Skip to content
Snippets Groups Projects
Commit 3408494d authored by catch's avatar catch
Browse files

Issue #3097443 by andypost, longwave: Remove all @deprecated code in the Search module

parent 754c4577
No related branches found
No related tags found
No related merge requests found
......@@ -121,53 +121,6 @@ function search_preprocess_block(&$variables) {
}
}
/**
* 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.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* \Drupal\search\SearchIndex::clear() instead.
*
* @see https://www.drupal.org/node/3075696
*/
function search_index_clear($type = NULL, $sid = NULL, $langcode = NULL) {
@trigger_error("search_index_clear() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\search\SearchIndex::clear() instead. See https://www.drupal.org/node/3075696", E_USER_DEPRECATED);
\Drupal::service('search.index')->clear($type, $sid, $langcode);
}
/**
* Marks a word as "dirty" (changed), or retrieves the list of dirty words.
*
* This is used during indexing (cron). Words that are dirty have outdated
* total counts in the search_total table, and need to be recounted.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use custom
* implementation of \Drupal\search\SearchIndexInterface instead.
*
* @see https://www.drupal.org/node/3075696
*/
function search_dirty($word = NULL) {
@trigger_error("search_dirty() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use custom implementation of \Drupal\search\SearchIndexInterface instead. See https://www.drupal.org/node/3075696", E_USER_DEPRECATED);
// Keep return result type for backward compatibility.
if ($word === NULL) {
return [];
}
}
/**
* Implements hook_cron().
*
......@@ -182,21 +135,6 @@ function search_cron() {
}
}
/**
* Updates the {search_total} database table.
*
* This function is called on shutdown to ensure that {search_total} is always
* up to date (even if cron times out or otherwise fails).
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use custom
* implementation of \Drupal\search\SearchIndexInterface instead.
*
* @see https://www.drupal.org/node/3075696
*/
function search_update_totals() {
@trigger_error("search_update_totals() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use custom implementation of \Drupal\search\SearchIndexInterface instead. See https://www.drupal.org/node/3075696", E_USER_DEPRECATED);
}
/**
* Simplifies and preprocesses text for searching.
*
......@@ -380,59 +318,6 @@ function search_invoke_preprocess(&$text, $langcode = NULL) {
}
}
/**
* 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.
*
* @ingroup search
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* \Drupal\search\SearchIndex::index() instead.
*
* @see https://www.drupal.org/node/3075696
*/
function search_index($type, $sid, $langcode, $text) {
@trigger_error("search_index() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\search\SearchIndex::index() instead. See https://www.drupal.org/node/3075696", E_USER_DEPRECATED);
\Drupal::service('search.index')->index($type, $sid, $langcode, $text);
}
/**
* 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 clear. If omitted, everything matching
* $type and $sid is marked.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* \Drupal\search\SearchIndex::markForReindex() instead.
*
* @see https://www.drupal.org/node/3075696
*/
function search_mark_for_reindex($type = NULL, $sid = NULL, $langcode = NULL) {
@trigger_error("search_mark_for_reindex() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\search\SearchIndex::markForReindex() instead. See https://www.drupal.org/node/3075696", E_USER_DEPRECATED);
\Drupal::service('search.index')->markForReindex($type, $sid, $langcode);
}
/**
* @defgroup search Search interface
* @{
......
<?php
namespace Drupal\search\Plugin\migrate\process\d6;
use Drupal\search\Plugin\migrate\process\SearchConfigurationRankings as BaseSearchConfigurationRankings;
/**
* Generate configuration rankings.
*
* @deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use
* \Drupal\search\Plugin\migrate\process\SearchConfigurationRankings instead.
*
* @MigrateProcessPlugin(
* id = "d6_search_configuration_rankings"
* )
*
* @see https://www.drupal.org/node/3009364
*/
class SearchConfigurationRankings extends BaseSearchConfigurationRankings {
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
@trigger_error('SearchConfigurationRankings is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Use Drupal\search\Plugin\migrate\process\SearchConfigurationRankings instead. See https://www.drupal.org/node/3009364.', E_USER_DEPRECATED);
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
}
......@@ -73,15 +73,11 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
* @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, SearchIndexInterface $search_index = NULL) {
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, SearchPluginManager $search_manager, ConfigFactoryInterface $config_factory, MessengerInterface $messenger, SearchIndexInterface $search_index) {
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;
}
......
<?php
namespace Drupal\search\Tests;
@trigger_error(__NAMESPACE__ . '\SearchTestBase is deprecated for removal before Drupal 9.0.0. Use \Drupal\Tests\search\Functional\SearchTestBase instead. See https://www.drupal.org/node/2999939', E_USER_DEPRECATED);
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Render\FormattableMarkup;
/**
* Defines the common search test code.
*
* @deprecated in drupal:8.?.? and is removed from drupal:9.0.0.
* Use \Drupal\Tests\search\Functional\SearchTestBase instead.
*
* @see https://www.drupal.org/node/2999939
*/
abstract class SearchTestBase extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['node', 'search', 'dblog'];
protected function setUp() {
parent::setUp();
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
/**
* Simulates submission of a form using GET instead of POST.
*
* Forms that use the GET method cannot be submitted with
* WebTestBase::drupalPostForm(), which explicitly uses POST to submit the
* form. So this method finds the form, verifies that it has input fields and
* a submit button matching the inputs to this method, and then calls
* WebTestBase::drupalGet() to simulate the form submission to the 'action'
* URL of the form (if set, or the current URL if not).
*
* See WebTestBase::drupalPostForm() for more detailed documentation of the
* function parameters.
*
* @param string $path
* Location of the form to be submitted: either a Drupal path, absolute
* path, or NULL to use the current page.
* @param array $edit
* Form field data to submit. Unlike drupalPostForm(), this does not support
* file uploads.
* @param string $submit
* Value of the submit button to submit clicking. Unlike drupalPostForm(),
* this does not support AJAX.
* @param string $form_html_id
* (optional) HTML ID of the form, to disambiguate.
*/
protected function submitGetForm($path, $edit, $submit, $form_html_id = NULL) {
if (isset($path)) {
$this->drupalGet($path);
}
if ($this->parse()) {
// Iterate over forms to find one that matches $edit and $submit.
$edit_save = $edit;
$xpath = '//form';
if (!empty($form_html_id)) {
$xpath .= "[@id='" . $form_html_id . "']";
}
$forms = $this->xpath($xpath);
foreach ($forms as $form) {
// Try to set the fields of this form as specified in $edit.
$edit = $edit_save;
$post = [];
$upload = [];
$submit_matches = $this->handleForm($post, $edit, $upload, $submit, $form);
if (!$edit && $submit_matches) {
// Everything matched, so "submit" the form.
$action = isset($form['action']) ? $this->getAbsoluteUrl((string) $form['action']) : NULL;
$this->drupalGet($action, ['query' => $post]);
return;
}
}
// We have not found a form which contained all fields of $edit and
// the submit button.
foreach ($edit as $name => $value) {
$this->fail(new FormattableMarkup('Failed to set field @name to @value', ['@name' => $name, '@value' => $value]));
}
$this->assertTrue($submit_matches, new FormattableMarkup('Found the @submit button', ['@submit' => $submit]));
$this->fail(new FormattableMarkup('Found the requested form fields at @path', ['@path' => $path]));
}
}
}
<?php
namespace Drupal\Tests\search\Functional;
@trigger_error(__NAMESPACE__ . '\SearchTestBase is deprecated in Drupal 8.6.x and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\BrowserTestBase. See https://www.drupal.org/node/2979950.', E_USER_DEPRECATED);
use Drupal\Tests\BrowserTestBase;
/**
* Defines the common search test code.
*
* @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0. Use
* \Drupal\Tests\BrowserTestBase instead.
*
* @see https://www.drupal.org/node/2979950
*/
abstract class SearchTestBase extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['node', 'search', 'dblog'];
protected function setUp() {
parent::setUp();
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
/**
* Submission of a form via press submit button.
*
* @param string $path
* Location of the form to be submitted: either a Drupal path, absolute
* path, or NULL to use the current page.
* @param array $edit
* Form field data to submit. Unlike drupalPostForm(), this does not support
* file uploads.
* @param string $submit
* Value of the submit button to submit clicking. Unlike drupalPostForm(),
* this does not support AJAX.
* @param string $form_html_id
* (optional) HTML ID of the form, to disambiguate.
*
* @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0. Use
* \Drupal\Tests\BrowserTestBase::drupalPostForm() instead.
*
* @see https://www.drupal.org/node/2979950
*/
protected function submitGetForm($path, $edit, $submit, $form_html_id = NULL) {
@trigger_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated in Drupal 8.6.x, for removal before the Drupal 9.0.0 release. Use \Drupal\Tests\BrowserTestBase::drupalPostForm() instead. See https://www.drupal.org/node/2979950.', E_USER_DEPRECATED);
$this->drupalPostForm($path, $edit, $submit, [], $form_html_id);
}
}
<?php
namespace Drupal\Tests\search\Kernel;
use Drupal\Core\Language\LanguageInterface;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests deprecated search methods.
*
* @group legacy
* @group search
*/
class SearchDeprecationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['search'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installSchema('search', [
'search_index',
'search_dataset',
'search_total',
]);
$this->installConfig(['search']);
}
/**
* @expectedDeprecation search_index() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\search\SearchIndex::index() instead. See https://www.drupal.org/node/3075696
*/
public function testIndex() {
$this->assertNull(search_index('_test_', 1, LanguageInterface::LANGCODE_NOT_SPECIFIED, "foo"));
}
/**
* @expectedDeprecation search_index_clear() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\search\SearchIndex::clear() instead. See https://www.drupal.org/node/3075696
*/
public function testClear() {
$this->assertNull(search_index_clear());
}
/**
* @expectedDeprecation search_dirty() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use custom implementation of \Drupal\search\SearchIndexInterface instead. See https://www.drupal.org/node/3075696
*/
public function testDirty() {
$this->assertNull(search_dirty("foo"));
$this->assertEqual([], search_dirty());
}
/**
* @expectedDeprecation search_update_totals() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use custom implementation of \Drupal\search\SearchIndexInterface instead. See https://www.drupal.org/node/3075696
*/
public function testUpdateTotals() {
$this->assertNull(search_update_totals());
}
/**
* @expectedDeprecation search_mark_for_reindex() is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\search\SearchIndex::markForReindex() instead. See https://www.drupal.org/node/3075696
*/
public function testMarkForReindex() {
$this->assertNull(search_mark_for_reindex('_test_', 1, LanguageInterface::LANGCODE_NOT_SPECIFIED));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment