diff --git a/src/Form/IndexForm.php b/src/Form/IndexForm.php index 5f3f933..447f0df 100644 --- a/src/Form/IndexForm.php +++ b/src/Form/IndexForm.php @@ -8,7 +8,6 @@ namespace Drupal\search_api\Form; use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityManagerInterface; diff --git a/src/Form/IndexStatusForm.php b/src/Form/IndexStatusForm.php index a39717a..1d5e6f6 100644 --- a/src/Form/IndexStatusForm.php +++ b/src/Form/IndexStatusForm.php @@ -44,7 +44,7 @@ class IndexStatusForm extends FormBase { $form['tracking'] = array( '#type' => 'details', '#title' => $this->t('Track items for index'), - '#description' => $this->t('Not all items have been tracked for this index. This means, the displayed index status is incomplete and not all items will currently be indexed.'), + '#description' => $this->t('Not all items have been tracked for this index. This means the displayed index status is incomplete and not all items will currently be indexed.'), '#open' => TRUE, '#attributes' => array( 'class' => array('container-inline'), diff --git a/src/Task/IndexTaskManager.php b/src/Task/IndexTaskManager.php index 89f5b8a..864262d 100644 --- a/src/Task/IndexTaskManager.php +++ b/src/Task/IndexTaskManager.php @@ -121,7 +121,7 @@ class IndexTaskManager implements IndexTaskManagerInterface { if (!empty($index_state['status'])) { $batch_definition = array( 'operations' => array( - array(array($this, 'processBatch'), array($index)), + array(array($this, 'processBatch'), array($index->id())), ), 'finished' => array($this, 'finishBatch'), ); @@ -133,13 +133,15 @@ class IndexTaskManager implements IndexTaskManagerInterface { /** * Adds one page of items to the tracker as part of a batch operation. * - * @param \Drupal\search_api\IndexInterface $index - * The index on which items should be indexed. + * @param string $index_id + * The ID of the index on which items should be indexed. * @param array $context * The current batch context, as defined in the @link batch Batch operations * @endlink documentation. */ - public function processBatch(IndexInterface $index, array &$context) { + public function processBatch($index_id, array &$context) { + /** @var \Drupal\search_api\IndexInterface $index */ + $index = $this->entityManager->getStorage('search_api_index')->load($index_id); $added = $this->addItemsOnce($index); if ($added === NULL) { $context['finished'] = 1; @@ -268,4 +270,23 @@ class IndexTaskManager implements IndexTaskManagerInterface { return 'search_api.index.' . $index->id() . '.tasks'; } + /** + * Implements the magic __sleep() method. + * + * Prevents the any properties from being serialized. + */ + public function __sleep() { + return array(); + } + + /** + * Implements the magic __wakeup() method. + * + * Reloads the services into this object's properties. + */ + public function __wakeup() { + $this->state = \Drupal::state(); + $this->entityManager = \Drupal::entityManager(); + } + }