diff --git a/config/schema/search_api.index.schema.yml b/config/schema/search_api.index.schema.yml index 732d9b8..caf0fd2 100644 --- a/config/schema/search_api.index.schema.yml +++ b/config/schema/search_api.index.schema.yml @@ -17,23 +17,41 @@ search_api.index.*: read_only: type: boolean label: 'Read-only' + processors: + type: sequence + label: 'Processor settings' + sequence: + type: mapping + label: 'A processor' + mapping: + processor_id: + type: string + label: 'The plugin ID of the processor' + weights: + type: sequence + label: 'The processor''s weights for the different processing stages' + sequence: + type: integer + label: 'The processor''s weight for this stage' + settings: + type: plugin.plugin_configuration.search_api_processor.[%parent.processor_id] + fields: + type: sequence + label: 'Indexed fields' + sequence: + type: mapping + label: field + mapping: + type: + type: string + label: 'Type of field' + boost: + type: float + label: 'Boost' options: type: mapping label: 'Options' mapping: - fields: - type: sequence - label: 'Indexed fields' - sequence: - type: mapping - label: field - mapping: - type: - type: string - label: 'Type of field' - boost: - type: float - label: 'Boost' additional fields: type: sequence label: 'Included additional fields' @@ -46,24 +64,6 @@ search_api.index.*: index_directly: type: boolean label: 'Index items immediately' - processors: - type: sequence - label: 'Processor settings' - sequence: - type: mapping - label: 'A processor' - mapping: - processor_id: - type: string - label: 'The plugin ID of the processor' - weights: - type: sequence - label: 'The processor''s weights for the different processing stages' - sequence: - type: integer - label: 'The processor''s weight for this stage' - settings: - type: plugin.plugin_configuration.search_api_processor.[%parent.processor_id] datasources: type: sequence label: 'Datasource plugin IDs' diff --git a/search_api.api.php b/search_api.api.php index 0fa2331..0c3fde8 100644 --- a/search_api.api.php +++ b/search_api.api.php @@ -152,7 +152,7 @@ function hook_search_api_query_alter(\Drupal\search_api\Query\QueryInterface &$q return; } // Otherwise, exclude the node with ID 10 from the search results. - $fields = $query->getIndex()->getFields(); + $fields = $query->getIndex()->getCachedFields(); foreach ($query->getIndex()->getDatasources() as $datasource_id => $datasource) { if ($datasource->getEntityTypeId() == 'node') { $field = \Drupal\search_api\Utility::createCombinedId($datasource_id, 'nid'); @@ -173,7 +173,7 @@ function hook_search_api_query_alter(\Drupal\search_api\Query\QueryInterface &$q */ function hook_search_api_query_TAG_alter(\Drupal\search_api\Query\QueryInterface &$query) { // Exclude the node with ID 10 from the search results. - $fields = $query->getIndex()->getFields(); + $fields = $query->getIndex()->getCachedFields(); foreach ($query->getIndex()->getDatasources() as $datasource_id => $datasource) { if ($datasource->getEntityTypeId() == 'node') { $field = \Drupal\search_api\Utility::createCombinedId($datasource_id, 'nid'); diff --git a/search_api_db/search_api_db_defaults/config/optional/search_api.index.default_index.yml b/search_api_db/search_api_db_defaults/config/optional/search_api.index.default_index.yml index 57f0ee8..8c949e3 100644 --- a/search_api_db/search_api_db_defaults/config/optional/search_api.index.default_index.yml +++ b/search_api_db/search_api_db_defaults/config/optional/search_api.index.default_index.yml @@ -2,164 +2,164 @@ id: default_index name: 'Default content index' description: 'Default content index created by the Database Search Defaults module' read_only: false +processors: + content_access: + processor_id: content_access + weights: + preprocess_index: -6 + preprocess_query: -4 + settings: { } + highlight: + processor_id: highlight + weights: + postprocess_query: -9 + settings: + highlight: always + excerpt: true + excerpt_length: 256 + prefix: '' + suffix: '' + html_filter: + processor_id: html_filter + weights: + preprocess_index: -3 + preprocess_query: -6 + settings: + fields: + - rendered_item + title: true + alt: true + tags: + h1: 5 + h2: 3 + h3: 2 + string: 2 + b: 2 + ignorecase: + processor_id: ignorecase + weights: + preprocess_index: -5 + preprocess_query: -8 + settings: + fields: + - rendered_item + - 'entity:node/title' + language: + processor_id: language + weights: + preprocess_index: -50 + settings: { } + node_status: + processor_id: node_status + weights: + preprocess_index: -10 + settings: { } + rendered_item: + processor_id: rendered_item + weights: + preprocess_index: -8 + settings: + roles: + anonymous: anonymous + view_mode: + 'entity:node': + article: search_index + page: search_index + stopwords: + processor_id: stopwords + weights: + preprocess_query: -10 + postprocess_query: -10 + settings: + fields: + - rendered_item + - 'entity:node/title' + stopwords: + - a + - an + - and + - are + - as + - at + - be + - but + - by + - for + - if + - in + - into + - is + - it + - 'no' + - not + - of + - 'on' + - or + - s + - such + - t + - that + - the + - their + - then + - there + - these + - they + - this + - to + - was + - will + - with + tokenizer: + processor_id: tokenizer + weights: + preprocess_index: -2 + preprocess_query: -5 + settings: + fields: + - rendered_item + - 'entity:node/title' + spaces: '' + overlap_cjk: 1 + minimum_word_size: '3' + transliteration: + processor_id: transliteration + weights: + preprocess_index: -4 + preprocess_query: -7 + settings: + fields: + - rendered_item + - 'entity:node/title' +fields: + search_api_language: + type: string + 'entity:node/title': + type: text + boost: 8 + rendered_item: + type: text + 'entity:node/created': + type: date + 'entity:node/changed': + type: date + 'entity:node/status': + type: boolean + 'entity:node/sticky': + type: boolean + 'entity:node/field_tags:entity:name': + type: string + 'entity:node/uid:entity:name': + type: string + 'entity:node/uid': + type: integer + search_api_node_grants: + type: string + 'entity:node/type': + type: string options: index_directly: true cron_limit: 50 - processors: - content_access: - processor_id: content_access - weights: - preprocess_index: -6 - preprocess_query: -4 - settings: { } - highlight: - processor_id: highlight - weights: - postprocess_query: -9 - settings: - highlight: always - excerpt: true - excerpt_length: 256 - prefix: '' - suffix: '' - html_filter: - processor_id: html_filter - weights: - preprocess_index: -3 - preprocess_query: -6 - settings: - fields: - - rendered_item - title: true - alt: true - tags: - h1: 5 - h2: 3 - h3: 2 - string: 2 - b: 2 - ignorecase: - processor_id: ignorecase - weights: - preprocess_index: -5 - preprocess_query: -8 - settings: - fields: - - rendered_item - - 'entity:node/title' - language: - processor_id: language - weights: - preprocess_index: -50 - settings: { } - node_status: - processor_id: node_status - weights: - preprocess_index: -10 - settings: { } - rendered_item: - processor_id: rendered_item - weights: - preprocess_index: -8 - settings: - roles: - anonymous: anonymous - view_mode: - 'entity:node': - article: search_index - page: search_index - stopwords: - processor_id: stopwords - weights: - preprocess_query: -10 - postprocess_query: -10 - settings: - fields: - - rendered_item - - 'entity:node/title' - stopwords: - - a - - an - - and - - are - - as - - at - - be - - but - - by - - for - - if - - in - - into - - is - - it - - 'no' - - not - - of - - 'on' - - or - - s - - such - - t - - that - - the - - their - - then - - there - - these - - they - - this - - to - - was - - will - - with - tokenizer: - processor_id: tokenizer - weights: - preprocess_index: -2 - preprocess_query: -5 - settings: - fields: - - rendered_item - - 'entity:node/title' - spaces: '' - overlap_cjk: 1 - minimum_word_size: '3' - transliteration: - processor_id: transliteration - weights: - preprocess_index: -4 - preprocess_query: -7 - settings: - fields: - - rendered_item - - 'entity:node/title' - fields: - search_api_language: - type: string - 'entity:node/title': - type: text - boost: 8 - rendered_item: - type: text - 'entity:node/created': - type: date - 'entity:node/changed': - type: date - 'entity:node/status': - type: boolean - 'entity:node/sticky': - type: boolean - 'entity:node/field_tags:entity:name': - type: string - 'entity:node/uid:entity:name': - type: string - 'entity:node/uid': - type: integer - search_api_node_grants: - type: string - 'entity:node/type': - type: string 'additional fields': 'entity:node/field_tags': 'entity:node/field_tags' 'entity:node/field_tags:entity': 'entity:node/field_tags:entity' diff --git a/search_api_db/src/Plugin/search_api/backend/Database.php b/search_api_db/src/Plugin/search_api/backend/Database.php index b1d9fc4..39dc263 100644 --- a/search_api_db/src/Plugin/search_api/backend/Database.php +++ b/search_api_db/src/Plugin/search_api/backend/Database.php @@ -515,7 +515,7 @@ class Database extends BackendPluginBase { $this->getKeyValueStore()->set($index->id(), $db_info); // If there are no fields, we are done now. - if (!$index->getFields()) { + if (!$index->getCachedFields()) { return; } } @@ -773,7 +773,7 @@ class Database extends BackendPluginBase { try { $db_info = $this->getIndexDbInfo($index); $fields = &$db_info['field_tables']; - $new_fields = $index->getFields(); + $new_fields = $index->getCachedFields(); $reindex = FALSE; $cleared = FALSE; @@ -1283,7 +1283,7 @@ class Database extends BackendPluginBase { if (count($words) > 1 && max(array_map('strlen', $words)) <= 50) { // Overlong token is due to bad tokenizing. // Check for "Tokenizer" preprocessor on index. - if (empty($index->getOption('processors')['search_api_tokenizer']['status'])) { + if (empty($index->getProcessorSettings()['search_api_tokenizer']['status'])) { $this->getLogger()->warning('An overlong word (more than 50 characters) was encountered while indexing, due to bad tokenizing. It is recommended to enable the "Tokenizer" preprocessor for indexes using database servers. Otherwise, the backend class has to use its own, fixed tokenizing.'); } else { diff --git a/search_api_db/src/Tests/BackendTest.php b/search_api_db/src/Tests/BackendTest.php index ea48701..a8409ab 100644 --- a/search_api_db/src/Tests/BackendTest.php +++ b/search_api_db/src/Tests/BackendTest.php @@ -159,13 +159,13 @@ class BackendTest extends EntityUnitTestBase { // Remove a field from the index and check if the change is matched in the // server configuration. $field_id = $this->getFieldId('keywords'); - if (empty($index->getFields()[$field_id])) { + if (empty($index->getCachedFields()[$field_id])) { throw new \Exception(); } - $index->getFields()[$field_id]->setIndexed(FALSE, TRUE); + $index->getCachedFields()[$field_id]->setIndexed(FALSE, TRUE); $index->save(); - $index_fields = array_keys($index->getOption('fields', array())); + $index_fields = array_keys($index->getFields()); $db_info = \Drupal::keyValue(BackendDatabase::INDEXES_KEY_VALUE_STORE_ID)->get($this->indexId); $server_fields = array_keys($db_info['field_tables']); @@ -175,7 +175,7 @@ class BackendTest extends EntityUnitTestBase { $this->assertEqual($index_fields, $server_fields); // Add the field back for the next assertions. - $index->getFields(FALSE)[$field_id]->setIndexed(TRUE, TRUE); + $index->getCachedFields(FALSE)[$field_id]->setIndexed(TRUE, TRUE); $index->save(); } @@ -186,15 +186,15 @@ class BackendTest extends EntityUnitTestBase { /** @var \Drupal\search_api\IndexInterface $index */ $index = $this->getIndex(); - $index->getFields(FALSE)[$this->getFieldId('body')]->setIndexed(TRUE, TRUE); + $index->getCachedFields(FALSE)[$this->getFieldId('body')]->setIndexed(TRUE, TRUE); - $processors = $index->getOption('processors', array()); + $processors = $index->getProcessorSettings(); $processors['html_filter'] = array( 'processor_id' => 'html_filter', 'weights' => array(), 'settings' => array(), ); - $index->setOption('processors', $processors); + $index->setProcessorSettings($processors); $index->save(); } @@ -204,10 +204,10 @@ class BackendTest extends EntityUnitTestBase { protected function disableHtmlFilter() { /** @var \Drupal\search_api\IndexInterface $index */ $index = $this->getIndex(); - $processors = $index->getOption('processors'); + $processors = $index->getProcessorSettings(); unset($processors['html_filter']); - $index->setOption('processors', $processors); - $index->getFields()[$this->getFieldId('body')]->setIndexed(FALSE, TRUE); + $index->setProcessorSettings($processors); + $index->getCachedFields()[$this->getFieldId('body')]->setIndexed(FALSE, TRUE); $index->save(); } @@ -864,7 +864,7 @@ class BackendTest extends EntityUnitTestBase { /** @var \Drupal\search_api\IndexInterface $index */ $index = $this->getIndex(); $index->resetCaches(); - $fields = $index->getFields(FALSE); + $fields = $index->getCachedFields(FALSE); $price_field = $fields[$this->getFieldId('prices')]; $price_field->setType('decimal')->setIndexed(TRUE, TRUE); $success = $index->save(); @@ -910,7 +910,7 @@ class BackendTest extends EntityUnitTestBase { $this->assertEqual($count, 1, 'Indexing an item with an empty value for a non string field worked.'); // Regression test for #2471509. - $index->getFields(FALSE)[$this->getFieldId('body')]->setIndexed(TRUE, TRUE); + $index->getCachedFields(FALSE)[$this->getFieldId('body')]->setIndexed(TRUE, TRUE); $index->save(); $this->indexItems($this->indexId); @@ -927,7 +927,7 @@ class BackendTest extends EntityUnitTestBase { // Regression test for #2616268. $index = $this->getIndex(); - $index->getFields()[$this->getFieldId('body')]->setType('string', TRUE); + $index->getCachedFields()[$this->getFieldId('body')]->setType('string', TRUE); $index->save(); $count = $this->indexItems($this->indexId); $this->assertEqual($count, 8, 'Switching type from text to string worked.'); @@ -940,7 +940,7 @@ class BackendTest extends EntityUnitTestBase { $this->assertIgnored($results); $this->assertWarnings($results); - $index->getFields()[$this->getFieldId('body')]->setIndexed(FALSE, TRUE); + $index->getCachedFields()[$this->getFieldId('body')]->setIndexed(FALSE, TRUE); $index->save(); } diff --git a/src/Entity/Index.php b/src/Entity/Index.php index 8a07deb..4597dbf 100644 --- a/src/Entity/Index.php +++ b/src/Entity/Index.php @@ -61,6 +61,8 @@ use Drupal\views\Views; * "description", * "read_only", * "options", + * "fields", + * "processors", * "datasources", * "datasource_configs", * "tracker", @@ -200,12 +202,20 @@ class Index extends ConfigEntityBase implements IndexInterface { * @var \Drupal\search_api\Item\GenericFieldInterface[][][]|null * * @see computeFields() - * @see getFields() + * @see getCachedFields() * @see getFieldsByDatasource() * @see getAdditionalFields() * @see getAdditionalFieldsByDatasource() */ - protected $fields; + protected $cachedFields; + + /** + * An array of field settings. + * + * @var array + * An array containing field settings. + */ + protected $fields = array(); /** * Cached fields data, grouped by datasource and indexed state. @@ -248,7 +258,15 @@ class Index extends ConfigEntityBase implements IndexInterface { * * @see loadProcessors() */ - protected $processors; + protected $processorInstances; + + /** + * The array of processor settings. + * + * @var array + * An array containing processor settings. + */ + protected $processors = array(); /** * List of types that failed to map to a Search API type. @@ -351,6 +369,21 @@ class Index extends ConfigEntityBase implements IndexInterface { /** * {@inheritdoc} */ + public function setFields(array $fields = array()) { + $this->fields = $fields; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getFields() { + return $this->fields; + } + + /** + * {@inheritdoc} + */ public function isValidDatasource($datasource_id) { $datasources = $this->getDatasources(); return !empty($datasources[$datasource_id]); @@ -485,7 +518,7 @@ class Index extends ConfigEntityBase implements IndexInterface { // Filter processors by status if required. Enabled processors are those // which have settings in the "processors" option. if ($only_enabled) { - $processors_settings = $this->getOption('processors', array()); + $processors_settings = $this->getProcessorSettings(); $processors = array_intersect_key($processors, $processors_settings); } @@ -497,7 +530,7 @@ class Index extends ConfigEntityBase implements IndexInterface { */ public function getProcessorsByStage($stage, $only_enabled = TRUE) { $processors = $this->loadProcessors(); - $processor_settings = $this->getOption('processors', array()); + $processor_settings = $this->getProcessorSettings(); $processor_weights = array(); // Get a list of all processors meeting the criteria (stage and, optionally, @@ -530,13 +563,13 @@ class Index extends ConfigEntityBase implements IndexInterface { * The loaded processors, keyed by processor ID. */ protected function loadProcessors() { - if (!isset($this->processors)) { + if (!isset($this->processorInstances)) { /** @var $processor_plugin_manager \Drupal\search_api\Processor\ProcessorPluginManager */ $processor_plugin_manager = \Drupal::service('plugin.manager.search_api.processor'); - $processor_settings = $this->getOption('processors', array()); + $processor_settings = $this->getProcessorSettings(); foreach ($processor_plugin_manager->getDefinitions() as $name => $processor_definition) { - if (class_exists($processor_definition['class']) && empty($this->processors[$name])) { + if (class_exists($processor_definition['class']) && empty($this->processorInstances[$name])) { // Create our settings for this processor. $settings = empty($processor_settings[$name]['settings']) ? array() : $processor_settings[$name]['settings']; $settings['index'] = $this; @@ -544,7 +577,7 @@ class Index extends ConfigEntityBase implements IndexInterface { /** @var $processor \Drupal\search_api\Processor\ProcessorInterface */ $processor = $processor_plugin_manager->createInstance($name, $settings); if ($processor->supportsIndex($this)) { - $this->processors[$name] = $processor; + $this->processorInstances[$name] = $processor; } } elseif (!class_exists($processor_definition['class'])) { @@ -553,6 +586,21 @@ class Index extends ConfigEntityBase implements IndexInterface { } } + return $this->processorInstances; + } + + /** + * {@inheritdoc} + */ + public function setProcessorSettings(array $processors) { + $this->processors = $processors; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getProcessorSettings() { return $this->processors; } @@ -587,10 +635,10 @@ class Index extends ConfigEntityBase implements IndexInterface { /** * {@inheritdoc} */ - public function getFields($only_indexed = TRUE) { + public function getCachedFields($only_indexed = TRUE) { $this->computeFields(); $only_indexed = $only_indexed ? 1 : 0; - return $this->fields[$only_indexed]['fields']; + return $this->cachedFields[$only_indexed]['fields']; } /** @@ -604,18 +652,18 @@ class Index extends ConfigEntityBase implements IndexInterface { // @todo Since labels and descriptions are translated, we probably need to // cache per language? $cid = $this->getCacheId(); - if (empty($this->fields)) { + if (empty($this->cachedFields)) { if ($cached = \Drupal::cache()->get($cid)) { - $this->fields = $cached->data; - if ($this->fields) { - $this->updateFieldsIndex($this->fields); + $this->cachedFields = $cached->data; + if ($this->cachedFields) { + $this->updateFieldsIndex($this->cachedFields); } } } // If not cached, fetch the list of fields and their properties. - if (empty($this->fields)) { - $this->fields = array( + if (empty($this->cachedFields)) { + $this->cachedFields = array( 0 => array( 'fields' => array(), 'additional fields' => array(), @@ -644,7 +692,7 @@ class Index extends ConfigEntityBase implements IndexInterface { $vars['%index'] = $this->label(); \Drupal::logger('search_api')->warning('Warning while retrieving available fields for index %index: could not find a type mapping for the following fields: @fields.', $vars); } - \Drupal::cache()->set($cid, $this->fields, Cache::PERMANENT, $this->getCacheTags()); + \Drupal::cache()->set($cid, $this->cachedFields, Cache::PERMANENT, $this->getCacheTags()); } } @@ -692,7 +740,7 @@ class Index extends ConfigEntityBase implements IndexInterface { */ protected function convertPropertyDefinitionsToFields(array $properties, $datasource_id = NULL, $prefix = '', $label_prefix = '') { $type_mapping = Utility::getFieldTypeMapping(); - $field_options = isset($this->options['fields']) ? $this->options['fields'] : array(); + $field_options = $this->fields; $enabled_additional_fields = isset($this->options['additional fields']) ? $this->options['additional fields'] : array(); // All field identifiers should start with the datasource ID. @@ -756,12 +804,12 @@ class Index extends ConfigEntityBase implements IndexInterface { if ($original_property instanceof PropertyInterface) { $additional_field->setHidden($original_property->isHidden()); } - $this->fields[0]['additional fields'][$key] = $additional_field; + $this->cachedFields[0]['additional fields'][$key] = $additional_field; if ($additional_field->isEnabled()) { while ($pos = strrpos($property_path, ':')) { $property_path = substr($property_path, 0, $pos); /** @var \Drupal\search_api\Item\AdditionalFieldInterface $additional_field */ - $additional_field = $this->fields[0]['additional fields'][$property_path]; + $additional_field = $this->cachedFields[0]['additional fields'][$property_path]; $additional_field->setEnabled(TRUE); $additional_field->setLocked(); } @@ -820,7 +868,7 @@ class Index extends ConfigEntityBase implements IndexInterface { $field->setTypeLocked($original_property->isTypeLocked()); $field->setHidden($original_property->isHidden()); } - $this->fields[0]['fields'][$key] = $field; + $this->cachedFields[0]['fields'][$key] = $field; if (isset($field_options[$key]) || $field->isIndexedLocked()) { $field->setIndexed(TRUE); if (isset($field_options[$key])) { @@ -829,7 +877,7 @@ class Index extends ConfigEntityBase implements IndexInterface { $field->setBoost($field_options[$key]['boost']); } } - $this->fields[1]['fields'][$key] = $field; + $this->cachedFields[1]['fields'][$key] = $field; } } foreach ($recurse as $arguments) { @@ -840,8 +888,8 @@ class Index extends ConfigEntityBase implements IndexInterface { $sort_by_label = function(GenericFieldInterface $field1, GenericFieldInterface $field2) { return strnatcasecmp($field1->getLabel(), $field2->getLabel()); }; - uasort($this->fields[0]['fields'], $sort_by_label); - uasort($this->fields[0]['additional fields'], $sort_by_label); + uasort($this->cachedFields[0]['fields'], $sort_by_label); + uasort($this->cachedFields[0]['additional fields'], $sort_by_label); } /** @@ -854,7 +902,7 @@ class Index extends ConfigEntityBase implements IndexInterface { $this->datasourceFields = array_fill_keys($this->datasources, array(array(), array())); $this->datasourceFields[NULL] = array(array(), array()); /** @var \Drupal\search_api\Item\FieldInterface $field */ - foreach ($this->fields[0]['fields'] as $field_id => $field) { + foreach ($this->cachedFields[0]['fields'] as $field_id => $field) { $this->datasourceFields[$field->getDatasourceId()][0][$field_id] = $field; if ($field->isIndexed()) { $this->datasourceFields[$field->getDatasourceId()][1][$field_id] = $field; @@ -869,7 +917,7 @@ class Index extends ConfigEntityBase implements IndexInterface { */ public function getAdditionalFields() { $this->computeFields(); - return $this->fields[0]['additional fields']; + return $this->cachedFields[0]['additional fields']; } /** @@ -881,7 +929,7 @@ class Index extends ConfigEntityBase implements IndexInterface { $this->datasourceAdditionalFields = array_fill_keys($this->datasources, array()); $this->datasourceAdditionalFields[NULL] = array(); /** @var \Drupal\search_api\Item\FieldInterface $field */ - foreach ($this->fields[0]['additional fields'] as $field_id => $field) { + foreach ($this->cachedFields[0]['additional fields'] as $field_id => $field) { $this->datasourceAdditionalFields[$field->getDatasourceId()][$field_id] = $field; } } @@ -896,8 +944,8 @@ class Index extends ConfigEntityBase implements IndexInterface { if (!isset($this->fulltextFields[$i])) { $this->fulltextFields[$i] = array(); if ($only_indexed) { - if (isset($this->options['fields'])) { - foreach ($this->options['fields'] as $key => $field) { + if (isset($this->fields)) { + foreach ($this->fields as $key => $field) { if (Utility::isTextType($field['type'])) { $this->fulltextFields[$i][] = $key; } @@ -905,7 +953,7 @@ class Index extends ConfigEntityBase implements IndexInterface { } } else { - foreach ($this->getFields(FALSE) as $key => $field) { + foreach ($this->getCachedFields(FALSE) as $key => $field) { if (Utility::isTextType($field->getType())) { $this->fulltextFields[$i][] = $key; } @@ -1006,7 +1054,7 @@ class Index extends ConfigEntityBase implements IndexInterface { if (!$this->status) { throw new SearchApiException(new FormattableMarkup("Couldn't index values on index %index (index is disabled)", array('%index' => $this->label()))); } - if (empty($this->options['fields'])) { + if (empty($this->fields)) { throw new SearchApiException(new FormattableMarkup("Couldn't index values on index %index (no fields selected)", array('%index' => $this->label()))); } @@ -1174,10 +1222,10 @@ class Index extends ConfigEntityBase implements IndexInterface { $this->datasourcePlugins = NULL; $this->trackerPlugin = NULL; $this->serverInstance = NULL; - $this->fields = NULL; + $this->cachedFields = NULL; $this->datasourceFields = NULL; $this->fulltextFields = NULL; - $this->processors = NULL; + $this->processorInstances = NULL; $this->properties = NULL; $this->datasourceAdditionalFields = NULL; if ($include_stored) { @@ -1221,8 +1269,8 @@ class Index extends ConfigEntityBase implements IndexInterface { // Obviously, we should first check for locked processors, because they // might add new locked properties. foreach ($this->getProcessors(FALSE) as $processor_id => $processor) { - if ($processor->isLocked() && !isset($this->options['processors'][$processor_id])) { - $this->options['processors'][$processor_id] = array( + if ($processor->isLocked() && !isset($this->processors[$processor_id])) { + $this->processors[$processor_id] = array( 'processor_id' => $processor_id, 'weights' => array(), 'settings' => array(), @@ -1239,15 +1287,15 @@ class Index extends ConfigEntityBase implements IndexInterface { if ($property instanceof PropertyInterface && $property->isIndexedLocked()) { $settings = $property->getFieldSettings(); // Don't overwrite settings that aren't locked (like the boost). - if (isset($this->options['fields'][$key])) { - $settings += $this->options['fields'][$key]; + if (isset($this->fields[$key])) { + $settings += $this->fields[$key]; } if (empty($settings['type']) || $property->isTypeLocked()) { $mapping = Utility::getFieldTypeMapping(); $type = $property->getDataType(); $settings['type'] = !empty($mapping[$type]) ? $mapping[$type] : 'string'; } - $this->options['fields'][$key] = $settings; + $this->fields[$key] = $settings; $change = TRUE; } } @@ -1392,8 +1440,8 @@ class Index extends ConfigEntityBase implements IndexInterface { * The previous version of the index. */ protected function reactToProcessorChanges(IndexInterface $original) { - $original_settings = $original->getOption('processors', array()); - $new_settings = $this->getOption('processors', array()); + $original_settings = $original->getProcessorSettings(); + $new_settings = $this->getProcessorSettings(); // Only actually do something when the processor settings are changed. if ($original_settings != $new_settings) { @@ -1537,7 +1585,7 @@ class Index extends ConfigEntityBase implements IndexInterface { unset($properties['datasourcePlugins']); unset($properties['trackerPlugin']); unset($properties['serverInstance']); - unset($properties['fields']); + unset($properties['cachedFields']); unset($properties['datasourceFields']); unset($properties['fulltextFields']); unset($properties['processors']); diff --git a/src/Form/IndexFieldsForm.php b/src/Form/IndexFieldsForm.php index bb56cc6..352ac59 100644 --- a/src/Form/IndexFieldsForm.php +++ b/src/Form/IndexFieldsForm.php @@ -256,7 +256,7 @@ class IndexFieldsForm extends EntityForm { // Store the fields configuration. $values = $form_state->getValues(); $fields = $values['fields']; - foreach ($index->getFields(FALSE) as $field_id => $field) { + foreach ($index->getCachedFields(FALSE) as $field_id => $field) { if (isset($fields[$field_id])) { $field->setType($fields[$field_id]['type']); $field->setBoost($fields[$field_id]['boost']); diff --git a/src/Form/IndexProcessorsForm.php b/src/Form/IndexProcessorsForm.php index 783e99a..7b4d0ca 100644 --- a/src/Form/IndexProcessorsForm.php +++ b/src/Form/IndexProcessorsForm.php @@ -96,7 +96,7 @@ class IndexProcessorsForm extends EntityForm { $processors_by_stage[$stage] = $this->entity->getProcessorsByStage($stage, FALSE); } - $processor_settings = $this->entity->getOption('processors'); + $processor_settings = $this->entity->getProcessorSettings(); $form['#tree'] = TRUE; $form['#attached']['library'][] = 'search_api/drupal.search_api.index-active-formatters'; @@ -263,10 +263,10 @@ class IndexProcessorsForm extends EntityForm { // Sort the processors so we won't have unnecessary changes. ksort($new_settings); - $settings_changed = $new_settings != $this->entity->getOption('processors', array()); + $settings_changed = $new_settings != $this->entity->getProcessorSettings(); $form_state->set('processors_changed', $settings_changed); if ($settings_changed) { - $this->entity->setOption('processors', $new_settings); + $this->entity->setProcessorSettings($new_settings); } } diff --git a/src/IndexInterface.php b/src/IndexInterface.php index b5ccd54..4beffb7 100644 --- a/src/IndexInterface.php +++ b/src/IndexInterface.php @@ -176,6 +176,24 @@ interface IndexInterface extends ConfigEntityInterface { public function getDatasources($only_enabled = TRUE); /** + * Retrieves this index's field settings + * + * @return array + * An array of field settings + */ + public function getFields(); + + /** + * Sets this index's field settings + * + * @param array $fields + * An array of field settings. + * + * @return $this + */ + public function setFields(array $fields); + + /** * Determines whether the tracker is valid. * * @return bool @@ -277,6 +295,24 @@ interface IndexInterface extends ConfigEntityInterface { public function getProcessorsByStage($stage, $only_enabled = TRUE); /** + * Sets this index's processor settings. + * + * @param array $processors + * An array of processors and it's settings. + * + * @return $this + */ + public function setProcessorSettings(array $processors); + + /** + * Retrieves this index's processor settings. + * + * @return array + * An array of processors and it's settings. + */ + public function getProcessorSettings(); + + /** * Preprocesses data items for indexing. * * Lets all enabled processors for this index preprocess the indexed data. @@ -319,7 +355,7 @@ interface IndexInterface extends ConfigEntityInterface { * An array of all known (or indexed, if $only_indexed is TRUE) fields for * this index, keyed by field identifier. */ - public function getFields($only_indexed = TRUE); + public function getCachedFields($only_indexed = TRUE); /** * Returns a list of all known fields of a specific datasource. diff --git a/src/Item/Field.php b/src/Item/Field.php index 0660ca7..3039aef 100644 --- a/src/Item/Field.php +++ b/src/Item/Field.php @@ -79,10 +79,10 @@ class Field implements \IteratorAggregate, FieldInterface { public function setType($type, $notify = FALSE) { $this->type = $type; if ($notify) { - $fields = $this->index->getOption('fields', array()); + $fields = $this->index->getFields(); if (isset($fields[$this->fieldIdentifier])) { $fields[$this->fieldIdentifier]['type'] = $type; - $this->index->setOption('fields', $fields); + $this->index->setFields($fields); } } return $this; @@ -140,7 +140,7 @@ class Field implements \IteratorAggregate, FieldInterface { */ public function isIndexed() { if (!isset($this->indexed)) { - $fields = $this->index->getOption('fields', array()); + $fields = $this->index->getFields(); $this->indexed = isset($fields[$this->fieldIdentifier]); } return $this->isIndexedLocked() || $this->indexed; @@ -152,7 +152,7 @@ class Field implements \IteratorAggregate, FieldInterface { public function setIndexed($indexed, $notify = FALSE) { $this->indexed = (bool) $indexed; if ($notify) { - $fields = $this->index->getOption('fields', array()); + $fields = $this->index->getFields(); if ($indexed) { $fields[$this->fieldIdentifier] = array('type' => $this->getType()); if (($boost = $this->getBoost()) != 1.0) { @@ -162,7 +162,7 @@ class Field implements \IteratorAggregate, FieldInterface { else { unset($fields[$this->fieldIdentifier]); } - $this->index->setOption('fields', $fields); + $this->index->setFields($fields); } return $this; } @@ -172,7 +172,7 @@ class Field implements \IteratorAggregate, FieldInterface { */ public function getBoost() { if (!isset($this->boost)) { - $fields = $this->index->getOption('fields', array()); + $fields = $this->index->getFields(); $this->boost = isset($fields[$this->fieldIdentifier]['boost']) ? (float) $fields[$this->fieldIdentifier]['boost'] : 1.0; } return $this->boost; @@ -185,7 +185,7 @@ class Field implements \IteratorAggregate, FieldInterface { $boost = (float) $boost; $this->boost = $boost; if ($notify) { - $fields = $this->index->getOption('fields', array()); + $fields = $this->index->getFields(); if (isset($fields[$this->fieldIdentifier])) { if ($boost != 1.0) { $fields[$this->fieldIdentifier]['boost'] = $boost; @@ -193,7 +193,7 @@ class Field implements \IteratorAggregate, FieldInterface { else { unset($fields[$this->fieldIdentifier]['boost']); } - $this->index->setOption('fields', $fields); + $this->index->setFields($fields); } } return $this; diff --git a/src/Plugin/search_api/datasource/ContentEntity.php b/src/Plugin/search_api/datasource/ContentEntity.php index 3c53b91..db1a129 100644 --- a/src/Plugin/search_api/datasource/ContentEntity.php +++ b/src/Plugin/search_api/datasource/ContentEntity.php @@ -868,7 +868,7 @@ class ContentEntity extends DatasourcePluginBase { // @todo This should definitely be the responsibility of the index class, // this is nothing specific to the datasource. $fields = array(); - foreach ($this->getIndex()->getFields() as $field) { + foreach ($this->getIndex()->getCachedFields() as $field) { if ($field->getDatasourceId() === $this->pluginId) { $fields[] = $field->getPropertyPath(); } diff --git a/src/Plugin/search_api/processor/AggregatedFields.php b/src/Plugin/search_api/processor/AggregatedFields.php index e981379..8dba920 100644 --- a/src/Plugin/search_api/processor/AggregatedFields.php +++ b/src/Plugin/search_api/processor/AggregatedFields.php @@ -105,7 +105,7 @@ class AggregatedFields extends ProcessorPluginBase { $types = $this->getTypes(); // Get the available fields for this index. - $fields = $this->index->getFields(FALSE); + $fields = $this->index->getCachedFields(FALSE); $field_options = array(); $field_properties = array(); @@ -399,7 +399,7 @@ class AggregatedFields extends ProcessorPluginBase { } $types = $this->getTypes('type'); if (isset($this->configuration['fields'])) { - $index_fields = $this->index->getFields(FALSE); + $index_fields = $this->index->getCachedFields(FALSE); foreach ($this->configuration['fields'] as $field_id => $field) { $definition = array( 'label' => $field['label'], diff --git a/src/Plugin/search_api/processor/Highlight.php b/src/Plugin/search_api/processor/Highlight.php index c6d154b..1d2372a 100644 --- a/src/Plugin/search_api/processor/Highlight.php +++ b/src/Plugin/search_api/processor/Highlight.php @@ -237,7 +237,7 @@ class Highlight extends ProcessorPluginBase { // All the index's fulltext fields, grouped by datasource. $fulltext_fields = array(); - foreach ($this->index->getFields() as $field_id => $field) { + foreach ($this->index->getCachedFields() as $field_id => $field) { if (Utility::isTextType($field->getType())) { $fulltext_fields[$field->getDatasourceId()][$field_id] = $field; } diff --git a/src/Plugin/views/argument/SearchApiFulltext.php b/src/Plugin/views/argument/SearchApiFulltext.php index 44b939c..d197998 100644 --- a/src/Plugin/views/argument/SearchApiFulltext.php +++ b/src/Plugin/views/argument/SearchApiFulltext.php @@ -118,7 +118,7 @@ class SearchApiFulltext extends SearchApiArgument { return array(); } - $fields_info = $index->getFields(); + $fields_info = $index->getCachedFields(); foreach ($index->getFulltextFields() as $field_id) { $fields[$field_id] = $fields_info[$field_id]->getPrefixedLabel(); } diff --git a/src/Plugin/views/argument/SearchApiMoreLikeThis.php b/src/Plugin/views/argument/SearchApiMoreLikeThis.php index f1da51f..4b777ba 100644 --- a/src/Plugin/views/argument/SearchApiMoreLikeThis.php +++ b/src/Plugin/views/argument/SearchApiMoreLikeThis.php @@ -79,7 +79,7 @@ class SearchApiMoreLikeThis extends SearchApiArgument { } $fields = isset($this->options['fields']) ? $this->options['fields'] : array(); if (!$fields) { - foreach ($this->query->getIndex()->getOption('fields', array()) as $key => $field) { + foreach ($this->query->getIndex()->getFields() as $key => $field) { $fields[] = $key; } } diff --git a/src/Plugin/views/filter/SearchApiFulltext.php b/src/Plugin/views/filter/SearchApiFulltext.php index f76c381..72d065f 100644 --- a/src/Plugin/views/filter/SearchApiFulltext.php +++ b/src/Plugin/views/filter/SearchApiFulltext.php @@ -233,9 +233,10 @@ class SearchApiFulltext extends SearchApiFilterText { */ protected function getFulltextFields() { $fields = array(); + /** @var \Drupal\search_api\IndexInterface $index */ $index = Index::load(substr($this->table, 17)); - $fields_info = $index->getFields(); + $fields_info = $index->getCachedFields(); foreach ($index->getFulltextFields() as $field_id) { $fields[$field_id] = $fields_info[$field_id]->getPrefixedLabel(); } diff --git a/src/Processor/FieldsProcessorPluginBase.php b/src/Processor/FieldsProcessorPluginBase.php index 340a4ab..b00b70d 100644 --- a/src/Processor/FieldsProcessorPluginBase.php +++ b/src/Processor/FieldsProcessorPluginBase.php @@ -47,7 +47,7 @@ abstract class FieldsProcessorPluginBase extends ProcessorPluginBase { public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); - $fields = $this->index->getFields(); + $fields = $this->index->getCachedFields(); $field_options = array(); $default_fields = array(); if (isset($this->configuration['fields'])) { @@ -223,7 +223,7 @@ abstract class FieldsProcessorPluginBase extends ProcessorPluginBase { * passed by reference. */ protected function processConditions(array &$conditions) { - $fields = $this->index->getFields(); + $fields = $this->index->getCachedFields(); foreach ($conditions as $key => &$condition) { if ($condition instanceof ConditionInterface) { $field = $condition->getField(); diff --git a/src/Tests/CustomDataTypesUnitTest.php b/src/Tests/CustomDataTypesUnitTest.php index d75662e..829dbb3 100644 --- a/src/Tests/CustomDataTypesUnitTest.php +++ b/src/Tests/CustomDataTypesUnitTest.php @@ -80,7 +80,7 @@ class CustomDataTypesUnitTest extends EntityUnitTestBase { */ public function testCustomDataTypes() { $original_value = $this->entities[1]->get('name')->value; - $original_type = $this->index->getFields()['entity:entity_test/name']->getType(); + $original_type = $this->index->getCachedFields()['entity:entity_test/name']->getType(); $item = $this->index->loadItem('entity:entity_test/1:en'); $item = Utility::createItemFromObject($this->index, $item, 'entity:entity_test/1:en'); @@ -95,7 +95,7 @@ class CustomDataTypesUnitTest extends EntityUnitTestBase { // Reset the fields on the item and change to the supported data type. $item->setFieldsExtracted(FALSE); $item->setFields(array()); - $this->index->getFields()['entity:entity_test/name']->setType('search_api_test_data_type'); + $this->index->getCachedFields()['entity:entity_test/name']->setType('search_api_test_data_type'); $name_field = $item->getField('entity:entity_test/name'); $processed_value = $name_field->getValues()[0]; @@ -107,7 +107,7 @@ class CustomDataTypesUnitTest extends EntityUnitTestBase { // Reset the fields on the item and change to the non-supported data type. $item->setFieldsExtracted(FALSE); $item->setFields(array()); - $this->index->getFields()['entity:entity_test/name']->setType('search_api_unsupported_test_data_type'); + $this->index->getCachedFields()['entity:entity_test/name']->setType('search_api_unsupported_test_data_type'); $name_field = $item->getField('entity:entity_test/name'); $processed_value = $name_field->getValues()[0]; @@ -119,7 +119,7 @@ class CustomDataTypesUnitTest extends EntityUnitTestBase { // Reset the fields on the item and change to the data altering data type. $item->setFieldsExtracted(FALSE); $item->setFields(array()); - $this->index->getFields()['entity:entity_test/name']->setType('search_api_altering_test_data_type'); + $this->index->getCachedFields()['entity:entity_test/name']->setType('search_api_altering_test_data_type'); $name_field = $item->getField('entity:entity_test/name'); $processed_value = $name_field->getValues()[0]; diff --git a/src/Tests/HooksTest.php b/src/Tests/HooksTest.php index bc66fff..09d79ca 100644 --- a/src/Tests/HooksTest.php +++ b/src/Tests/HooksTest.php @@ -17,7 +17,13 @@ class HooksTest extends WebTestBase { /** * {@inheritdoc} */ - public static $modules = array('node', 'search_api', 'search_api_test_backend', 'search_api_test_views', 'search_api_test_hooks'); + public static $modules = array( + 'node', + 'search_api', + 'search_api_test_backend', + 'search_api_test_views', + 'search_api_test_hooks', + ); /** * The id of the index. diff --git a/src/Tests/IntegrationTest.php b/src/Tests/IntegrationTest.php index 4d71336..2fcc19b 100644 --- a/src/Tests/IntegrationTest.php +++ b/src/Tests/IntegrationTest.php @@ -450,8 +450,10 @@ class IntegrationTest extends WebTestBase { $edit = array('fields[entity:node/field__field_][indexed]' => 1); $this->drupalGet($this->getIndexPath('fields')); + $this->assertHtmlEscaped($field_name); $this->drupalPostForm(NULL, $edit, $this->t('Save changes')); $this->assertHtmlEscaped($field_name); + $this->assertFieldChecked('edit-fields-entitynodefield-field-indexed'); $edit = array( 'datasource_configs[entity:node][default]' => 1, @@ -482,10 +484,14 @@ class IntegrationTest extends WebTestBase { $this->drupalPostForm($this->getIndexPath('fields'), $edit, $this->t('Save changes')); $this->assertText($this->t('The changes were successfully saved.')); + $this->assertFieldChecked('edit-fields-entitynodenid-indexed', 'nid is saved'); + $this->assertFieldChecked('edit-fields-entitynodetitle-indexed', 'title is saved'); + $this->assertFieldChecked('edit-fields-entitynodebody-indexed', 'body is saved'); + $this->indexStorage->resetCache(array($this->indexId)); /** @var $index \Drupal\search_api\IndexInterface */ $index = $this->indexStorage->load($this->indexId); - $fields = $index->getFields(FALSE); + $fields = $index->getCachedFields(FALSE); $this->assertEqual($fields['entity:node/nid']->isIndexed(), $edit['fields[entity:node/nid][indexed]'], 'nid field is indexed.'); $this->assertEqual($fields['entity:node/title']->isIndexed(), $edit['fields[entity:node/title][indexed]'], 'title field is indexed.'); @@ -532,7 +538,7 @@ class IntegrationTest extends WebTestBase { $this->indexStorage->resetCache(array($this->indexId)); /** @var $index \Drupal\search_api\IndexInterface */ $index = $this->indexStorage->load($this->indexId); - $fields = $index->getFields(); + $fields = $index->getCachedFields(); $this->assertTrue(!isset($fields['entity:node/body']), 'The body field has been removed from the index.'); } diff --git a/src/Tests/Processor/ProcessorIntegrationTest.php b/src/Tests/Processor/ProcessorIntegrationTest.php index ac22441..d922462 100644 --- a/src/Tests/Processor/ProcessorIntegrationTest.php +++ b/src/Tests/Processor/ProcessorIntegrationTest.php @@ -134,10 +134,10 @@ class ProcessorIntegrationTest extends WebTestBase { */ public function checkLanguageIntegration() { $index = $this->loadIndex(); - $processors = $index->getOption('processors', array()); + $processors = $index->getProcessorSettings(); $this->assertTrue(!empty($processors['language']), 'The "language" processor is enabled by default.'); unset($processors['language']); - $index->setOption('processors', $processors)->save(); + $index->setProcessorSettings($processors)->save(); $processors = $this->loadIndex()->getProcessors(); $this->assertTrue(!empty($processors['language']), 'The "language" processor cannot be disabled.'); } diff --git a/src/Tests/Processor/ProcessorTestBase.php b/src/Tests/Processor/ProcessorTestBase.php index 64f9c22..93ea110 100644 --- a/src/Tests/Processor/ProcessorTestBase.php +++ b/src/Tests/Processor/ProcessorTestBase.php @@ -92,7 +92,7 @@ abstract class ProcessorTestBase extends EntityUnitTestBase { 'tracker' => 'default', )); $this->index->setServer($this->server); - $this->index->setOption('fields', array( + $this->index->setFields(array( 'entity:comment/subject' => array( 'type' => 'text', ), @@ -101,7 +101,7 @@ abstract class ProcessorTestBase extends EntityUnitTestBase { ), )); if ($processor) { - $this->index->setOption('processors', array( + $this->index->setProcessorSettings(array( $processor => array( 'processor_id' => $processor, 'weights' => array(), diff --git a/tests/search_api_test_db/config/install/search_api.index.database_search_index.yml b/tests/search_api_test_db/config/install/search_api.index.database_search_index.yml index cfcf924..5bd2ee6 100644 --- a/tests/search_api_test_db/config/install/search_api.index.database_search_index.yml +++ b/tests/search_api_test_db/config/install/search_api.index.database_search_index.yml @@ -2,31 +2,31 @@ id: database_search_index name: 'Test index' description: 'An index used for testing' read_only: false +processors: + language: + processor_id: language + weights: + preprocess_index: -50 + settings: { } +fields: + 'entity:entity_test/id': + type: integer + 'entity:entity_test/name': + type: text + boost: 5.0 + 'entity:entity_test/body': + type: text + 'entity:entity_test/type': + type: string + 'entity:entity_test/keywords': + type: string + 'entity:entity_test/category': + type: string + search_api_language: + type: string options: cron_limit: -1 index_directly: false - fields: - 'entity:entity_test/id': - type: integer - 'entity:entity_test/name': - type: text - boost: 5.0 - 'entity:entity_test/body': - type: text - 'entity:entity_test/type': - type: string - 'entity:entity_test/keywords': - type: string - 'entity:entity_test/category': - type: string - search_api_language: - type: string - processors: - language: - processor_id: language - weights: - preprocess_index: -50 - settings: { } datasources: - 'entity:entity_test' datasource_configs: { } diff --git a/tests/search_api_test_hooks/search_api_test_hooks.module b/tests/search_api_test_hooks/search_api_test_hooks.module index d400acd..4475cd1 100644 --- a/tests/search_api_test_hooks/search_api_test_hooks.module +++ b/tests/search_api_test_hooks/search_api_test_hooks.module @@ -85,7 +85,7 @@ function search_api_test_hooks_search_api_field_type_mapping_alter(array &$mappi */ function search_api_test_hooks_search_api_query_andrew_hill_alter(\Drupal\search_api\Query\QueryInterface &$query) { // Exclude the node with ID 2 from the search results. - $fields = $query->getIndex()->getFields(); + $fields = $query->getIndex()->getCachedFields(); foreach ($query->getIndex()->getDatasources() as $datasource_id => $datasource) { if ($datasource->getEntityTypeId() == 'node') { $field = \Drupal\search_api\Utility::createCombinedId($datasource_id, 'nid'); diff --git a/tests/src/Unit/Plugin/Processor/AggregatedFieldTest.php b/tests/src/Unit/Plugin/Processor/AggregatedFieldTest.php index 0cc675b..085e541 100644 --- a/tests/src/Unit/Plugin/Processor/AggregatedFieldTest.php +++ b/tests/src/Unit/Plugin/Processor/AggregatedFieldTest.php @@ -441,7 +441,7 @@ class AggregatedFieldTest extends UnitTestCase { $index_fields[$field_id] = $field_object; } $this->index->expects($this->any()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue($index_fields)); $configuration['fields'] = array( diff --git a/tests/src/Unit/Plugin/Processor/FieldsProcessorPluginBaseTest.php b/tests/src/Unit/Plugin/Processor/FieldsProcessorPluginBaseTest.php index cd3fd8b..1fd7df6 100644 --- a/tests/src/Unit/Plugin/Processor/FieldsProcessorPluginBaseTest.php +++ b/tests/src/Unit/Plugin/Processor/FieldsProcessorPluginBaseTest.php @@ -50,7 +50,7 @@ class FieldsProcessorPluginBaseTest extends UnitTestCase { ->will($this->returnValue(TRUE)); $fields = $this->getTestItem()[$this->itemIds[0]]->getFields(); $this->index->expects($this->any()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue($fields)); $this->processor = new TestFieldsProcessorPlugin(array('index' => $this->index), '', array()); diff --git a/tests/src/Unit/Plugin/Processor/HighlightTest.php b/tests/src/Unit/Plugin/Processor/HighlightTest.php index 2cc02fa..b2fe480 100644 --- a/tests/src/Unit/Plugin/Processor/HighlightTest.php +++ b/tests/src/Unit/Plugin/Processor/HighlightTest.php @@ -119,7 +119,7 @@ class HighlightTest extends UnitTestCase { $field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $field))); $this->processor->setIndex($index); @@ -165,7 +165,7 @@ class HighlightTest extends UnitTestCase { $field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $field))); $this->processor->setIndex($index); @@ -211,7 +211,7 @@ class HighlightTest extends UnitTestCase { $field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $field))); $this->processor->setIndex($index); @@ -255,7 +255,7 @@ class HighlightTest extends UnitTestCase { $field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $field))); $this->processor->setIndex($index); @@ -304,7 +304,7 @@ class HighlightTest extends UnitTestCase { $field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $field))); $this->processor->setIndex($index); @@ -350,7 +350,7 @@ class HighlightTest extends UnitTestCase { $field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $field))); $this->processor->setIndex($index); @@ -398,7 +398,7 @@ class HighlightTest extends UnitTestCase { $field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $field))); $this->processor->setIndex($index); @@ -446,7 +446,7 @@ class HighlightTest extends UnitTestCase { $field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $field))); $this->processor->setIndex($index); @@ -506,7 +506,7 @@ class HighlightTest extends UnitTestCase { $body_field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $body_field))); $this->processor->setIndex($index); @@ -556,7 +556,7 @@ class HighlightTest extends UnitTestCase { $title_field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $body_field, $title_field_id => $title_field))); $this->processor->setIndex($index); @@ -610,7 +610,7 @@ class HighlightTest extends UnitTestCase { $body_field->setType('text'); $index->expects($this->atLeastOnce()) - ->method('getFields') + ->method('getCachedFields') ->will($this->returnValue(array($body_field_id => $body_field))); $this->processor->setIndex($index);