The function trackItemChange checks to see if $item_ids is FALSE, but if it is empty it attempts to add it to the query which causes a SQL error. Attached is a small patch that changes the check to use empty().
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | search-api-empty_item_ids-1956650-8-D7.patch | 911 bytes | thelmer |
| #4 | 1956650-2--tracking_empty_item_ids--debugging.patch | 1.01 KB | drunken monkey |
| track_item_changed_items_empty.patch | 558 bytes | wwhurley |
Comments
Comment #1
martijn houtman commentedWe encountered the same error when trying to save a node. I am not sure why the item_id array is empty, but we got the following error:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 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 2: UPDATE {search_api_item} SET changed=:db_update_placeholder_0 WHERE (index_id IN (:db_condition_placeholder_0)) AND (changed = :db_condition_placeholder_1) AND (item_id IN ()) ; Array ( [:db_update_placeholder_0] => 1382013725 [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => 0 ) in SearchApiAbstractDataSourceController->trackItemChange() (line 601 of /.../datasource.inc).
The patch appears to fix it, but not sure if this is a workaround, rather than a fix.
Comment #2
drunken monkeyThe change does make sense (though the code is unnecessarily complicated), I'd be fine with committing that, especially if it causes exceptions.
However, you should still try to find out where the empty array is coming from, if possible. Just dump the stack trace at this point if
$item_idsis an empty array (and, of course, skip adding the condition). (You can use the attached patch to do that.)There might be some underlying bigger bug/error which we'd otherwise hide.
What type of server and item type of index are you using?
Comment #3
martijn houtman commentedThanks for your reply. It's a Solr server and a node index. This error came up sporadically, let me see if I can reproduce again.
Comment #4
drunken monkeyOh, oops, here is the mentioned patch.
Comment #5
drunken monkeyOK, I just committed a fix now. It would be great if you could still find the original source of the error, though.
Comment #7
donquixote commentedHi!
This fix does not seem to be part of 7.x-1.13 - or do I miss something?
Comment #8
thelmer commentedI also see this issue on some projects so I have attached a re-rolled patch.
Comment #9
drunken monkeyOh, you're right! I don't know why or how, but it seems I reverted that fix again in the course of #2115127: Index logic does not add failed items back to the queue or does not retry. I guess I used a branch for that issue and forgot to rebase, or something. Pretty silly.
Next time, please feel free to re-open the issue in such a case, since I don't look at closed issues. I now just re-committed the solution from two years ago.
@ thelmer: Thanks for re-opening! However, your solution is buggy – it would mark all items as changed if none changed (empty array).