Skip to content

Commit 0836aba

Browse files
Code clean-up: second batch.
1 parent 39c5f5c commit 0836aba

5 files changed

+28
-56
lines changed

Diff for: search_api.install

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @file
5-
* Defines the schema of the search API module.
5+
* Install, update and uninstall functions for the Search API module.
66
*/
77

88
/**
@@ -31,21 +31,19 @@ function search_api_schema() {
3131
'not null' => TRUE,
3232
),
3333
'changed' => array(
34-
'description' => 'Either a flag or a timestamp to indicate if or when the item was changed since it was last indexed.',
34+
'description' => 'A timestamp indicating when the item was last changed.',
3535
'type' => 'int',
3636
'unsigned' => TRUE,
3737
'not null' => TRUE,
38-
'default' => 1,
3938
),
4039
'status' => array(
41-
'description' => 'Boolean indicating whether the entity should be in the index.',
40+
'description' => 'Boolean indicating whether the item needs to be reindexed.',
4241
'type' => 'int',
4342
'not null' => TRUE,
44-
'default' => 1,
4543
),
4644
),
4745
'indexes' => array(
48-
'indexing' => array('index_id', 'changed'),
46+
'indexing' => array('index_id', 'status', 'changed', 'item_id'),
4947
),
5048
'primary key' => array('index_id', 'item_id'),
5149
);
@@ -59,7 +57,7 @@ function search_api_schema() {
5957
'not null' => TRUE,
6058
),
6159
'server_id' => array(
62-
'description' => 'The {search_api_server}.machine_name for which this task should be executed.',
60+
'description' => 'The ID of the server for which this task should be executed.',
6361
'type' => 'varchar',
6462
'length' => 50,
6563
'not null' => TRUE,
@@ -71,7 +69,7 @@ function search_api_schema() {
7169
'not null' => TRUE,
7270
),
7371
'index_id' => array(
74-
'description' => 'The {search_api_index}.machine_name to which this task pertains, if applicable for this type.',
72+
'description' => 'The ID of the index to which this task pertains, if applicable for this type.',
7573
'type' => 'varchar',
7674
'length' => 50,
7775
'not null' => FALSE,
@@ -85,7 +83,7 @@ function search_api_schema() {
8583
),
8684
),
8785
'indexes' => array(
88-
'server' => array('server_id'),
86+
'execution' => array('type', 'server_id', 'id'),
8987
),
9088
'primary key' => array('id'),
9189
);

Diff for: search_api.links.menu.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
search_api.overview:
22
title: Search API
3-
description: 'Create and configure search engines.'
3+
description: 'Create and configure search indexes and servers.'
44
route_name: search_api.overview
5-
parent: system.admin_config_search
5+
parent: system.admin_config_search

Diff for: search_api.module

+9-28
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @file
5-
* Contains the Search API hook implementations.
5+
* Provides a rich framework for creating searches.
66
*/
77

88
use Drupal\Core\Entity\ContentEntityInterface;
@@ -16,7 +16,7 @@ use Drupal\search_api\Plugin\SearchApi\Datasource\ContentEntityDatasource;
1616
function search_api_help($route_name) {
1717
switch ($route_name) {
1818
case 'search_api.overview':
19-
return t('Below is a list of indexes grouped by the server they are associated with. A server is the definition of the actual indexing, querying and storage engine (e.g. an Apache Solr or MongoDB server). An index is the definition of the actual indexed content that will be searched against (e.g. A core within Solr).');
19+
return t('Below is a list of indexes grouped by the server they are associated with. A server is the definition of the actual indexing, querying and storage engine (e.g., an Apache Solr server, the database, …). An index is defines the indexed content (e.g., all content and all comments on "Article" posts).');
2020
}
2121
}
2222

