--- ../modules/2003482-37.patch 2013-06-07 00:28:50.000000000 -0400 +++ ../modules/2003482-41.patch 2013-06-07 19:40:43.000000000 -0400 @@ -1,9 +1,9 @@ diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php new file mode 100644 -index 0000000..e1284e5 +index 0000000..3ccb3bd --- /dev/null +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php -@@ -0,0 +1,265 @@ +@@ -0,0 +1,266 @@ +get('database'); -+ $entity_manager = $container->get('plugin.manager.entity'); -+ $module_handler = $container->get('module_handler'); -+ $config_factory = $container->get('config.factory'); -+ $state = $container->get('keyvalue')->get('state'); -+ return new static($database, $entity_manager, $module_handler, $config_factory, $state, $configuration, $plugin_id, $plugin_definition); ++ return new static( ++ $container->get('database'), ++ $container->get('plugin.manager.entity'), ++ $container->get('module_handler'), ++ $container->get('config.factory')->get('search.settings'), ++ $container->get('keyvalue')->get('state'), ++ $configuration, ++ $plugin_id, ++ $plugin_definition ++ ); + } + -+ public function __construct(Connection $database, EntityManager $entity_manager, ModuleHandlerInterface $module_handler, ConfigFactory $config_factory, KeyValueStoreInterface $state, array $configuration, $plugin_id, array $plugin_definition) { -+ $this->configuration = $configuration; -+ $this->pluginId = $plugin_id; -+ $this->pluginDefinition = $plugin_definition; ++ public function __construct(Connection $database, EntityManager $entity_manager, ModuleHandlerInterface $module_handler, Config $search_settings, KeyValueStoreInterface $state, array $configuration, $plugin_id, array $plugin_definition) { + $this->database = $database; -+ $this->entity_manager = $entity_manager; -+ $this->module_handler = $module_handler; -+ $this->config_factory = $config_factory; ++ $this->entityManager = $entity_manager; ++ $this->moduleHandler = $module_handler; ++ $this->searchSettings = $search_settings; + $this->state = $state; ++ parent::__construct($configuration, $plugin_id, $plugin_definition); + } + + /** @@ -107,9 +109,8 @@ + ->limit(10) + ->execute(); + -+ $node_storage = $this->entity_manager->getStorageController('node'); -+ $node_render = $this->entity_manager->getRenderController('node'); -+ $module_handler = $this->module_handler; ++ $node_storage = $this->entityManager->getStorageController('node'); ++ $node_render = $this->entityManager->getRenderController('node'); + + foreach ($find as $item) { + // Render the node. @@ -120,15 +121,15 @@ + $node->rendered = drupal_render($build); + + // Fetch comments for snippet. -+ $node->rendered .= ' ' . $module_handler->invoke('comment', 'node_update_index', array($node, $item->langcode)); ++ $node->rendered .= ' ' . $this->moduleHandler->invoke('comment', 'node_update_index', array($node, $item->langcode)); + -+ $extra = $module_handler->invokeAll('node_search_result', array($node, $item->langcode)); ++ $extra = $this->moduleHandler->invokeAll('node_search_result', array($node, $item->langcode)); + -+ $language = $module_handler->invoke('language', 'load', array($item->langcode)); ++ $language = $this->moduleHandler->invoke('language', 'load', array($item->langcode)); + $uri = $node->uri(); + $results[] = array( + 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))), -+ 'type' => check_plain($module_handler->invoke('node', 'get_type_label', array($node))), ++ 'type' => check_plain($this->moduleHandler->invoke('node', 'get_type_label', array($node))), + 'title' => $node->label($item->langcode), + 'user' => theme('username', array('account' => $node)), + 'date' => $node->changed, @@ -149,7 +150,7 @@ + * A query object that has been extended with the Search DB Extender. + */ + protected function addNodeRankings(SelectExtender $query) { -+ if ($ranking = $this->module_handler->invokeAll('ranking')) { ++ if ($ranking = $this->moduleHandler->invokeAll('ranking')) { + $tables = &$query->getTables(); + foreach ($ranking as $rank => $values) { + // @todo - move rank out of drupal variables. @@ -168,7 +169,7 @@ + * {@inheritdoc} + */ + public function updateIndex() { -+ $limit = (int) $this->config_factory->get('search.settings')->get('index.cron_limit'); ++ $limit = (int) $this->searchSettings->get('index.cron_limit'); + + $result = $this->database->queryRange("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array('target' => 'slave')); + $nids = $result->fetchCol(); @@ -179,7 +180,7 @@ + // The indexing throttle should be aware of the number of language variants + // of a node. + $counter = 0; -+ $node_storage = $this->entity_manager->getStorageController('node'); ++ $node_storage = $this->entityManager->getStorageController('node'); + foreach ($node_storage->load($nids) as $node) { + // Determine when the maximum number of indexable items is reached. + $counter += count($node->getTranslationLanguages()); @@ -206,7 +207,7 @@ + + foreach ($languages as $language) { + // Render the node. -+ $build = $this->module_handler->invoke('node', 'view', array($node, 'search_index', $language->langcode)); ++ $build = $this->moduleHandler->invoke('node', 'view', array($node, 'search_index', $language->langcode)); + + unset($build['#theme']); + $node->rendered = drupal_render($build); @@ -214,13 +215,13 @@ + $text = '

' . check_plain($node->label($language->langcode)) . '

' . $node->rendered; + + // Fetch extra data normally not visible. -+ $extra = $this->module_handler->invokeAll('node_update_index', array($node, $language->langcode)); ++ $extra = $this->moduleHandler->invokeAll('node_update_index', array($node, $language->langcode)); + foreach ($extra as $t) { + $text .= $t; + } + + // Update index. -+ $this->module_handler->invoke('search', 'index', array($node->nid, 'node', $text, $language->langcode)); ++ $this->moduleHandler->invoke('search', 'index', array($node->nid, 'node', $text, $language->langcode)); + } + } + @@ -259,7 +260,7 @@ + + // Note: reversed to reflect that higher number = higher ranking. + $options = drupal_map_assoc(range(0, 10)); -+ foreach ($this->module_handler->invokeAll('ranking') as $var => $values) { ++ foreach ($this->moduleHandler->invokeAll('ranking') as $var => $values) { + $form['content_ranking']['factors']['node_rank_' . $var] = array( + '#title' => $values['title'], + '#type' => 'select', @@ -570,10 +571,10 @@ +} diff --git a/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php b/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php new file mode 100644 -index 0000000..1047e86 +index 0000000..6a6fb2a --- /dev/null +++ b/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php -@@ -0,0 +1,144 @@ +@@ -0,0 +1,140 @@ +keywords = (string) $keywords; + $this->searchParams = $params; + $this->searchAttributes = $attributes; ++ return $this; + } + + /** @@ -893,7 +891,7 @@ + } +} diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchAdvancedSearchFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchAdvancedSearchFormTest.php -index 5b0efeb..a710ee6 100644 +index 5b0efeb..74fb54f 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchAdvancedSearchFormTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchAdvancedSearchFormTest.php @@ -29,7 +29,7 @@ function setUp() { @@ -901,12 +899,12 @@ // First update the index. This does the initial processing. - node_update_index(); -+ \Drupal::service('plugin.manager.search')->createInstance('node_search')->updateIndex(); ++ $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 diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php -index 2548a4c..49a7cea 100644 +index 2548a4c..cd4f9ae 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php @@ -66,7 +66,7 @@ function setUp() { @@ -914,12 +912,12 @@ // First update the index. This does the initial processing. - node_update_index(); -+ \Drupal::service('plugin.manager.search')->createInstance('node_search')->updateIndex(); ++ $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 diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php -index 8d91a82..639a1a8 100644 +index 8d91a82..961d163 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php @@ -49,7 +49,7 @@ function setUp() { @@ -927,12 +925,12 @@ $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save and keep published')); - node_update_index(); -+ \Drupal::service('plugin.manager.search')->createInstance('node_search')->updateIndex(); ++ $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); search_update_totals(); // Enable the search block. diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchEmbedFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchEmbedFormTest.php -index ff822c6..d868556 100644 +index ff822c6..649e410 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchEmbedFormTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchEmbedFormTest.php @@ -46,7 +46,7 @@ function setUp() { @@ -940,12 +938,12 @@ $this->node = $this->drupalCreateNode(); - node_update_index(); -+ \Drupal::service('plugin.manager.search')->createInstance('node_search')->updateIndex(); ++ $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. diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php -index e9526d8..d4a0875 100644 +index e9526d8..4bc8cac 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php @@ -95,7 +95,7 @@ function testIndexingThrottle() { @@ -953,16 +951,17 @@ config('search.settings')->set('index.cron_limit', 4)->save(); // Update the index. This does the initial processing. - node_update_index(); -+ \Drupal::service('plugin.manager.search')->createInstance('node_search')->updateIndex(); ++ $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); // 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. -@@ -114,14 +114,19 @@ function testIndexingThrottle() { +@@ -114,14 +114,17 @@ function testIndexingThrottle() { function testSearchingMultilingualFieldValues() { // Update the index and then run the shutdown method. // See testIndexingThrottle() for further explanation. - node_update_index(); -+ \Drupal::service('plugin.manager.search')->createInstance('node_search')->updateIndex(); ++ $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); ++ $plugin->updateIndex(); search_update_totals(); foreach ($this->searchable_nodes as $node) { // Each searchable node that we created contains values in the body field @@ -970,17 +969,14 @@ // body array and execute a search using that as a search keyword. $body_language_variant = end($node->body); - $search_result = node_search_execute($body_language_variant[0]['value']); -+ $config = array( -+ 'keywords' => $body_language_variant[0]['value'], -+ ); -+ $plugin = \Drupal::service('plugin.manager.search')->createInstance('node_search', $config); ++ $plugin->setSearch($body_language_variant[0]['value'], array(), array()); + // Do the search and assert the results. + $search_result = $plugin->execute(); // See whether we get the same node as a result. $sts = $this->assertTrue(!empty($search_result[0]['node']->nid) && $search_result[0]['node']->nid == $node->nid, diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php -index a8c2e61..2cbf725 100644 +index a8c2e61..8792596 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php @@ -46,7 +46,7 @@ function testPreprocessLangcode() { @@ -988,7 +984,7 @@ // First update the index. This does the initial processing. - node_update_index(); -+ \Drupal::service('plugin.manager.search')->createInstance('node_search')->updateIndex(); ++ $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 @@ -997,12 +993,12 @@ // First update the index. This does the initial processing. - node_update_index(); -+ \Drupal::service('plugin.manager.search')->createInstance('node_search')->updateIndex(); ++ $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 diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php -index e85dcd6..8501096 100644 +index e85dcd6..17fa4ae 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php @@ -90,16 +90,16 @@ function testRankings() { @@ -1010,7 +1006,7 @@ $client->post($stats_path, array(), array('nid' => $nid))->send(); } - -+ $plugin = \Drupal::service('plugin.manager.search')->createInstance('node_search'); ++ $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); + $plugin->setSearch('rocks', array(), array()); // Test each of the possible rankings. foreach ($node_ranks as $node_rank) { @@ -1030,7 +1026,7 @@ variable_set('node_rank_' . $node_rank, 0); } - $set = node_search_execute('rocks'); -+ $plugin = \Drupal::service('plugin.manager.search')->createInstance('node_search'); ++ $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); + $plugin->setSearch('rocks', array(), array()); + // Do the search and assert the results. + $set = $plugin->execute(); @@ -1043,7 +1039,7 @@ $this->refreshVariables(); - - $set = node_search_execute('rocks'); -+ $plugin = \Drupal::service('plugin.manager.search')->createInstance('node_search'); ++ $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); + $plugin->setSearch('rocks', array(), array()); + // Do the search and assert the results. + $set = $plugin->execute(); @@ -1055,7 +1051,7 @@ // Do the search and assert the results. - $set = node_search_execute('rocks'); -+ $plugin = \Drupal::service('plugin.manager.search')->createInstance('node_search'); ++ $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); + $plugin->setSearch('rocks', array(), array()); + // Do the search and assert the results. + $set = $plugin->execute(); @@ -1472,7 +1468,7 @@ -} - diff --git a/core/modules/search/search.module b/core/modules/search/search.module -index 9de229b..8388497 100644 +index 9de229b..0c4846d 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -7,6 +7,7 @@ @@ -1517,7 +1513,7 @@ // The default local task points to its parent, but this item points to // where it should so it should not be changed. 'type' => MENU_LOCAL_TASK, -@@ -231,30 +233,31 @@ function search_is_active() { +@@ -231,30 +233,27 @@ function search_is_active() { * have been set to active on the search settings page will be returned. * * @return @@ -1533,20 +1529,18 @@ - if (!isset($search_hooks)) { - foreach (module_implements('search_info') as $module) { - $search_hooks[$module] = call_user_func($module . '_search_info'); -+ $search_info = &drupal_static(__FUNCTION__); -+ -+ if (!isset($search_info)) { -+ $search_info = array(); -+ $search_definitions = Drupal::service('plugin.manager.search')->getDefinitions(); -+ foreach ($search_definitions as $plugin_id => $plugin) { -+ $module = $plugin['module']; -+ $search_info[$module] = $plugin; - // Use module name as the default value. +- // Use module name as the default value. - $search_hooks[$module] += array('title' => $module, 'path' => $module); - // Include the module name itself in the array. - $search_hooks[$module]['module'] = $module; -+ $search_info[$module] += array('title' => $module, 'path' => $module, 'module' => $module); - } +- } ++ $search_info = array(); ++ $search_definitions = Drupal::service('plugin.manager.search')->getDefinitions(); ++ foreach ($search_definitions as $plugin_id => $plugin) { ++ $module = $plugin['module']; ++ $search_info[$module] = $plugin; ++ // Use module name as the default value. ++ $search_info[$module] += array('title' => $module, 'path' => $module, 'module' => $module); } if ($all) { @@ -1560,7 +1554,7 @@ } /** -@@ -307,7 +310,9 @@ function _search_menu_access($name) { +@@ -307,7 +306,9 @@ function _search_menu_access($name) { */ function search_reindex($sid = NULL, $module = NULL, $reindex = FALSE, $langcode = NULL) { if ($module == NULL && $sid == NULL) { @@ -1571,7 +1565,7 @@ } else { $query = db_delete('search_dataset') -@@ -364,10 +369,9 @@ function search_cron() { +@@ -364,10 +365,9 @@ function search_cron() { // to date. drupal_register_shutdown_function('search_update_totals'); @@ -1585,7 +1579,7 @@ } /** -@@ -1057,36 +1061,6 @@ function search_box_form_submit($form, &$form_state) { +@@ -1057,36 +1057,6 @@ function search_box_form_submit($form, &$form_state) { } /** @@ -1688,10 +1682,10 @@ + arguments: ['@container.namespaces'] diff --git a/core/modules/search/tests/modules/search_extra_type/lib/Drupal/search_extra_type/Plugin/Search/SearchExtraTypeSearch.php b/core/modules/search/tests/modules/search_extra_type/lib/Drupal/search_extra_type/Plugin/Search/SearchExtraTypeSearch.php new file mode 100644 -index 0000000..4500af3 +index 0000000..d7d35e5 --- /dev/null +++ b/core/modules/search/tests/modules/search_extra_type/lib/Drupal/search_extra_type/Plugin/Search/SearchExtraTypeSearch.php -@@ -0,0 +1,138 @@ +@@ -0,0 +1,139 @@ +get('config.factory'); -+ return new static($config_factory, $configuration, $plugin_id, $plugin_definition); ++ return new static( ++ $container->get('config.factory')->get('search_extra_type.settings'), ++ $configuration, ++ $plugin_id, ++ $plugin_definition ++ ); + } + -+ public function __construct(ConfigFactory $config_factory, array $configuration, $plugin_id, array $plugin_definition) { -+ $this->configuration = $configuration; -+ $this->pluginId = $plugin_id; -+ $this->pluginDefinition = $plugin_definition; -+ $this->config_factory = $config_factory; ++ public function __construct(Config $config_settings, array $configuration, $plugin_id, array $plugin_definition) { ++ $this->configSettings = $config_settings; ++ parent::__construct($configuration, $plugin_id, $plugin_definition); + } + + /** @@ -1817,7 +1812,7 @@ + 'bi' => t('Bistromathic'), + 'ii' => t('Infinite Improbability'), + ), -+ '#default_value' => $this->config_factory->get('search_extra_type.settings')->get('boost'), ++ '#default_value' => $this->configSettings->get('boost'), + ); + } + @@ -1825,7 +1820,7 @@ + * {@inheritdoc} + */ + public function submitAdminForm(array &$form, array &$form_state) { -+ $this->config_factory->get('search_extra_type.settings') ++ $this->configSettings + ->set('boost', $form_state['values']['extra_type_settings']['boost']) + ->save(); + } @@ -1940,7 +1935,7 @@ -} diff --git a/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php b/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php new file mode 100644 -index 0000000..3a3ff6b +index 0000000..96c5cb6 --- /dev/null +++ b/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php @@ -0,0 +1,105 @@ @@ -1974,26 +1969,28 @@ + */ +class UserSearch extends SearchPluginBase { + protected $database; -+ protected $entity_manager; -+ protected $module_handler; ++ protected $entityManager; ++ protected $moduleHandler; + + /** + * {@inheritdoc} + */ + static public function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { -+ $database = $container->get('database'); -+ $entity_manager = $container->get('plugin.manager.entity'); -+ $module_handler = $container->get('module_handler'); -+ return new static($database, $entity_manager, $module_handler, $configuration, $plugin_id, $plugin_definition); ++ return new static( ++ $container->get('database'), ++ $container->get('plugin.manager.entity'), ++ $container->get('module_handler'), ++ $configuration, ++ $plugin_id, ++ $plugin_definition ++ ); + } + + public function __construct(Connection $database, EntityManager $entity_manager, ModuleHandlerInterface $module_handler, array $configuration, $plugin_id, array $plugin_definition) { -+ $this->configuration = $configuration; -+ $this->pluginId = $plugin_id; -+ $this->pluginDefinition = $plugin_definition; + $this->database = $database; -+ $this->entity_manager = $entity_manager; -+ $this->module_handler = $module_handler; ++ $this->entityManager = $entity_manager; ++ $this->moduleHandler = $module_handler; ++ parent::__construct($configuration, $plugin_id, $plugin_definition); + } + + /** @@ -2030,9 +2027,7 @@ + ->limit(15) + ->execute() + ->fetchCol(); -+ $entity_manger = $this->entity_manager; -+ $user_storage = $entity_manger->getStorageController('user'); -+ $accounts = $user_storage->load($uids); ++ $accounts = $this->entityManager->getStorageController('user')->load($uids); + + foreach ($accounts as $account_ng) { + $account = $account_ng->getBCEntity();