Commit 7dc65c5c authored by larowlan's avatar larowlan

Issue #3075695 by kim.pepper, andypost, jhodgdon, larowlan, pwolanin, Sam152:...

Issue #3075695 by kim.pepper, andypost, jhodgdon, larowlan, pwolanin, Sam152: Move search_index() and related functions to a service
parent af98f5bd
......@@ -18,6 +18,7 @@
use Drupal\help_topics\SearchableHelpInterface;
use Drupal\search\Plugin\SearchIndexingInterface;
use Drupal\search\Plugin\SearchPluginBase;
use Drupal\search\SearchIndexInterface;
use Drupal\search\SearchQuery;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -91,6 +92,13 @@ class HelpSearch extends SearchPluginBase implements AccessibleInterface, Search
*/
protected $helpSectionManager;
/**
* The search index.
*
* @var \Drupal\search\SearchIndexInterface
*/
protected $searchIndex;
/**
* {@inheritdoc}
*/
......@@ -105,7 +113,8 @@ public static function create(ContainerInterface $container, array $configuratio
$container->get('messenger'),
$container->get('current_user'),
$container->get('state'),
$container->get('plugin.manager.help_section')
$container->get('plugin.manager.help_section'),
$container->get('search.index')
);
}
......@@ -132,8 +141,10 @@ public static function create(ContainerInterface $container, array $configuratio
* The state object.
* @param \Drupal\help\HelpSectionManager $help_section_manager
* The help section manager.
* @param \Drupal\search\SearchIndexInterface $search_index
* The search index.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, Config $search_settings, LanguageManagerInterface $language_manager, MessengerInterface $messenger, AccountInterface $account, StateInterface $state, HelpSectionManager $help_section_manager) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, Config $search_settings, LanguageManagerInterface $language_manager, MessengerInterface $messenger, AccountInterface $account, StateInterface $state, HelpSectionManager $help_section_manager, SearchIndexInterface $search_index) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->database = $database;
$this->searchSettings = $search_settings;
......@@ -142,6 +153,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
$this->account = $account;
$this->state = $state;
$this->helpSectionManager = $help_section_manager;
$this->searchIndex = $search_index;
}
/**
......@@ -327,35 +339,41 @@ public function updateIndex() {
$language_list = $this->languageManager->getLanguages(LanguageInterface::STATE_CONFIGURABLE);
$section_plugins = [];
foreach ($items as $item) {
$section_plugin_id = $item->section_plugin_id;
if (!isset($section_plugins[$section_plugin_id])) {
$section_plugins[$section_plugin_id] = $this->getSectionPlugin($section_plugin_id);
}
$words = [];
try {
foreach ($items as $item) {
$section_plugin_id = $item->section_plugin_id;
if (!isset($section_plugins[$section_plugin_id])) {
$section_plugins[$section_plugin_id] = $this->getSectionPlugin($section_plugin_id);
}
if (!$section_plugins[$section_plugin_id]) {
$this->removeItemsFromIndex($item->sid);
continue;
}
if (!$section_plugins[$section_plugin_id]) {
$this->removeItemsFromIndex($item->sid);
continue;
}
$section_plugin = $section_plugins[$section_plugin_id];
search_index_clear($this->getType(), $item->sid);
foreach ($language_list as $langcode => $language) {
$topic = $section_plugin->renderTopicForSearch($item->topic_id, $language);
if ($topic) {
// Index the title plus body text.
$text = '<h1>' . $topic['title'] . '</h1>' . "\n" . $topic['text'];
search_index($this->getType(), $item->sid, $langcode, $text);
$section_plugin = $section_plugins[$section_plugin_id];
$this->searchIndex->clear($this->getType(), $item->sid);
foreach ($language_list as $langcode => $language) {
$topic = $section_plugin->renderTopicForSearch($item->topic_id, $language);
if ($topic) {
// Index the title plus body text.
$text = '<h1>' . $topic['title'] . '</h1>' . "\n" . $topic['text'];
$words += $this->searchIndex->index($this->getType(), $item->sid, $langcode, $text);
}
}
}
}
finally {
$this->searchIndex->updateWordWeights($words);
}
}
/**
* {@inheritdoc}
*/
public function indexClear() {
search_index_clear($this->getType());
$this->searchIndex->clear($this->getType());
}
/**
......@@ -419,7 +437,7 @@ public function updateTopicList() {
*/
public function markForReindex() {
$this->updateTopicList();
search_mark_for_reindex($this->getType());
$this->searchIndex->markForReindex($this->getType());
}
/**
......@@ -466,7 +484,7 @@ protected function removeItemsFromIndex($sids) {
// Remove items from the search tables individually, as there is no bulk
// function to delete items from the search index.
foreach ($sids as $sid) {
search_index_clear($this->getType(), $sid);
$this->searchIndex->clear($this->getType(), $sid);
}
}
......
......@@ -1421,7 +1421,7 @@ function node_configurable_language_delete(ConfigurableLanguageInterface $langua
function node_reindex_node_search($nid) {
if (\Drupal::moduleHandler()->moduleExists('search')) {
// Reindex node context indexed by the node module search plugin.
search_mark_for_reindex('node_search', $nid);
\Drupal::service('search.index')->markForReindex('node_search', $nid);
}
}
......
......@@ -163,9 +163,11 @@ public static function preDelete(EntityStorageInterface $storage, array $entitie
parent::preDelete($storage, $entities);
// Ensure that all nodes deleted are removed from the search index.
if (\Drupal::moduleHandler()->moduleExists('search')) {
if (\Drupal::hasService('search.index')) {
/** @var \Drupal\search\SearchIndexInterface $search_index */
$search_index = \Drupal::service('search.index');
foreach ($entities as $entity) {
search_index_clear('node_search', $entity->nid->value);
$search_index->clear('node_search', $entity->nid->value);
}
}
}
......
......@@ -2,10 +2,12 @@
namespace Drupal\node\Plugin\Search;
use Drupal\Core\Access\AccessibleInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\Config;
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Database\Query\SelectExtender;
use Drupal\Core\Database\StatementInterface;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
......@@ -15,14 +17,13 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessibleInterface;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Render\RendererInterface;
use Drupal\node\NodeInterface;
use Drupal\search\Plugin\ConfigurableSearchPluginBase;
use Drupal\search\Plugin\SearchIndexingInterface;
use Drupal\search\SearchIndexInterface;
use Drupal\Search\SearchQuery;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -98,6 +99,13 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
*/
protected $renderer;
/**
* The search index.
*
* @var \Drupal\search\SearchIndexInterface
*/
protected $searchIndex;
/**
* An array of additional rankings from hook_ranking().
*
......@@ -153,7 +161,8 @@ public static function create(ContainerInterface $container, array $configuratio
$container->get('renderer'),
$container->get('messenger'),
$container->get('current_user'),
$container->get('database.replica')
$container->get('database.replica'),
$container->get('search.index')
);
}
......@@ -184,8 +193,10 @@ public static function create(ContainerInterface $container, array $configuratio
* The $account object to use for checking for access to advanced search.
* @param \Drupal\Core\Database\Connection|null $database_replica
* (Optional) the replica database connection.
* @param \Drupal\search\SearchIndexInterface $search_index
* The search index.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, Config $search_settings, LanguageManagerInterface $language_manager, RendererInterface $renderer, MessengerInterface $messenger, AccountInterface $account = NULL, Connection $database_replica = NULL) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, Config $search_settings, LanguageManagerInterface $language_manager, RendererInterface $renderer, MessengerInterface $messenger, AccountInterface $account = NULL, Connection $database_replica = NULL, SearchIndexInterface $search_index = NULL) {
$this->database = $database;
$this->databaseReplica = $database_replica ?: $database;
$this->entityTypeManager = $entity_type_manager;
......@@ -198,6 +209,11 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->addCacheTags(['node_list']);
if (!$search_index) {
@trigger_error('Calling NodeSearch::__construct() without the $search_index argument is deprecated in drupal:8.8.0 and is required in drupal:9.0.0. See https://www.drupal.org/node/3075696', E_USER_DEPRECATED);
$search_index = \Drupal::service('search.index');
}
$this->searchIndex = $search_index;
}
/**
......@@ -478,8 +494,14 @@ public function updateIndex() {
}
$node_storage = $this->entityTypeManager->getStorage('node');
foreach ($node_storage->loadMultiple($nids) as $node) {
$this->indexNode($node);
$words = [];
try {
foreach ($node_storage->loadMultiple($nids) as $node) {
$this->indexNode($node, $words);
}
}
finally {
$this->searchIndex->updateWordWeights($words);
}
}
......@@ -488,8 +510,10 @@ public function updateIndex() {
*
* @param \Drupal\node\NodeInterface $node
* The node to index.
* @param array $words
* Words that need updating after the index run.
*/
protected function indexNode(NodeInterface $node) {
protected function indexNode(NodeInterface $node, array &$words) {
$languages = $node->getTranslationLanguages();
$node_render = $this->entityTypeManager->getViewBuilder('node');
......@@ -516,7 +540,7 @@ protected function indexNode(NodeInterface $node) {
}
// Update index, using search index "type" equal to the plugin ID.
search_index($this->getPluginId(), $node->id(), $language->getId(), $text);
$words += $this->searchIndex->index($this->getPluginId(), $node->id(), $language->getId(), $text);
}
}
......@@ -526,7 +550,7 @@ protected function indexNode(NodeInterface $node) {
public function indexClear() {
// All NodeSearch pages share a common search index "type" equal to
// the plugin ID.
search_index_clear($this->getPluginId());
$this->searchIndex->clear($this->getPluginId());
}
/**
......@@ -535,7 +559,7 @@ public function indexClear() {
public function markForReindex() {
// All NodeSearch pages share a common search index "type" equal to
// the plugin ID.
search_mark_for_reindex($this->getPluginId());
$this->searchIndex->markForReindex($this->getPluginId());
}
/**
......
This diff is collapsed.
......@@ -6,3 +6,7 @@ services:
search.search_page_repository:
class: Drupal\search\SearchPageRepository
arguments: ['@config.factory', '@entity_type.manager']
search.index:
class: Drupal\search\SearchIndex
arguments: ['@config.factory', '@database','@database.replica', '@cache_tags.invalidator']
<?php
namespace Drupal\search\Exception;
/**
* Exception thrown for search index errors.
*/
class SearchIndexException extends \RuntimeException {}
......@@ -30,8 +30,8 @@ interface SearchIndexingInterface {
* This method is called every cron run if the plugin has been set as
* an active search module on the Search settings page
* (admin/config/search/pages). It allows your module to add items to the
* built-in search index using search_index(), or to add them to your module's
* own indexing mechanism.
* built-in search index by calling the index() method on the search.index
* service class, or to add them to your module's own indexing mechanism.
*
* When implementing this method, your module should index content items that
* were modified or added since the last run. There is a time limit for cron,
......@@ -49,10 +49,10 @@ public function updateIndex();
*
* When a request is made to clear all items from the search index related to
* this plugin, this method will be called. If this plugin uses the default
* search index, this method can call search_index_clear($type) to remove
* indexed items from the search database.
* search index, this method can call clear($type) method on the search.index
* service class to remove indexed items from the search database.
*
* @see search_index_clear()
* @see \Drupal\search\SearchIndexInterface::clear()
*/
public function indexClear();
......@@ -61,11 +61,11 @@ public function indexClear();
*
* When a request is made to mark all items from the search index related to
* this plugin for reindexing, this method will be called. If this plugin uses
* the default search index, this method can call
* search_mark_for_reindex($type) to mark the items in the search database for
* reindexing.
* the default search index, this method can call markForReindex($type) method
* on the search.index service class to mark the items in the search database
* for reindexing.
*
* @see search_mark_for_reindex()
* @see \Drupal\search\SearchIndexInterface::markForReindex()
*/
public function markForReindex();
......
......@@ -66,8 +66,8 @@ public function isSearchExecutable();
* The type used by this search plugin in the search index, or NULL if this
* plugin does not use the search index.
*
* @see search_index()
* @see search_index_clear()
* @see \Drupal\search\SearchIndexInterface::index()
* @see \Drupal\search\SearchIndexInterface::clear()
*/
public function getType();
......
This diff is collapsed.
<?php
namespace Drupal\search;
/**
* Provides search index management functions.
*
* @ingroup search
*/
interface SearchIndexInterface {
/**
* Updates the full-text search index for a particular item.
*
* @param string $type
* The plugin ID or other machine-readable type of this item,
* which should be less than 64 bytes.
* @param int $sid
* An ID number identifying this particular item (e.g., node ID).
* @param string $langcode
* Language code for the language of the text being indexed.
* @param string $text
* The content of this item. Must be a piece of HTML or plain text.
* @param bool $update_weights
* (optional) TRUE if word weights should be updated. FALSE otherwise.
*
* @return string[]
* The words to be updated.
*
* @throws \Drupal\search\Exception\SearchIndexException
* If there is an error indexing the text.
*/
public function index($type, $sid, $langcode, $text, $update_weights = TRUE);
/**
* Clears either a part of, or the entire search index.
*
* This function is meant for use by search page plugins, or for building a
* user interface that lets users clear all or parts of the search index.
*
* @param string|null $type
* (optional) The plugin ID or other machine-readable type for the items to
* remove from the search index. If omitted, $sid and $langcode are ignored
* and the entire search index is cleared.
* @param int|array|null $sid
* (optional) The ID or array of IDs of the items to remove from the search
* index. If omitted, all items matching $type are cleared, and $langcode
* is ignored.
* @param string|null $langcode
* (optional) Language code of the item to remove from the search index. If
* omitted, all items matching $sid and $type are cleared.
*
* @throws \Drupal\search\Exception\SearchIndexException
* If there is an error clearing the index.
*/
public function clear($type = NULL, $sid = NULL, $langcode = NULL);
/**
* Changes the timestamp on indexed items to 'now' to force reindexing.
*
* This function is meant for use by search page plugins, or for building a
* user interface that lets users mark all or parts of the search index for
* reindexing.
*
* @param string $type
* (optional) The plugin ID or other machine-readable type of this item. If
* omitted, the entire search index is marked for reindexing, and $sid and
* $langcode are ignored.
* @param int $sid
* (optional) An ID number identifying this particular item (e.g., node ID).
* If omitted, everything matching $type is marked, and $langcode is
* ignored.
* @param string $langcode
* (optional) The language code to mark. If omitted, everything matching
* $type and $sid is marked.
*
* @throws \Drupal\search\Exception\SearchIndexException
* If there is an error marking the index for re-indexing.
*/
public function markForReindex($type = NULL, $sid = NULL, $langcode = NULL);
/**
* Updates the {search_total} database table.
*
* @param array $words
* An array whose keys are words from self::index() whose total weights
* need to be updated.
*
* @throws \Drupal\search\Exception\SearchIndexException
* If there is an error updating the totals.
*/
public function updateWordWeights(array $words);
}
......@@ -43,6 +43,13 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
*/
protected $searchManager;
/**
* The search index.
*
* @var \Drupal\search\SearchIndexInterface
*/
protected $searchIndex;
/**
* The messenger.
*
......@@ -63,12 +70,19 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
* The factory for configuration objects.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
* @param \Drupal\search\SearchIndexInterface $search_index
* The search index.
*/
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, SearchPluginManager $search_manager, ConfigFactoryInterface $config_factory, MessengerInterface $messenger) {
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, SearchPluginManager $search_manager, ConfigFactoryInterface $config_factory, MessengerInterface $messenger, SearchIndexInterface $search_index = NULL) {
parent::__construct($entity_type, $storage);
$this->configFactory = $config_factory;
$this->searchManager = $search_manager;
$this->messenger = $messenger;
if (!$search_index) {
@trigger_error('Calling SearchPageListBuilder::__construct() without the $search_index argument is deprecated in drupal:8.8.0 and is required in drupal:9.0.0. See https://www.drupal.org/node/3075696', E_USER_DEPRECATED);
$search_index = \Drupal::service('search.index');
}
$this->searchIndex = $search_index;
}
/**
......@@ -80,7 +94,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('plugin.manager.search'),
$container->get('config.factory'),
$container->get('messenger')
$container->get('messenger'),
$container->get('search.index')
);
}
......@@ -344,9 +359,9 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$search_settings->set('index.minimum_word_size', $form_state->getValue('minimum_word_size'));
$search_settings->set('index.overlap_cjk', $form_state->getValue('overlap_cjk'));
// Specifically mark items in the default index for reindexing, since
// these settings are used in the search_index() function.
// these settings are used in the SearchIndex::index() function.
$this->messenger->addStatus($this->t('The default search index will be rebuilt.'));
search_mark_for_reindex();
$this->searchIndex->markForReindex();
}
$search_settings
......
......@@ -38,11 +38,6 @@ protected function setUp() {
// First update the index. This does the initial processing.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
// Then, run the shutdown function. Testing is a unique case where indexing
// and searching has to happen in the same request, so running the shutdown
// function manually is needed to finish the indexing process.
search_update_totals();
}
/**
......
......@@ -70,11 +70,6 @@ protected function setUp() {
// First update the index. This does the initial processing.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
// Then, run the shutdown function. Testing is a unique case where indexing
// and searching has to happen in the same request, so running the shutdown
// function manually is needed to finish the indexing process.
search_update_totals();
}
/**
......
......@@ -294,7 +294,7 @@ public function setRolePermissions($rid, $access_comments = FALSE, $search_conte
*/
public function assertCommentAccess($assume_access, $message) {
// Invoke search index update.
search_mark_for_reindex('node_search', $this->node->id());
\Drupal::service('search.index')->markForReindex('node_search', $this->node->id());
$this->cronRun();
// Search for the comment subject.
......
......@@ -53,7 +53,6 @@ protected function setUp() {
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
search_update_totals();
// Enable the search block.
$this->drupalPlaceBlock('search_form_block');
......
......@@ -56,7 +56,6 @@ protected function setUp() {
// Update the index.
$plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
$plugin->updateIndex();
search_update_totals();
}
/**
......
......@@ -42,7 +42,6 @@ protected function setUp() {
$this->node = $this->drupalCreateNode();
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
search_update_totals();
// Set up a dummy initial count of times the form has been submitted.
$this->submitCount = \Drupal::state()->get('search_embedded_form.submit_count');
......
......@@ -46,7 +46,6 @@ public function testExactQuery() {
// Update the search index.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
search_update_totals();
// Refresh variables after the treatment.
$this->refreshVariables();
......
......@@ -85,7 +85,6 @@ protected function setUp() {
// Update the index and then run the shutdown method.
$plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
$plugin->updateIndex();
search_update_totals();
}
public function testLanguages() {
......
......@@ -5,6 +5,7 @@
use Drupal\Core\Database\Database;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\search\SearchIndexInterface;
use Drupal\Tests\BrowserTestBase;
/**
......@@ -128,7 +129,8 @@ public function testMultilingualSearch() {
// Run the shutdown function. Testing is a unique case where indexing
// and searching has to happen in the same request, so running the shutdown
// function manually is needed to finish the indexing process.
search_update_totals();
$search_index = \Drupal::service('search.index');
assert($search_index instanceof SearchIndexInterface);
$this->assertIndexCounts(6, 8, 'after updating partially');
$this->assertDatabaseCounts(2, 0, 'after updating partially');
......@@ -140,7 +142,6 @@ public function testMultilingualSearch() {
$this->plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
$this->plugin->updateIndex();
search_update_totals();
$this->assertIndexCounts(0, 8, 'after updating fully');
$this->assertDatabaseCounts(8, 0, 'after updating fully');
......@@ -150,7 +151,6 @@ public function testMultilingualSearch() {
$this->assertIndexCounts(8, 8, 'after reindex');
$this->assertDatabaseCounts(8, 0, 'after reindex');
$this->plugin->updateIndex();
search_update_totals();
// Test search results.
......@@ -190,13 +190,12 @@ public function testMultilingualSearch() {
// Mark one of the nodes for reindexing, using the API function, and
// verify indexing status.
search_mark_for_reindex('node_search', $this->searchableNodes[0]->id());
$search_index->markForReindex('node_search', $this->searchableNodes[0]->id());
$this->assertIndexCounts(1, 8, 'after marking one node to reindex via API function');
// Update the index and verify the totals again.
$this->plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
$this->plugin->updateIndex();
search_update_totals();
$this->assertIndexCounts(0, 8, 'after indexing again');
// Mark one node for reindexing by saving it, and verify indexing status.
......@@ -227,32 +226,32 @@ public function testMultilingualSearch() {
// Add a bogus entry to the search index table using a different search
// type. This will not appear in the index status, because it is not
// managed by a plugin.
search_index('foo', $this->searchableNodes[0]->id(), 'en', 'some text');
$search_index->index('foo', $this->searchableNodes[0]->id(), 'en', 'some text');
$this->assertIndexCounts(1, 8, 'after adding a different index item');
// Mark just this "foo" index for reindexing.
search_mark_for_reindex('foo');
$search_index->markForReindex('foo');
$this->assertIndexCounts(1, 8, 'after reindexing the other search type');
// Mark everything for reindexing.
search_mark_for_reindex();
$search_index->markForReindex();
$this->assertIndexCounts(8, 8, 'after reindexing everything');
// Clear one item from the index, but with wrong language.
$this->assertDatabaseCounts(8, 1, 'before clear');
search_index_clear('node_search', $this->searchableNodes[0]->id(), 'hu');
$search_index->clear('node_search', $this->searchableNodes[0]->id(), 'hu');
$this->assertDatabaseCounts(8, 1, 'after clear with wrong language');
// Clear using correct language.
search_index_clear('node_search', $this->searchableNodes[0]->id(), 'en');
$search_index->clear('node_search', $this->searchableNodes[0]->id(), 'en');
$this->assertDatabaseCounts(7, 1, 'after clear with right language');
// Don't specify language.
search_index_clear('node_search', $this->searchableNodes[1]->id());
$search_index->clear('node_search', $this->searchableNodes[1]->id());
$this->assertDatabaseCounts(6, 1, 'unspecified language clear');
// Clear everything in 'foo'.
search_index_clear('foo');
$search_index->clear('foo');
$this->assertDatabaseCounts(6, 0, 'other index clear');
// Clear everything.
search_index_clear();
$search_index->clear();
$this->assertDatabaseCounts(0, 0, 'complete clear');
}
......
......@@ -45,7 +45,6 @@ public function testPhraseSearchPunctuation() {
// Update the search index.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
search_update_totals();
// Refresh variables after the treatment.
$this->refreshVariables();
......
......@@ -43,7 +43,6 @@ public function testPhraseSearchPunctuation() {
// Update the search index.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
search_update_totals();
// Refresh variables after the treatment.
$this->refreshVariables();
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Core\Database\Database;
use Drupal\search\SearchIndexInterface;
use Drupal\Tests\BrowserTestBase;
/**
......@@ -48,7 +49,8 @@ public function testSearchIndexUpdateOnNodeChange() {