diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index 9071cac..21d8cb6 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -124,17 +124,24 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ if ($this->isDefaultRevision()) { \Drupal::entityManager()->getAccessController('node')->writeGrants($this, $update); } + + // Reindex the node when it is updated. The node is automatically indexed + // when it is added, simply by being added to the node table. + if (!$update) { + node_reindex_node_search($this->id()); + } } /** * {@inheritdoc} */ - public static function preDelete(EntityStorageControllerInterface $storage_controller, array $entities) { - parent::preDelete($storage_controller, $entities); + public static function postDelete(EntityStorageControllerInterface $storage_controller, array $entities) { + parent::postDelete($storage_controller, $entities); - if (module_exists('search')) { + // Assure that all nodes deleted are removed from the search index. + if (\Drupal::moduleHandler()->moduleExists('search')) { foreach ($entities as $entity) { - search_reindex($entity->nid->value, 'node'); + search_reindex($entity->nid->value, 'node_search'); } } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index cf31cc4..5d48d90 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -2210,15 +2210,6 @@ function node_reindex_node_search($nid) { } /** - * Implements hook_node_update(). - */ -function node_node_update(EntityInterface $node) { - // Reindex the node when it is updated. The node is automatically indexed - // when it is added, simply by being added to the node table. - node_reindex_node_search($node->id()); -} - -/** * Implements hook_comment_insert(). */ function node_comment_insert($comment) {