After upgrade several features don't work, bad SQL in error #2102

Open
opened 2026-10-05 01:06:24 +02:00 by adam · 1 comment
Owner

I upgraded Piwigo and several things stopped working entirely. For example, editing a folder fails when hitting the Save Settings button.
Hitting Save Settings results in a call to /gallery/ws.php?format=json&method=pwg.categories.setInfo with the following payload:
category_id=827&name=Stable+Diffusion+and+other+AI+Images&comment=All+of+the+images+in+this+gallery+were+generated+by+Stable+Diffusion+from+text+prompts.++There+are+no+actual+photographs+in+these+albums.&visible=true&commentable=true&pwg_token=0cf1945e37383cd7324376febe46e1f6

This is the error shown in the response:
Fatal error
Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
AND level >8
AND level <= 8
GROUP BY category_id' at line 5 in /home/sgartner/public.photosdirect2you.com/gallery/include/dblayer/functions_mysqli.inc.php:132
Stack trace:
#0 /home/sgartner/public.photosdirect2you.com/gallery/include/dblayer/functions_mysqli.inc.php(132): mysqli->query('\nSELECT\n cat...')
#1 /home/sgartner/public.photosdirect2you.com/gallery/include/dblayer/functions_mysqli.inc.php(888): pwg_query('\nSELECT\n cat...')
#2 /home/sgartner/public.photosdirect2you.com/gallery/include/functions.inc.php(1633): query2array('\nSELECT\n cat...', 'category_id')
#3 /home/sgartner/public.photosdirect2you.com/gallery/plugins/community/include/functions_community.inc.php(197): hash_from_query('\nSELECT\n cat...', 'category_id')
#4 /home/sgartner/public.photosdirect2you.com/gallery/plugins/community/main.inc.php(49): community_get_user_permissions('1')
#5 /home/sgartner/public.photosdirect2you.com/gallery/include/functions_plugins.inc.php(264): community_init()
#6 /home/sgartner/public.photosdirect2you.com/gallery/include/common.inc.php(343): trigger_notify('init')
#7 /home/sgartner/public.photosdirect2you.com/gallery/ws.php(12): include_once('/home/sgartner/...')
#8 {main}
thrown in /home/sgartner/public.photosdirect2you.com/gallery/include/dblayer/functions_mysqli.inc.php
on line 132

There are no strange characters in the name or comment (and there weren't any strange characters in either field previously). The code that is generating this query is definitely in the Community plugin, it was referencing "AND level >8 AND level <= 8" in community_get_user_permissions(). Also, from looking at the error code it should have printed the whole SQL string into the result, so I can only assume that the SQL shown above is what it tried to execute (i.e. there was no SELECT in the query string), but I might be missing something.

When I tried to disable the Community Plugin it failed to disable at first, then it failed to enable, then it worked and things started working again for a short while and then they seem to have broken again. I'm not sure what to try, I really can't do without the community plugin.

I upgraded Piwigo and several things stopped working entirely. For example, editing a folder fails when hitting the Save Settings button. Hitting Save Settings results in a call to /gallery/ws.php?format=json&method=pwg.categories.setInfo with the following payload: category_id=827&name=Stable+Diffusion+and+other+AI+Images&comment=All+of+the+images+in+this+gallery+were+generated+by+Stable+Diffusion+from+text+prompts.++There+are+no+actual+photographs+in+these+albums.&visible=true&commentable=true&pwg_token=0cf1945e37383cd7324376febe46e1f6 This is the error shown in the response: <b>Fatal error</b> : Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND level &gt;8 AND level &lt;= 8 GROUP BY category_id' at line 5 in /home/sgartner/public.photosdirect2you.com/gallery/include/dblayer/functions_mysqli.inc.php:132 Stack trace: #0 /home/sgartner/public.photosdirect2you.com/gallery/include/dblayer/functions_mysqli.inc.php(132): mysqli-&gt;query('\nSELECT\n cat...') #1 /home/sgartner/public.photosdirect2you.com/gallery/include/dblayer/functions_mysqli.inc.php(888): pwg_query('\nSELECT\n cat...') #2 /home/sgartner/public.photosdirect2you.com/gallery/include/functions.inc.php(1633): query2array('\nSELECT\n cat...', 'category_id') #3 /home/sgartner/public.photosdirect2you.com/gallery/plugins/community/include/functions_community.inc.php(197): hash_from_query('\nSELECT\n cat...', 'category_id') #4 /home/sgartner/public.photosdirect2you.com/gallery/plugins/community/main.inc.php(49): community_get_user_permissions('1') #5 /home/sgartner/public.photosdirect2you.com/gallery/include/functions_plugins.inc.php(264): community_init() #6 /home/sgartner/public.photosdirect2you.com/gallery/include/common.inc.php(343): trigger_notify('init') #7 /home/sgartner/public.photosdirect2you.com/gallery/ws.php(12): include_once('/home/sgartner/...') #8 {main} thrown in <b>/home/sgartner/public.photosdirect2you.com/gallery/include/dblayer/functions_mysqli.inc.php</b> on line <b>132</b> There are no strange characters in the name or comment (and there weren't any strange characters in either field previously). The code that is generating this query is definitely in the Community plugin, it was referencing "AND level >8 AND level <= 8" in community_get_user_permissions(). Also, from looking at the error code it should have printed the whole SQL string into the result, so I can only assume that the SQL shown above is what it tried to execute (i.e. there was no SELECT in the query string), but I might be missing something. When I tried to disable the Community Plugin it failed to disable at first, then it failed to enable, then it worked and things started working again for a short while and then they seem to have broken again. I'm not sure what to try, I really can't do without the community plugin. <!-- github-sync-id:3551632385 -->
Author
Owner

Something I discovered after uploading the above is that if I logout and log back in then things start working again. I figure I must have logged out and back in before trying to disable the community plugin because it only allows me to disable it if I try before things go south, so disabling the community plugin isn't actually a solution at all, it was things getting corrupted (very quickly, within a few clicks) and logging in clears the problem.

tl;dr logging out and back in fixes the problem every time.

Something I discovered after uploading the above is that if I logout and log back in then things start working again. I figure I must have logged out and back in before trying to disable the community plugin because it only allows me to disable it if I try before things go south, so disabling the community plugin isn't actually a solution at all, it was things getting corrupted (very quickly, within a few clicks) and logging in clears the problem. tl;dr logging out and back in fixes the problem every time. <!-- github-comment-id:3445636977 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2102