SQL error - category_id out of SMALLINT(5) range #1855

Open
opened 2026-10-05 00:58:48 +02:00 by adam · 0 comments
Owner

Hello,

I am getting this error:

Fatal error: Uncaught mysqli_sql_exception: Out of range value for column 'category_id' at row 1 in /srv/hfr-internal/include/dblayer/functions_mysqli.inc.php:132 Stack trace: #0 /srv/hfr-internal/include/dblayer/functions_mysqli.inc.php(132): mysqli->query() #1 /srv/hfr-internal/include/functions.inc.php(533): pwg_query() #2 /srv/hfr-internal/index.php(723): pwg_log() #3 {main} thrown in /srv/hfr-internal/include/dblayer/functions_mysqli.inc.php on line 132

The problem is that the category_id type table is SMALLINT(5) SIGNED. That gives me a range of -32768 to 32767. My max category id value is 38738, so above that range.

If I am logged in as an admin I get no message, probably because pwg_log() doesn't record admin activity to the piwigo_history table? However, if I am logged in as a normal user I see the error at the bottom of the page. In addition, the thumbnail doesn't show up and I can't open the image (while everything works if I am an admin).

The solution seems somewhat simple - I just changed the attribute to UNSIGNED. I am not sure having it SIGNED confers any benefits given that half of that range is not usable for us (we don't have categories with negative category_ids). But not sure it is the optimal solution.

Hello, I am getting this error: Fatal error: Uncaught mysqli_sql_exception: Out of range value for column 'category_id' at row 1 in /srv/hfr-internal/include/dblayer/functions_mysqli.inc.php:132 Stack trace: #0 /srv/hfr-internal/include/dblayer/functions_mysqli.inc.php(132): mysqli->query() #1 /srv/hfr-internal/include/functions.inc.php(533): pwg_query() #2 /srv/hfr-internal/index.php(723): pwg_log() #3 {main} thrown in /srv/hfr-internal/include/dblayer/functions_mysqli.inc.php on line 132 The problem is that the category_id type table is SMALLINT(5) SIGNED. That gives me a range of -32768 to 32767. My max category id value is 38738, so above that range. If I am logged in as an admin I get no message, probably because pwg_log() doesn't record admin activity to the piwigo_history table? However, if I am logged in as a normal user I see the error at the bottom of the page. In addition, the thumbnail doesn't show up and I can't open the image (while everything works if I am an admin). The solution seems somewhat simple - I just changed the attribute to UNSIGNED. I am not sure having it SIGNED confers any benefits given that half of that range is not usable for us (we don't have categories with negative category_ids). But not sure it is the optimal solution. <!-- github-sync-id:2192583181 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1855