diff --git a/src/Entity/Index.php b/src/Entity/Index.php index fb6bb03..954db69 100644 --- a/src/Entity/Index.php +++ b/src/Entity/Index.php @@ -384,8 +384,11 @@ class Index extends ConfigEntityBase implements IndexInterface { $tracker_settings = $this->getTrackerSettings()[$this->getTrackerId()]; } $tracker_plugin_configuration = array('index' => $this) + $tracker_settings['settings']; - if (!($this->trackerInstance = \Drupal::service('plugin.manager.search_api.tracker')->createInstance($this->getTrackerId(), $tracker_plugin_configuration))) { - $args['@tracker'] = $this->tracker_settings; + + try { + $this->trackerInstance = \Drupal::service('plugin.manager.search_api.tracker')->createInstance($this->getTrackerId(), $tracker_plugin_configuration); + } catch (PluginException $pe) { + $args['@tracker'] = $tracker_settings['plugin_id']; $args['%index'] = $this->label(); throw new SearchApiException(new FormattableMarkup('The tracker with ID "@tracker" could not be retrieved for index %index.', $args)); } diff --git a/src/Task/ServerTaskManager.php b/src/Task/ServerTaskManager.php index d1f7e01..f0a7e22 100644 --- a/src/Task/ServerTaskManager.php +++ b/src/Task/ServerTaskManager.php @@ -50,9 +50,17 @@ class ServerTaskManager implements ServerTaskManagerInterface { */ public function execute(ServerInterface $server = NULL) { $select = $this->database->select('search_api_task', 't'); + // Only retrieve tasks we can handle. + $allowed_tasks = array( + 'addIndex', + 'updateIndex', + 'removeIndex', + 'deleteItems', + 'deleteAllIndexItems' + ); $select->fields('t') - // Only retrieve tasks we can handle. - ->condition('t.type', array('addIndex', 'updateIndex', 'removeIndex', 'deleteItems', 'deleteAllIndexItems'), 'IN'); + ->condition('t.type', $allowed_tasks, 'IN'); + if ($server) { if (!$server->status()) { return FALSE; diff --git a/tests/src/Kernel/CliTest.php b/tests/src/Kernel/CliTest.php index bba9fed..96109ad 100644 --- a/tests/src/Kernel/CliTest.php +++ b/tests/src/Kernel/CliTest.php @@ -94,8 +94,18 @@ class CliTest extends KernelTestBase { 'name' => 'Test index', 'id' => 'index', 'status' => 1, - 'datasources' => array('entity:entity_test'), - 'tracker' => 'default', + 'datasource_settings' => array( + 'entity:entity_test' => array( + 'plugin_id' => 'entity:entity_test', + 'settings' => array() + ) + ), + 'tracker_settings' => array( + 'default' => array( + 'plugin_id' => 'default', + 'settings' => array() + ) + ), 'server' => $this->server->id(), 'options' => array('index_directly' => TRUE), ));