diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php index 012a669..f157284 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -330,7 +330,7 @@ protected function indexNode(EntityInterface $node) { foreach ($languages as $language) { // Render the node. - $build = $this->moduleHandler->invoke('node', 'view', array($node, 'search_index', $language->id)); + $build = node_view($node, 'search_index', $language->id); unset($build['#theme']); $node->rendered = drupal_render($build); @@ -344,7 +344,7 @@ protected function indexNode(EntityInterface $node) { } // Update index. - $this->moduleHandler->invoke('search', 'index', array($node->id(), $this->getPluginId(), $text, $language->id)); + search_index($node->id(), $this->getPluginId(), $text, $language->id); } } diff --git a/core/modules/search/lib/Drupal/search/SearchExpression.php b/core/modules/search/lib/Drupal/search/SearchExpression.php deleted file mode 100644 index 5662389..0000000 --- a/core/modules/search/lib/Drupal/search/SearchExpression.php +++ /dev/null @@ -1,93 +0,0 @@ -expression = $expression; - } - - /** - * Gets the expression. - * - * @return string - */ - public function getExpression() { - return $this->expression; - } - - /** - * Extracts a type-specific search option from a search expression. - * - * Search options are added using SearchExpression::insert() and retrieved - * using SearchExpression::extract(). They take the form option:value, and - * are added to the ordinary keywords in the search expression. - * - * @param string $option - * The name of the option to retrieve from the search expression. - * - * @return string - * The value previously stored in the search expression for option $option, - * if any. Trailing spaces in values will not be included. - */ - public function extract($option) { - if (preg_match('/(^| )' . $option . ':([^ ]*)( |$)/i', $this->expression, $matches)) { - return $matches[2]; - } - } - - /** - * Adds a type-specific search option to a search expression. - * - * Search options are added using SearchExpression::insert() and retrieved - * using SearchExpression::extract(). They take the form option:value, and - * are added to the ordinary keywords in the search expression. - * - * @param string $option - * The name of the option to add to the search expression. - * @param string $value - * The value to add for the option. If present, it will replace any previous - * value added for the option. Cannot contain any spaces or | characters, as - * these are used as delimiters. If you want to add a blank value $option: to - * the search expression, pass in an empty string or a string that is - * composed of only spaces. To clear a previously-stored option without - * adding a replacement, pass in NULL for $value or omit. - * - * @return static|\Drupal\search\SearchExpression - * The search expression, with any previous value for this option removed, and - * a new $option:$value pair added if $value was provided. - */ - public function insert($option, $value = NULL) { - // Remove any previous values stored with $option. - $this->expression = trim(preg_replace('/(^| )' . $option . ':[^ ]*/i', '', $this->expression)); - - // Set new value, if provided. - if (isset($value)) { - $this->expression .= ' ' . $option . ':' . trim($value); - } - return $this; - } - -} diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 2813702..5646de2 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -660,55 +660,6 @@ function search_mark_for_reindex($type, $sid) { } /** - * Extracts a search-type-specific search option from a search expression. - * - * Search options are added using search_expression_insert(), and retrieved - * using search_expression_extract(). They take the form option:value, and - * are added to the ordinary keywords in the search expression. - * - * @param $expression - * The search expression to extract from. - * @param $option - * The name of the option to retrieve from the search expression. - * - * @return - * The value previously stored in the search expression for option $option, - * if any. Trailing spaces in values will not be included. - */ -function search_expression_extract($expression, $option) { - $expression = new SearchExpression($expression); - return $expression->extract($option); -} - -/** - * Adds a search-type-specific search option to a search expression. - * - * Search options are added using search_expression_insert(), and retrieved - * using search_expression_extract(). They take the form option:value, and - * are added to the ordinary keywords in the search expression. - * - * @param $expression - * The search expression to add to. - * @param $option - * The name of the option to add to the search expression. - * @param $value - * The value to add for the option. If present, it will replace any previous - * value added for the option. Cannot contain any spaces or | characters, as - * these are used as delimiters. If you want to add a blank value $option: to - * the search expression, pass in an empty string or a string that is - * composed of only spaces. To clear a previously-stored option without - * adding a replacement, pass in NULL for $value or omit. - * - * @return - * The search expression, with any previous value for this option removed, and - * a new $option:$value pair added if $value was provided. - */ -function search_expression_insert($expression, $option, $value = NULL) { - $expression = new SearchExpression($expression); - return $expression->insert($option, $value)->getExpression(); -} - -/** * @defgroup search Search interface * @{ * The Drupal search interface manages a global search mechanism. diff --git a/core/modules/search/tests/Drupal/search/Tests/SearchExpressionTest.php b/core/modules/search/tests/Drupal/search/Tests/SearchExpressionTest.php deleted file mode 100644 index 27f59ed..0000000 --- a/core/modules/search/tests/Drupal/search/Tests/SearchExpressionTest.php +++ /dev/null @@ -1,89 +0,0 @@ - 'Search expression insert/extract', - 'description' => 'Tests the search expression class.', - 'group' => 'Search', - ); - } - - - /** - * Provides data for the search expression tests. - * - * @return array - * An array of values passed to the test methods. - */ - public function dataProvider() { - $cases = array( - // Normal case. - array('foo', 'bar', 'foo:bar', 'bar'), - // Empty value: shouldn't insert. - array('foo', NULL, '', NULL), - // Space as value: should insert but retrieve empty string. - array('foo', ' ', 'foo:', ''), - // Empty string as value: should insert but retrieve empty string. - array('foo', '', 'foo:', ''), - // String zero as value: should insert. - array('foo', '0', 'foo:0', '0'), - // Numeric zero as value: should insert. - array('foo', 0, 'foo:0', '0'), - ); - return $cases; - } - - /** - * Tests the search expression methods. - * - * @dataProvider dataProvider - */ - public function testInsertExtract($case_0, $case_1, $case_2, $case_3) { - $base_expression = 'mykeyword'; - // Build an array of option, value, what should be in the expression, what - // should be retrieved from expression. - - $after_insert = new SearchExpression($base_expression); - $after_insert->insert($case_0, $case_1); - - if (empty($case_2)) { - $this->assertEquals($base_expression, $after_insert->getExpression(), 'Empty insert does change expression.'); - } - else { - $this->assertEquals($base_expression . ' ' . $case_2, $after_insert->getExpression(), 'Insert added incorrect expression.'); - } - - $retrieved = $after_insert->extract($case_0); - - if (!isset($case_3)) { - $this->assertFalse(isset($retrieved), 'Empty retrieval results in unset value.'); - } - else { - $this->assertEquals($case_3, $retrieved, 'Value is retrieved.'); - } - - $after_clear = $after_insert->insert($case_0); - $this->assertEquals($base_expression, $after_clear->getExpression(), 'After clearing, base expression is not restored.'); - - $cleared = $after_clear->extract($case_0); - $this->assertFalse(isset($cleared), 'After clearing, value could be retrieved.'); - } - -}