@@ -37,7 +37,7 @@ function search_api_permission() {
3737
*
3838
* This will first execute any pending server tasks. After that, items will
3939
* be indexed on all enabled indexes with a non-zero cron limit. Indexing will
40-
* run for the time set in the cron_limit config setting(defaulting to 15
40+
* run for the time set in the cron_limit config setting (defaulting to 15
4141
* seconds), but will at least index one batch of items on each index.
4242
*/
4343
function search_api_cron() {
@@ -123,6 +123,7 @@ function search_api_entity_insert(EntityInterface $entity) {
123123
return;
124124
}
125125

126+
// Compute the item IDs for all languages of the entity.
126127
$item_ids = array();
127128
$entity_id = $entity->id();
128129
foreach (array_keys($entity->getTranslationLanguages()) as $langcode) {
@@ -138,8 +139,8 @@ function search_api_entity_insert(EntityInterface $entity) {
138139
/**
139140
* Implements hook_entity_update().
140141
*
141-
* Updates the entry to the tracking table for each index that tracks this
142-
* entity.
142+
* Updates the corresponding tracking table entries for each index that tracks
143+
* this entity.
143144
*
144145
* Also takes care of new or deleted translations.
145146
*/
@@ -151,6 +152,8 @@ function search_api_entity_update(EntityInterface $entity) {
151152
return;
152153
}
153154

155+
// Compare old and new languages for the entity to identify inserted,
156+
// updated and deleted translations (and, therefore, search items).
154157
$entity_id = $entity->id();
155158
$combine_id = function($langcode) use ($entity_id) {
156159
return $entity_id . ':' . $langcode;
@@ -203,6 +206,7 @@ function search_api_entity_delete(EntityInterface $entity) {
203206
return;
204207
}
205208

209+
// Remove the search items for all the entity's translations.
206210
$item_ids = array();
207211
$entity_id = $entity->id();
208212
foreach (array_keys($entity->getTranslationLanguages()) as $langcode) {
@@ -234,26 +238,3 @@ function search_api_theme() {
234238
),
235239
);
236240
}
237-
238-
/**
239-
* Implements hook_entity_type_build().
240-
*/
241-
function search_api_entity_type_build(array &$entity_types) {
242-
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
243-
if (isset($entity_types['node'])) {
244-
$entity_types['node']->set('search_api_default_fields', array(
245-
'node:title' => array(
246-
'type' => 'string',
247-
),
248-
'node:path' => array(
249-
'type' => 'string',
250-
),
251-
'node:created' => array(
252-
'type' => 'date',
253-
),
254-
'node:changed' => array(
255-
'type' => 'date',
256-
)
257-
));
258-
}
259-
}

Diff for: search_api.routing.yml

+6-13
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,6 @@ search_api.index_delete:
8787
requirements:
8888
_entity_access: 'search_api_index.delete'
8989

90-
search_api.index_disable:
91-
path: '/admin/config/search/search-api/index/{search_api_index}/disable'
92-
defaults:
93-
_entity_form: 'search_api_index.disable'
94-
requirements:
95-
_entity_access: 'search_api_index.disable'
96-
9790
search_api.index_enable:
9891
path: '/admin/config/search/search-api/index/{search_api_index}/enable'
9992
defaults:
@@ -102,15 +95,15 @@ search_api.index_enable:
10295
_entity_access: 'search_api_index.enable'
10396
_csrf_token: 'TRUE'
10497

105-
search_api.index_fields:
106-
path: '/admin/config/search/search-api/index/{search_api_index}/fields'
98+
search_api.index_disable:
99+
path: '/admin/config/search/search-api/index/{search_api_index}/disable'
107100
defaults:
108-
_entity_form: 'search_api_index.fields'
101+
_entity_form: 'search_api_index.disable'
109102
requirements:
110-
_entity_access: 'search_api_index.fields'
103+
_entity_access: 'search_api_index.disable'
111104

112-
search_api.index_fields_datasource:
113-
path: '/admin/config/search/search-api/index/{search_api_index}/fields/{datasource_id}'
105+
search_api.index_fields:
106+
path: '/admin/config/search/search-api/index/{search_api_index}/fields'
114107
defaults:
115108
_entity_form: 'search_api_index.fields'
116109
requirements:

Diff for: search_api.services.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
services:
2-
plugin.manager.search_api.processor:
3-
class: Drupal\search_api\Processor\ProcessorPluginManager
4-
parent: default_plugin_manager
5-
62
plugin.manager.search_api.backend:
73
class: Drupal\search_api\Backend\BackendPluginManager
84
parent: default_plugin_manager
@@ -11,6 +7,10 @@ services:
117
class: Drupal\search_api\Datasource\DatasourcePluginManager
128
parent: default_plugin_manager
139

10+
plugin.manager.search_api.processor:
11+
class: Drupal\search_api\Processor\ProcessorPluginManager
12+
parent: default_plugin_manager
13+
1414
plugin.manager.search_api.tracker:
1515
class: Drupal\search_api\Tracker\TrackerPluginManager
1616
parent: default_plugin_manager

0 commit comments

Comments
 (0)