Problem/Motivation

If search_api_index_specific_items_delayed() is called it registers _search_api_index_queued_items() as a drupal shutdown callback.
And it does this as long as the static variable $queue is empty.
The problem is if I call search_api_index_specific_items_delayed() to check if there's a queue, I omit the index and ids parameter. This means an empty queue is created and the shutdown function is registered.
This leads to an endless loop since _search_api_index_queued_items() also calls search_api_index_specific_items_delayed() to fetch the queue - since the queue is empty another shutdown callback is registered. Because the whole thing works with a reference the loop over the shutdown function gets immediately a new callback, which will add also a new callback and so on.

Proposed resolution

Add another static variable, that indicates whether the shutdown callback is registered.

Remaining tasks

Review

User interface changes

none

API changes

none

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Title: Prevent endlessloop in search_api_index_specific_items_delayed() » Fix endless loop in search_api_index_specific_items_delayed()
Status: Needs review » Fixed

Thanks for spotting and fixing that! Seems sensible.
Committed.

Status: Fixed » Closed (fixed)

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