[search] old links to search in an album are broken #1961

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

Related to https://piwigo.org/forum/viewtopic.php?id=33950

If a user (or a search engine, before #2218 ) has bookmarked the url of the "search in this set" button/icon in an album, like search.php?cat_id=1234, it will result in a broken search if the link is used when the album no longer exists.

Warning: [mysql error 1064] 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 '))
AND (category_id NOT IN (5,19,20,21,28,48,43,49,50,63,72,73,82,83,84,86,...' at line 5

SELECT DISTINCT(id)
FROM images i
INNER JOIN image_category AS ic ON id = ic.image_id
LEFT JOIN image_tag AS it ON id = it.image_id
WHERE (category_id IN ())
AND (category_id NOT IN (5,19,20,21,28,...,255))
ORDER BY file ASC, date_available DESC in include/dblayer/functions_mysqli.inc.php on line 847

Fatal error: Uncaught Error: Call to a member function fetch_assoc() on bool in include/dblayer/functions_mysqli.inc.php:908
Stack trace:
0 include/functions.inc.php(1640): query2array('\nSELECT DISTINC...', NULL, 'id')
1 include/functions_search.inc.php(457): array_from_query('\nSELECT DISTINC...', 'id')
2 include/functions_search.inc.php(1696): get_regular_search_results(Array, '')
3 include/section_init.inc.php(364): get_search_results('psk-20241027-9Q...', NULL)
4 index.php(12): include('/var/www/piwigo...')
5 {main} thrown in include/dblayer/functions_mysqli.inc.php on line 908

In search.php, we should check the availability of the cat_id. It may be deleted or not available for the visitor. It should simply say "page not found".

Related to https://piwigo.org/forum/viewtopic.php?id=33950 If a user (or a search engine, before #2218 ) has bookmarked the url of the "search in this set" button/icon in an album, like `search.php?cat_id=1234`, it will result in a broken search if the link is used when the album no longer exists. > Warning: [mysql error 1064] 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 ')) > AND (category_id NOT IN (5,19,20,21,28,48,43,49,50,63,72,73,82,83,84,86,...' at line 5 > > SELECT DISTINCT(id) > FROM images i > INNER JOIN image_category AS ic ON id = ic.image_id > LEFT JOIN image_tag AS it ON id = it.image_id > WHERE (category_id IN ()) > AND (category_id NOT IN (5,19,20,21,28,...,255)) > ORDER BY file ASC, date_available DESC in include/dblayer/functions_mysqli.inc.php on line 847 > > > Fatal error: Uncaught Error: Call to a member function fetch_assoc() on bool in include/dblayer/functions_mysqli.inc.php:908 > Stack trace: > 0 include/functions.inc.php(1640): query2array('\nSELECT DISTINC...', NULL, 'id') > 1 include/functions_search.inc.php(457): array_from_query('\nSELECT DISTINC...', 'id') > 2 include/functions_search.inc.php(1696): get_regular_search_results(Array, '') > 3 include/section_init.inc.php(364): get_search_results('psk-20241027-9Q...', NULL) > 4 index.php(12): include('/var/www/piwigo...') > 5 {main} thrown in include/dblayer/functions_mysqli.inc.php on line 908 In search.php, we should check the availability of the `cat_id`. It may be deleted or not available for the visitor. It should simply say "page not found". <!-- github-sync-id:2616761214 -->
adam closed this issue 2026-10-05 01:02:24 +02:00
Author
Owner

Just tested, works OK for an invalid album !

Just tested, works OK for an invalid album ! <!-- github-comment-id:2442519311 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1961