Upload from Darktable fails #1740

Closed
opened 2026-10-05 00:55:05 +02:00 by adam · 3 comments
Owner

Piwigo version: 13.8.0

I'm trying to upload an image to my piwigo instance from darktable, as can be seen in the nginx access log:

192.168.100.12 - - [27/Sep/2023:08:57:52 +0200] "POST /ws.php?format=json HTTP/2.0" 200 88 "-" "darktable/4.5.0+723~g12fe3a93dd"

Upload fails, the following error is then logged in the nginx error log:

PHP message: PHP Fatal error:  Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 4 in /var/www/hostname/piwigo/include/dblayer/functions_mysqli.inc.php:132
Stack trace:
#0 /var/www/hostname/piwigo/include/dblayer/functions_mysqli.inc.php(132): mysqli->query()
#1 /var/www/hostname/piwigo/include/ws_functions/pwg.images.php(2397): pwg_query()
#2 /var/www/hostname/piwigo/include/ws_core.inc.php(600): ws_images_uploadCompleted()
#3 /var/www/hostname/piwigo/include/ws_protocols/rest_handler.php(41): PwgServer->invoke()
#4 /var/www/hostname/piwigo/include/ws_core.inc.php(281): PwgRestRequestHandler->handleRequest()
#5 /var/www/hostname/piwigo/ws.php(22): PwgServer->run()
#6 {main}
  thrown in /var/www/hostname/piwigo/include/dblayer/functions_mysqli.inc.php on line 132" while reading response header from upstream, client: 192.168.100.12, server: hostname, request: "POST /ws.php?format=json HTTP/2.0", upstream: "fastcgi://127.0.0.1:9001", host: "hostname"

If I dump the offending query in pwg.images.php(2397), it shows the problem:

2023/09/27 08:57:52 [error] 7751#7751: *215 FastCGI sent in stderr: "PHP message: 
SELECT
    COUNT(*) AS nb_photos
  FROM piwigo_image_category
  WHERE category_id = 
;PHP message: PHP Fatal error:  Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 4 in /var/www/hostname/piwigo/include/dblayer/functions_mysqli.inc.php:132

So, the category_id is empty or missing from the WHERE clause.

I would expect the query not to fail and the upload to succeed.

Piwigo version: 13.8.0 I'm trying to upload an image to my piwigo instance from darktable, as can be seen in the nginx access log: ``` 192.168.100.12 - - [27/Sep/2023:08:57:52 +0200] "POST /ws.php?format=json HTTP/2.0" 200 88 "-" "darktable/4.5.0+723~g12fe3a93dd" ``` Upload fails, the following error is then logged in the nginx error log: ``` PHP message: PHP Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 4 in /var/www/hostname/piwigo/include/dblayer/functions_mysqli.inc.php:132 Stack trace: #0 /var/www/hostname/piwigo/include/dblayer/functions_mysqli.inc.php(132): mysqli->query() #1 /var/www/hostname/piwigo/include/ws_functions/pwg.images.php(2397): pwg_query() #2 /var/www/hostname/piwigo/include/ws_core.inc.php(600): ws_images_uploadCompleted() #3 /var/www/hostname/piwigo/include/ws_protocols/rest_handler.php(41): PwgServer->invoke() #4 /var/www/hostname/piwigo/include/ws_core.inc.php(281): PwgRestRequestHandler->handleRequest() #5 /var/www/hostname/piwigo/ws.php(22): PwgServer->run() #6 {main} thrown in /var/www/hostname/piwigo/include/dblayer/functions_mysqli.inc.php on line 132" while reading response header from upstream, client: 192.168.100.12, server: hostname, request: "POST /ws.php?format=json HTTP/2.0", upstream: "fastcgi://127.0.0.1:9001", host: "hostname" ``` If I dump the offending query in `pwg.images.php(2397)`, it shows the problem: ``` 2023/09/27 08:57:52 [error] 7751#7751: *215 FastCGI sent in stderr: "PHP message: SELECT COUNT(*) AS nb_photos FROM piwigo_image_category WHERE category_id = ;PHP message: PHP Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 4 in /var/www/hostname/piwigo/include/dblayer/functions_mysqli.inc.php:132 ``` So, the `category_id` is empty or missing from the `WHERE` clause. I would expect the query not to fail and the upload to succeed. <!-- github-sync-id:1914845239 -->
adam closed this issue 2026-10-05 00:55:05 +02:00
Author
Owner

The issue ist most likely with darktable, sorry for the noise.

The issue ist most likely with darktable, sorry for the noise. <!-- github-comment-id:1737289781 -->
Author
Owner

I reopen this issue. It is an issue and it's not fixed.

I reopen this issue. It is an issue and it's not fixed. <!-- github-comment-id:1918995468 -->
Author
Owner

Due to https://github.com/Piwigo/Piwigo/commit/36d403659cb1fae85c320e9f03c355f2fe3aa922 the photo now appears with some delay in the selected album when uploading from darktable - see https://github.com/darktable-org/darktable/issues/16994

Due to https://github.com/Piwigo/Piwigo/commit/36d403659cb1fae85c320e9f03c355f2fe3aa922 the photo now appears with some delay in the selected album when uploading from darktable - see https://github.com/darktable-org/darktable/issues/16994 <!-- github-comment-id:2169208995 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1740