Case

search_api_node_access_records_alter calls datasource()->getItemId on received node. This function (getItemId) is allowed to return NULL as item id. Returned value is pushed into an array called $item_ids. Just after that search_api_track_item_change_for_indexes is called, and inside SearchApiDataSourceControllerInterface::trackItemChange si called.

SearchApiDataSourceControllerInterface::trackItemChange signature is:

trackItemChange($item_ids, array $indexes, $dequeue = FALSE);

With $items_ids documented as: array|false Either an array with the IDs of the changed items. Or FALSE to mark all items as changed for the given indexes.

But trackItemChange is receiving as $item_ids an array with a NULL element:

array(
  0 => NULL
);

Proposed resolution

To avoid this search_api_node_access_records_alter should not push NULL values into $item_ids array.

Additional info

This issue comes from debugging this one: #2738911: SearchApiEtDatasourceController::getItemId that returns NULL could force loading all nodes

CommentFileSizeAuthor
edit-2738911-1.patch663 bytestunic

Comments

tunic created an issue. See original summary.

  • drunken monkey committed ff80f77 on 7.x-1.x authored by tunic
    Issue #2742053 by tunic: Fixed change notification on node access...
drunken monkey’s picture

Status: Needs review » Fixed

Thanks a lot, looks good!
Committed.
The real problem, of course, is that allowing NULL as getItemId() return value is a design flaw. But nothing we can do about that really, so this is probably the best we can do.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.