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 30d44cb..6c194d4 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -173,11 +173,11 @@ public function execute() { $uri = $node->uri(); $username = array( '#theme' => 'username', - '#account' => user_load($node->uid), + '#account' => $this->entityManager->getStorageController('user')->load($node->uid), ); $results[] = array( 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))), - 'type' => check_plain(node_get_type_label($node)), + 'type' => check_plain($this->entityManager->getStorageController('node_type')->load($node->bundle())->label()), 'title' => $node->label($item->langcode), 'user' => drupal_render($username), 'date' => $node->getChangedTime(), @@ -327,6 +327,7 @@ public function addToAdminForm(array &$form, array &$form_state) { public function submitAdminForm(array &$form, array &$form_state) { foreach ($this->moduleHandler->invokeAll('ranking') as $var => $values) { if (isset($form_state['values']['node_rank_' . $var])) { + // @todo Fix when https://drupal.org/node/1831632 is in. variable_set('node_rank_' . $var, $form_state['values']['node_rank_' . $var]); } } diff --git a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php index 40d2e1f..a58bb00 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php @@ -107,11 +107,10 @@ protected function getModuleOptions() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - // Collect some stats + // Collect some stats. $remaining = 0; $total = 0; - $active_plugins = $this->searchPluginManager->getActivePlugins(); - foreach ($active_plugins as $plugin) { + foreach ($this->searchPluginManager->getActivePlugins() as $plugin) { if ($status = $plugin->indexStatus()) { $remaining += $status['remaining']; $total += $status['total']; @@ -120,7 +119,7 @@ public function buildForm(array $form, array &$form_state) { $this->moduleHandler->loadAllIncludes('admin.inc'); $count = format_plural($remaining, 'There is 1 item left to index.', 'There are @count items left to index.'); - $percentage = ((int)min(100, 100 * ($total - $remaining) / max(1, $total))) . '%'; + $percentage = ((int) min(100, 100 * ($total - $remaining) / max(1, $total))) . '%'; $status = '

' . t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) . ' ' . $count . '

'; $form['status'] = array( '#type' => 'details', 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 index 780783c..3c44e18 100644 --- 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 @@ -40,6 +40,18 @@ static public function create(ContainerInterface $container, array $configuratio ); } + /** + * Creates a SearchExtraTypeSearch object. + * + * @param Config $config_settings + * The extra config settings. + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param array $plugin_definition + * The plugin implementation definition. + */ public function __construct(Config $config_settings, array $configuration, $plugin_id, array $plugin_definition) { $this->configSettings = $config_settings; parent::__construct($configuration, $plugin_id, $plugin_definition); @@ -58,7 +70,7 @@ public function setSearch($keywords, array $params, array $attributes) { /** * Verifies if the given parameters are valid enough to execute a search for. * - * @return boolean + * @return bool * A true or false depending on the implementation. */ public function isSearchExecutable() { @@ -66,12 +78,12 @@ public function isSearchExecutable() { } /** - * Execute the search + * Execute the search. * * This is a dummy search, so when search "executes", we just return a dummy * result containing the keywords and a list of conditions. * - * @return array $results + * @return array * A structured list of search results */ public function execute() { diff --git a/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php b/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php index 08ea1eb..15622bf 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php @@ -54,6 +54,22 @@ static public function create(ContainerInterface $container, array $configuratio ); } + /** + * Creates a UserSearch object. + * + * @param Connection $database + * The database connection. + * @param EntityManager $entity_manager + * The entity manager. + * @param ModuleHandlerInterface $module_handler + * The module handler. + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param array $plugin_definition + * The plugin implementation definition. + */ public function __construct(Connection $database, EntityManager $entity_manager, ModuleHandlerInterface $module_handler, array $configuration, $plugin_id, array $plugin_definition) { $this->database = $database; $this->entityManager = $entity_manager; @@ -80,14 +96,15 @@ public function execute() { // Administrators can also search in the otherwise private email field, and // they don't need to be restricted to only active users. $query->fields('users', array('mail')); - $query->condition(db_or()-> - condition('name', '%' . db_like($keys) . '%', 'LIKE')-> - condition('mail', '%' . db_like($keys) . '%', 'LIKE')); + $query->condition($query->orConditionGroup() + ->condition('name', '%' . $this->database->escapeLike($keys) . '%', 'LIKE') + ->condition('mail', '%' . $this->database->escapeLike($keys) . '%', 'LIKE') + ); } else { // Regular users can only search via usernames, and we do not show them // blocked accounts. - $query->condition('name', '%' . db_like($keys) . '%', 'LIKE') + $query->condition('name', '%' . $this->database->escapeLike($keys) . '%', 'LIKE') ->condition('status', 1); } $uids = $query