ophian / styx

Serendipity Styx Edition - Styx is what Serendipity should be!
https://ophian.github.io
7 stars 0 forks source link

PHP Fatal error (mysql exception) #40

Closed hbarel closed 1 year ago

hbarel commented 1 year ago

When logging in as admin, I get a blank screen. The Apache log states:

PHP Fatal error: Uncaught mysqli_sql_exception: Incorrect integer value: '' for columnmydb.my_blog_config.authoridat row 1 in /var/www/blogs/include/db/mysqli.inc.php:76\nStack trace:\n#0 /var/www/blogs/include/db/mysqli.inc.php(76): mysqli_query()\n#1 /var/www/blogs/include/db/db.inc.php(84): serendipity_db_query()\n#2 /var/www/blogs/include/functions_config.inc.php(122): serendipity_db_insert()\n#3 /var/www/blogs/include/functions_installer.inc.php(1408): serendipity_set_config_var()\n#4 /var/www/blogs/include/admin/overview.inc.php(73): serendipity_getCurrentVersion()\n#5 /var/www/blogs/serendipity_admin.php(252): include('...')\n#6 {main}\n thrown in /var/www/blogs/include/db/mysqli.inc.php on line 76, referer: ...

The developer seems to have foreseen it in Line 109 of functions_config.inc, but this still happens and prevents the page from loading... (Using PHP 8.1.17).

hbarel commented 1 year ago

Oddly enough, the value of $authorid that is passed by serendipity_db_insert (in the function serendipity_set_config_var) is an integer (with value 0). So I am not sure where it is converted into ''.

ophian commented 1 year ago

Hi Oh sorry for this thing. I had this yesterday changing templates, so I quickly released the Styx 4.1.1 version afterwards. Its the issue that parameters are send to the mysqli serendipity_db_insert() function via an array. So integers are converted to string, depending on the used PHP version. This is where the 0 to '' is done. I was under the impression that only PHP 7 and 8.0 had this issue and newer PHP versions were able to handle such types via array correctly. This is what I did in include/db/db.inc.php https://github.com/ophian/styx/commit/74061c2b9cc532b74667625b16737c0d0075d560 I really wonder what has happened that suddenly this issue was on the table ( I had this with PHP 7.4.33 ), since the mysqli exception backport was done very early in Styx (Oct. 2021) and we all had plenty of time to see this happen. So perhaps you can raise the version 80100 to 80117 or 80200 in this commits file and see how it does...

ophian commented 1 year ago

Did this happen after the upgrade to Styx 4.1.1 or before? And since the last time you logged in, did PHP got an update in the meanwhile? It is confusing why this type juggeling happens so sudden...

hbarel commented 1 year ago

Did this happen after the upgrade to Styx 4.1.1 or before? And since the last time you logged in, did PHP got an update in the meanwhile? It is confusing why this type juggeling happens so sudden...

It happened since I upgraded from Styx 4.0.1 to 4.1.1.

And since the last time you logged in, did PHP got an update in the meanwhile?

I might be that PHP has been upgraded since the last login; I haven't thought of that... PHP did get an update a few days ago.

hbarel commented 1 year ago

So perhaps you can raise the version 80100 to 80117 or 80200 in this commits file and see how it does...

Changing 80100 to 80200 solved it! Thank you very much for that.

I did not try 80117 because this is the current version I have (8.1.17), and the relation is "<", rather than "<=", so I suspected it will not make a difference because the condition will still be #false.

ophian commented 1 year ago

Yeah, right! I definitely don't have this on my local PHP 8.2 though. I will have to check this for PHP 8.1 a little bit more, since I can't remember to have seen this lately, working strongly with 8.1.14 and a pre version of Styx 4.0. Then I will quickly push out a 4.1.2.

Serendipity often stores values to the config table, like 'last_template_change', 'last_update_check_*' etc. so this is where it happens, even at/after login (sometimes). I think the issue is just related to my change of giving up the cast for the authorid, since the main check has to run in serendipity_db_insert(), presumably for all PHP versions, but PHP 8.2 is able to handle it themselves.