nathanz@piwigo-01:~$ python3 piwigo_api_test.py
Traceback (most recent call last):
File "/home/nathanz/.local/lib/python3.10/site-packages/piwigo/ws.py", line 124, in __call__
result = r.json()
File "/usr/lib/python3/dist-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/nathanz/piwigo_api_test.py", line 8, in <module>
response = mysite.pwg.images.setMd5sum(block_size="20", pwg_token=pwg_token)
File "/home/nathanz/.local/lib/python3.10/site-packages/piwigo/ws.py", line 96, in checking
return fn(self, **kw)
File "/home/nathanz/.local/lib/python3.10/site-packages/piwigo/ws.py", line 135, in __call__
raise WsErrorException(r.text)
piwigo.ws.WsErrorException: <br />
<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 ')' at line 3 in /var/www/html/include/dblayer/functions_mysqli.inc.php:132
Stack trace:
#0 /var/www/html/include/dblayer/functions_mysqli.inc.php(132): mysqli->query()
#1 /var/www/html/include/dblayer/functions_mysqli.inc.php(888): pwg_query()
#2 /var/www/html/admin/include/functions.php(3294): query2array()
#3 /var/www/html/include/ws_functions/pwg.images.php(2602): add_md5sum()
#4 /var/www/html/include/ws_core.inc.php(600): ws_images_setMd5sum()
#5 /var/www/html/include/ws_protocols/rest_handler.php(41): PwgServer->invoke()
#6 /var/www/html/include/ws_core.inc.php(281): PwgRestRequestHandler->handleRequest()
#7 /var/www/html/ws.php(22): PwgServer->run()
#8 {main}
thrown in <b>/var/www/html/include/dblayer/functions_mysqli.inc.php</b> on line <b>132</b><br />
When all the images in the piwigo_images table have an md5sum value and the pwg.images.setMd5sum API is called, a JSONDecodeError is thrown. Issue is with the call to get_photos_no_md5sum():
https://github.com/Piwigo/Piwigo/blob/562170528c63a2318d153a08ec4847684fa71784/include/ws_functions/pwg.images.php#L2596
I have a fix in my local repo that wraps it in an if statement similar to how this is handled on the admin UI that I'll submit after I figure out pull requests:
https://github.com/Piwigo/Piwigo/blob/562170528c63a2318d153a08ec4847684fa71784/admin.php#L290-L295
Sample Code:
```
from piwigo import Piwigo
mysite = Piwigo('http://localhost')
mysite.pwg.session.login(username="______", password="__________")
pwg_token = mysite.pwg.session.getStatus()['pwg_token']
response = mysite.pwg.images.setMd5sum(block_size="20", pwg_token=pwg_token)
print(response)
```
Output:
```
nathanz@piwigo-01:~$ python3 piwigo_api_test.py
Traceback (most recent call last):
File "/home/nathanz/.local/lib/python3.10/site-packages/piwigo/ws.py", line 124, in __call__
result = r.json()
File "/usr/lib/python3/dist-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/nathanz/piwigo_api_test.py", line 8, in <module>
response = mysite.pwg.images.setMd5sum(block_size="20", pwg_token=pwg_token)
File "/home/nathanz/.local/lib/python3.10/site-packages/piwigo/ws.py", line 96, in checking
return fn(self, **kw)
File "/home/nathanz/.local/lib/python3.10/site-packages/piwigo/ws.py", line 135, in __call__
raise WsErrorException(r.text)
piwigo.ws.WsErrorException: <br />
<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 ')' at line 3 in /var/www/html/include/dblayer/functions_mysqli.inc.php:132
Stack trace:
#0 /var/www/html/include/dblayer/functions_mysqli.inc.php(132): mysqli->query()
#1 /var/www/html/include/dblayer/functions_mysqli.inc.php(888): pwg_query()
#2 /var/www/html/admin/include/functions.php(3294): query2array()
#3 /var/www/html/include/ws_functions/pwg.images.php(2602): add_md5sum()
#4 /var/www/html/include/ws_core.inc.php(600): ws_images_setMd5sum()
#5 /var/www/html/include/ws_protocols/rest_handler.php(41): PwgServer->invoke()
#6 /var/www/html/include/ws_core.inc.php(281): PwgRestRequestHandler->handleRequest()
#7 /var/www/html/ws.php(22): PwgServer->run()
#8 {main}
thrown in <b>/var/www/html/include/dblayer/functions_mysqli.inc.php</b> on line <b>132</b><br />
```
<!-- github-sync-id:2128060694 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
When all the images in the piwigo_images table have an md5sum value and the pwg.images.setMd5sum API is called, a JSONDecodeError is thrown. Issue is with the call to get_photos_no_md5sum():
https://github.com/Piwigo/Piwigo/blob/562170528c63a2318d153a08ec4847684fa71784/include/ws_functions/pwg.images.php#L2596
I have a fix in my local repo that wraps it in an if statement similar to how this is handled on the admin UI that I'll submit after I figure out pull requests:
https://github.com/Piwigo/Piwigo/blob/562170528c63a2318d153a08ec4847684fa71784/admin.php#L290-L295
Sample Code:
Output: