rudolphi / open_enventory

PHP/MySQL-based chemical inventory/Electronic Lab Notebook for chemistry
https://sourceforge.net/projects/enventory/
GNU Affero General Public License v3.0
11 stars 6 forks source link

Problem making checkbox selections then pressing 'selected' in navbar #16

Open BRFud opened 1 year ago

BRFud commented 1 year ago

Hello. I am evaluating this software for use in a small business and encountering an error.

I have entered some items into the local database and selected their checkbox in search, but I get the following error in the apache error log when then pressing "selected" in the navbar:

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/html/lib_db_filter.php:197 Stack trace: #0 /var/www/html/lib_db_query.php(1026): getFilterObject() #1 /var/www/html/list.php(53): handleQueryRequest() #2 {main} thrown in /var/www/html/lib_db_filter.php on line 197

Any idea what the problem could be?

System is running on Ubuntu 22.04, php 8.1, apache2. Installation was from open_enventory_2022-11-29_php8.zip on Sourceforge. Thank you!

BRFud commented 1 year ago

Trying to solve this issue I am additionally encountering another fatal error when attempting to create a new user:

PHP Fatal error: Uncaught TypeError: array_sum(): Argument #1 ($array) must be of type array, null given in /var/www/html/lib_db_manip_edit.php:1898\nStack trace:\n#0 /var/www/html/lib_db_manip_edit.php(1898): array_sum()\n#1 /var/www/html/lib_db_manip.php(1066): performEdit()\n#2 /var/www/html/editAsync.php(78): handleDesiredAction()\n#3 {main}\n thrown in /var/www/html/lib_db_manip_edit.php on line 1898

I'll continue to try and work out if I have configured php or the database incorrectly...

rudolphi commented 1 year ago

Hi BRFud,

the 2nd problem looks like I have fixed it already, but not yet published the update (always try to collect a bit). The 1st I have just fixed, please find the files I meanwhile updated attached. I will push this also to the git during the day and create a fresh release, hoping that the number of problems resulting from transition to PHP8 will approach 0 soon. Thanks for your error reports. If you like, email any Apache error.log files to fr@sciformation.com so that I can fix anything I find within.

Best regards, unpublished_updates_23-01-29.zip

Felix

BRFud commented 1 year ago

Thank you for the reply, and for all your efforts (adapting code to maintain php compatability is a frustrating task, from my experience). I am no longer getting the fatal error, but neither are the selections appearing when I click 'selected' in the navbar. Here are the warnings from apache log:

PHP Warning:  Undefined array key "selection" in /var/www/html/lib_db_filter.php on line 197, referer: /topnav.php?db_name=storage&user=root&sess_proof=63d70fbe3a6a1
PHP Warning:  Trying to access array offset on value of type null in /var/www/html/lib_db_filter.php on line 197, referer: /topnav.php?db_name=storage&user=root&sess_proof=63d70fbe3a6a1
PHP Warning:  Undefined array key 10002 in /var/www/html/lib_db_filter.php on line 254, referer: /topnav.php?db_name=storage&user=root&sess_proof=63d70fbe3a6a1
PHP Warning:  Trying to access array offset on value of type null in /var/www/html/lib_db_filter.php on line 836, referer: /topnav.php?db_name=storage&user=root&sess_proof=63d70fbe3a6a1
PHP Warning:  Undefined variable $per_page_text in /var/www/html/list.php on line 205, referer: /topnav.php?db_name=storage&user=root&sess_proof=63d70fbe3a6a1

Perhaps it is best I wait for you to push the fresh release?

rudolphi commented 1 year ago

Hi BRFud, thanks for the list of warnings, I will fix them (but they are not the cause of the remaining problem).

Have you tried to use the "Select" checkboxes with a normal user (i.e. not root)? root is special, it does not have and entry in 'person' table - and that is also where we store settings and info on users' selection of datasets... With a regular account, I just tried it successfully (and yes, we should explain this a bit somewhere...).

BRFud commented 1 year ago

Thanks for your reply. Unfortunately I seem unable to create a new user. On creating a brand new database I immediately go to settings > users, and click the + to add a new user. Nothing happens in the browser when I click the green tick after entering a username/password and first/last name and leave all else defaults. The apache log gives:

PHP Fatal error:  Uncaught mysqli_sql_exception: Can't find any matching row in the user table in /var/www/html/lib_db_manip_edit.php:1948\nStack trace:\n#0 /var/www/html/lib_db_manip_edit.php(1948): mysqli_query()\n#1 /var/www/html/lib_db_manip.php(1066): performEdit()\n#2 /var/www/html/editAsync.php(78): handleDesiredAction()\n#3 {main}\n  thrown in /var/www/html/lib_db_manip_edit.php on line 1948, referer: /edit.php?db_name=storage2&user=root&dbs=-1&per_page=100&sess_proof=63d78022af7cf&desired_action=new&table=person&
rudolphi commented 1 year ago

Creating (and deleting) users is fixed. The SQL command was a safeguard needed in certain MySQL versions. From PHP8 onwards, it throws an exception (that we can just ignore). Fix is within https://sourceforge.net/projects/enventory/files/update_2022-11-29_to_2023-01-29_php8.zip/download (only files lib_db_manip_edit.php and lib_db_manip_del.php changed, I updated yesterday's update, instead of issuing an additional one)

BRFud commented 1 year ago

Thank you! It's working well enough now to explore more of the software. Regarding explaining the special nature of the root user, perhaps whenever anyone is logged in as root, the "you are logged in as root" in the navbar could be higghlighted as a reminder not to start doing things they should be doing with the normal user.

I have bumped into another issue (I hope you don't mind being notified here): when I select Settings>Global>Internet data retrieval, I am unable to deactivate or re-order the individual data sources.

rudolphi commented 1 year ago

Thanks for reporting, I pushed the fixed files, or you can just use the one in the zip 23-01-02_oe_bugfix_settings_dlg.zip Regards, Felix