[search] when a search on word also matches tags #684

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

In the regular search page (search.php), if you "search for words" and check the "tags" box : if your search matches a tag, then on the photo page you get something like:

Notice: Undefined offset: 25 in picture.php on line 244

Warning:  [mysql error 1064] 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

SELECT *
  FROM images
  WHERE id IN (1351,1255,)
; in include/dblayer/functions_mysqli.inc.php on line 845
In the regular search page (search.php), if you "search for words" and check the "tags" box : if your search matches a tag, then on the photo page you get something like: ``` Notice: Undefined offset: 25 in picture.php on line 244 Warning: [mysql error 1064] 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 SELECT * FROM images WHERE id IN (1351,1255,) ; in include/dblayer/functions_mysqli.inc.php on line 845 ``` <!-- github-sync-id:245457851 -->
adam closed this issue 2026-10-05 00:11:24 +02:00
Author
Owner

The problem lies in the list of items returned by get_regular_search_results function : if the search in tags matches some photos which are already found on other photo properties, then the "array_unique" will not reset the numeric keys in the $page['items']. We need to reset the keys.

That's the quick fix. But there is also another issue: the sorting order, when a merge is applied in the results, is not compliant with $conf['order_by']. This should be fixed in the future.

The problem lies in the list of items returned by get_regular_search_results function : if the search in tags matches some photos which are already found on other photo properties, then the "array_unique" will not reset the numeric keys in the $page['items']. We need to reset the keys. That's the quick fix. But there is also another issue: the sorting order, when a merge is applied in the results, is not compliant with $conf['order_by']. This should be fixed in the future. <!-- github-comment-id:317792364 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#684