upadted to 1.8

This commit is contained in:
Bachir Soussi Chiadmi
2013-09-26 15:49:26 +02:00
parent e0ae80791b
commit 128640cd15
52 changed files with 2604 additions and 1015 deletions

View File

@@ -153,6 +153,42 @@ function search_api_menu() {
return $items;
}
/**
* Implements hook_hook_info().
*/
function search_api_hook_info() {
// We use the same group for all hooks, so save code lines.
$hook_info = array(
'group' => 'search_api',
);
return array(
'search_api_service_info' => $hook_info,
'search_api_service_info_alter' => $hook_info,
'search_api_item_type_info' => $hook_info,
'search_api_item_type_info_alter' => $hook_info,
'search_api_data_type_info' => $hook_info,
'search_api_data_type_info_alter' => $hook_info,
'search_api_alter_callback_info' => $hook_info,
'search_api_processor_info' => $hook_info,
'search_api_index_items_alter' => $hook_info,
'search_api_items_indexed' => $hook_info,
'search_api_query_alter' => $hook_info,
'search_api_server_load' => $hook_info,
'search_api_server_insert' => $hook_info,
'search_api_server_update' => $hook_info,
'search_api_server_delete' => $hook_info,
'default_search_api_server' => $hook_info,
'default_search_api_server_alter' => $hook_info,
'search_api_index_load' => $hook_info,
'search_api_index_insert' => $hook_info,
'search_api_index_update' => $hook_info,
'search_api_index_reindex' => $hook_info,
'search_api_index_delete' => $hook_info,
'default_search_api_index' => $hook_info,
'default_search_api_index_alter' => $hook_info,
);
}
/**
* Implements hook_theme().
*/
@@ -227,7 +263,9 @@ function search_api_cron() {
if ($limit) {
try {
$task = array('index' => $index->machine_name);
$ids = search_api_get_items_to_index($index, -1);
// Fetch items to index, do not fetch more than the configured amount
// of batches to be created per cron run to avoid timeouts.
$ids = search_api_get_items_to_index($index, $limit > 0 ? $limit * variable_get('search_api_batch_per_cron', 10) : -1);
if (!$ids) {
continue;
}
@@ -417,6 +455,15 @@ function search_api_entity_property_info() {
* Calls the postCreate() method for the server.
*/
function search_api_search_api_server_insert(SearchApiServer $server) {
// Check whether this is actually part of a revert.
$reverts = &drupal_static('search_api_search_api_server_delete', array());
if (isset($reverts[$server->machine_name])) {
$server->original = $reverts[$server->machine_name];
unset($reverts[$server->machine_name]);
search_api_search_api_server_update($server);
unset($server->original);
return;
}
$server->postCreate();
}
@@ -432,7 +479,7 @@ function search_api_search_api_server_update(SearchApiServer $server) {
$index->reindex();
}
}
if ($server->enabled != $server->original->enabled) {
if (!empty($server->original) && $server->enabled != $server->original->enabled) {
if ($server->enabled) {
// Were there any changes in the server's indexes while it was disabled?
$tasks = variable_get('search_api_tasks', array());
@@ -448,7 +495,8 @@ function search_api_search_api_server_update(SearchApiServer $server) {
$server->deleteItems('all', $index);
break;
case 'clear all':
// Would normally be used with a fake index ID of "", since it doesn't matter.
// Would normally be used with a fake index ID of "", since it
// doesn't matter.
$server->deleteItems('all');
break;
case 'fields':
@@ -488,14 +536,16 @@ function search_api_search_api_server_update(SearchApiServer $server) {
* Calls the preDelete() method for the server.
*/
function search_api_search_api_server_delete(SearchApiServer $server) {
$server->preDelete();
// Only react on real delete, not revert.
if (!$server->hasStatus(ENTITY_IN_CODE)) {
foreach (search_api_index_load_multiple(FALSE, array('server' => $server->machine_name)) as $index) {
$index->update(array('server' => NULL, 'enabled' => FALSE));
}
if ($server->hasStatus(ENTITY_IN_CODE)) {
$reverts = &drupal_static(__FUNCTION__, array());
$reverts[$server->machine_name] = $server;
return;
}
$server->preDelete();
foreach (search_api_index_load_multiple(FALSE, array('server' => $server->machine_name)) as $index) {
$index->update(array('server' => NULL, 'enabled' => FALSE));
}
$tasks = variable_get('search_api_tasks', array());
@@ -510,6 +560,16 @@ function search_api_search_api_server_delete(SearchApiServer $server) {
* the index is enabled).
*/
function search_api_search_api_index_insert(SearchApiIndex $index) {
// Check whether this is actually part of a revert.
$reverts = &drupal_static('search_api_search_api_index_delete', array());
if (isset($reverts[$index->machine_name])) {
$index->original = $reverts[$index->machine_name];
unset($reverts[$index->machine_name]);
search_api_search_api_index_update($index);
unset($index->original);
return;
}
$index->postCreate();
}
@@ -517,6 +577,9 @@ function search_api_search_api_index_insert(SearchApiIndex $index) {
* Implements hook_search_api_index_update().
*/
function search_api_search_api_index_update(SearchApiIndex $index) {
// Call the datasource update function with the table this module provides.
search_api_index_update_datasource($index, 'search_api_item');
// If the server was changed, we have to call the appropriate service class
// hook methods.
if ($index->server != $index->original->server) {
@@ -552,22 +615,33 @@ function search_api_search_api_index_update(SearchApiIndex $index) {
}
}
// We also have to re-index all content
// We also have to re-index all content.
_search_api_index_reindex($index);
}
// If the fields were changed, call the appropriate service class hook method
// and re-index the content, if necessary.
// and re-index the content, if necessary. Also, clear the fields cache.
$old_fields = $index->original->options + array('fields' => array());
$old_fields = $old_fields['fields'];
$new_fields = $index->options + array('fields' => array());
$new_fields = $new_fields['fields'];
if ($old_fields != $new_fields) {
cache_clear_all($index->getCacheId(), 'cache', TRUE);
if ($index->server && $index->server()->fieldsUpdated($index)) {
_search_api_index_reindex($index);
}
}
// If additional fields changed, clear the index's specific cache which
// includes them.
$old_additional = $index->original->options + array('additional fields' => array());
$old_additional = $old_additional['additional fields'];
$new_additional = $index->options + array('additional fields' => array());
$new_additional = $new_additional['additional fields'];
if ($old_additional != $new_additional) {
cache_clear_all($index->getCacheId() . '-0-1', 'cache');
}
// If the index's enabled or read-only status is being changed, queue or
// dequeue items for indexing.
if (!$index->read_only && $index->enabled != $index->original->enabled) {
@@ -603,6 +677,13 @@ function search_api_search_api_index_update(SearchApiIndex $index) {
* Removes all data for indexes not available any more.
*/
function search_api_search_api_index_delete(SearchApiIndex $index) {
// Only react on real delete, not revert.
if ($index->hasStatus(ENTITY_IN_CODE)) {
$reverts = &drupal_static(__FUNCTION__, array());
$reverts[$index->machine_name] = $index;
return;
}
cache_clear_all($index->getCacheId(''), 'cache', TRUE);
$index->postDelete();
}
@@ -642,6 +723,72 @@ function search_api_features_export_alter(&$export, $module_name) {
}
}
/**
* Implements hook_system_info_alter().
*
* Checks if the module provides any search item types or service classes. If it
* does, and there are search indexes using those item types, respectively
* servers using those service classes, the module is set to "required".
*
* Heavily borrowed from field_system_info_alter().
*
* @see hook_search_api_item_type_info()
*/
function search_api_system_info_alter(&$info, $file, $type) {
if ($type != 'module' || $file->name == 'search_api') {
return;
}
// Check for defined item types.
if (module_hook($file->name, 'search_api_item_type_info')) {
$types = array();
foreach (search_api_get_item_type_info() as $type => $type_info) {
if ($type_info['module'] == $file->name) {
$types[] = $type;
}
}
if ($types) {
$sql = 'SELECT machine_name, name FROM {search_api_index} WHERE item_type IN (:types)';
$indexes = db_query($sql, array(':types' => $types))->fetchAllKeyed();
if ($indexes) {
$info['required'] = TRUE;
$links = array();
foreach ($indexes as $id => $name) {
$links[] = l($name, "admin/config/search/search_api/index/$id");
}
$args = array('!indexes' => implode(', ', $links));
$info['explanation'] = format_plural(count($indexes), 'Item type in use by the following index: !indexes.', 'Item type(s) in use by the following indexes: !indexes.', $args);
}
}
}
// Check for defined service classes.
if (module_hook($file->name, 'search_api_service_info')) {
$classes = array();
foreach (search_api_get_service_info() as $class => $class_info) {
if ($class_info['module'] == $file->name) {
$classes[] = $class;
}
}
if ($classes) {
$sql = 'SELECT machine_name, name FROM {search_api_server} WHERE class IN (:classes)';
$servers = db_query($sql, array(':classes' => $classes))->fetchAllKeyed();
if ($servers) {
$info['required'] = TRUE;
$links = array();
foreach ($servers as $id => $name) {
$links[] = l($name, "admin/config/search/search_api/server/$id");
}
$args = array('!servers' => implode(', ', $links));
$explanation = format_plural(count($servers), 'Service class in use by the following server: !servers.', 'Service class(es) in use by the following servers: !servers.', $args);
$info['explanation'] = (!empty($info['explanation']) ? $info['explanation'] . ' ' : '') . $explanation;
}
}
}
}
/**
* Implements hook_entity_insert().
*
@@ -712,6 +859,32 @@ function search_api_entity_delete($entity, $type) {
}
}
/**
* Implements hook_field_update_field().
*
* Recalculates fields settings if the cardinality of the field has changed from
* or to 1.
*/
function search_api_field_update_field($field, $prior_field, $has_data) {
$before = $prior_field['cardinality'];
$after = $field['cardinality'];
if ($before != $after && ($before == 1 || $after == 1)) {
// Unfortunately, we cannot call this right away since the field information
// is only stored after the hook is called.
drupal_register_shutdown_function('search_api_index_recalculate_fields');
}
}
/**
* Implements hook_flush_caches().
*
* Recalculates fields settings in case the schema (in most cases: the
* multiplicity) of a property has changed.
*/
function search_api_flush_caches() {
search_api_index_recalculate_fields();
}
/**
* Implements hook_search_api_item_type_info().
*
@@ -725,6 +898,7 @@ function search_api_search_api_item_type_info() {
$types[$type] = array(
'name' => $info['label'],
'datasource controller' => 'SearchApiEntityDataSourceController',
'entity_type' => $type,
);
}
}
@@ -736,18 +910,20 @@ function search_api_search_api_item_type_info() {
* Implements hook_modules_enabled().
*/
function search_api_modules_enabled(array $modules) {
// New modules might offer additional entity types, invalidating the cached
// item type information.
// New modules might offer additional item types or service classes,
// invalidating the cached information.
drupal_static_reset('search_api_get_item_type_info');
drupal_static_reset('search_api_get_service_info');
}
/**
* Implements hook_modules_disabled().
*/
function search_api_modules_disabled(array $modules) {
// The disabled modules might have offered entity types, which are now
// invalid. Therefore, clear the cached item type informaiton.
// The disabled modules might have offered item types or service classes,
// invalidating the cached information.
drupal_static_reset('search_api_get_item_type_info');
drupal_static_reset('search_api_get_service_info');
}
/**
@@ -761,6 +937,13 @@ function search_api_search_api_alter_callback_info() {
// Filters should be executed first.
'weight' => -10,
);
$callbacks['search_api_alter_role_filter'] = array(
'name' => t('Role filter'),
'description' => t('Exclude users from indexing based on their role.'),
'class' => 'SearchApiAlterRoleFilter',
// Filters should be executed first.
'weight' => -10,
);
$callbacks['search_api_alter_add_url'] = array(
'name' => t('URL field'),
'description' => t("Adds the item's URL to the indexed data."),
@@ -806,7 +989,7 @@ function search_api_search_api_alter_callback_info() {
function search_api_search_api_processor_info() {
$processors['search_api_case_ignore'] = array(
'name' => t('Ignore case'),
'description' => t('This processor will make searches case-insensitive for all fulltext fields (and, optionally, also for filters on string fields).'),
'description' => t('This processor will make searches case-insensitive for fulltext or string fields.'),
'class' => 'SearchApiIgnoreCase',
);
$processors['search_api_html_filter'] = array(
@@ -817,6 +1000,14 @@ function search_api_search_api_processor_info() {
'class' => 'SearchApiHtmlFilter',
'weight' => 10,
);
if (module_exists('transliteration')) {
$processors['search_api_transliteration'] = array(
'name' => t('Transliteration'),
'description' => t('This processor will make searches insensitive to accents and other non-ASCII characters.'),
'class' => 'SearchApiTransliteration',
'weight' => 15,
);
}
$processors['search_api_tokenizer'] = array(
'name' => t('Tokenizer'),
'description' => t('Tokenizes fulltext data by stripping whitespace. ' .
@@ -832,6 +1023,12 @@ function search_api_search_api_processor_info() {
'class' => 'SearchApiStopWords',
'weight' => 30,
);
$processors['search_api_highlighting'] = array(
'name' => t('Highlighting'),
'description' => t('Adds highlighting for search results.'),
'class' => 'SearchApiHighlight',
'weight' => 35,
);
return $processors;
}
@@ -859,7 +1056,7 @@ function search_api_track_item_insert($type, array $item_ids) {
foreach ($indexes as $index) {
if (!empty($index->options['index_directly'])) {
$indexed = search_api_index_specific_items_delayed($index, $item_ids);
search_api_index_specific_items_delayed($index, $item_ids);
}
}
}
@@ -922,6 +1119,7 @@ function search_api_track_item_queued(SearchApiIndex $index, array $item_ids) {
*/
function search_api_track_item_indexed(SearchApiIndex $index, array $item_ids) {
$index->datasource()->trackItemIndexed($item_ids, $index);
module_invoke_all('search_api_items_indexed', $index, $item_ids);
}
/**
@@ -964,6 +1162,83 @@ function search_api_track_item_delete($type, array $item_ids) {
}
}
/**
* Recalculates the saved fields of an index.
*
* This is mostly necessary when the multiplicity of the underlying properties
* change. The method will re-examine the data structure of the entities in each
* index and, if a discrepancy is spotted, re-save that index with updated
* fields options (thus, of course, also triggering a re-indexing operation).
*
* @param array|false $indexes
* An array of SearchApiIndex objects on which to perform the operation, or
* FALSE to perform it on all indexes.
*/
function search_api_index_recalculate_fields($indexes = FALSE) {
if (!is_array($indexes)) {
$indexes = search_api_index_load_multiple(FALSE);
}
$stored_keys = drupal_map_assoc(array('type', 'entity_type', 'real_type', 'boost'));
foreach ($indexes as $index) {
if (empty($index->options['fields'])) {
continue;
}
// We have to clear the cache, both static and stored, before using
// getFields(). Otherwise, we'd just use the stale data which the fields
// options are probably already based on.
cache_clear_all($index->getCacheId() . '-1-0', 'cache');
$index->resetCaches();
// getFields() automatically uses the actual data types to correct possible
// stale data.
$fields = $index->getFields();
foreach ($fields as $key => $field) {
$fields[$key] = array_intersect_key($field, $stored_keys);
if (isset($fields[$key]['boost']) && $fields[$key]['boost'] == '1.0') {
unset($fields[$key]['boost']);
}
}
// Use a more accurate method of determining if the fields settings are
// equal to avoid needlessly re-indexing the whole index.
if (!_search_api_settings_equals($fields, $index->options['fields'])) {
$options = $index->options;
$options['fields'] = $fields;
$index->update(array('options' => $options));
}
}
}
/**
* Test two setting arrays (or individual settings) for equality.
*
* While a simple == also works in some cases, this function takes into account
* that the order of keys (usually) doesn't matter in settings arrays.
*
* @param mixed $setting1
* The first setting (array).
* @param mixed $setting2
* The second setting (array).
*
* @return bool
* TRUE if both settings are identical, FALSE otherwise.
*/
function _search_api_settings_equals($setting1, $setting2) {
if (!is_array($setting1) || !is_array($setting2)) {
return $setting1 == $setting2;
}
foreach ($setting1 as $key => $value) {
if (!array_key_exists($key, $setting2)) {
return FALSE;
}
if (!_search_api_settings_equals($value, $setting2[$key])) {
return FALSE;
}
unset($setting2[$key]);
}
// If any keys weren't unset previously, they are not present in $setting1 and
// the two are different.
return !$setting2;
}
/**
* Indexes items for the specified index. Only items marked as changed are
* indexed, in their order of change (if known).
@@ -1035,7 +1310,21 @@ function search_api_index_specific_items(SearchApiIndex $index, array $ids) {
// Clone items because data alterations may alter them.
$cloned_items = array();
foreach ($items as $id => $item) {
$cloned_items[$id] = clone $item;
if (is_object($item)) {
$cloned_items[$id] = clone $item;
}
else {
// Normally, items that can't be loaded shouldn't be returned by
// entity_load (and other loadItems() implementations). Therefore, this is
// an extremely rare case, which seems to happen during installation for
// some specific setups.
$type = search_api_get_item_type_info($index->item_type);
$type = $type ? $type['name'] : $index->item_type;
watchdog('search_api',
"Error during indexing: invalid item loaded for @type with ID @id.",
array('@id' => $id, '@type' => $type),
WATCHDOG_WARNING);
}
}
$indexed = $items ? $index->index($cloned_items) : array();
if ($indexed) {
@@ -1259,22 +1548,48 @@ function search_api_get_data_type_info($type = NULL) {
*
* @see hook_search_api_service_info()
*
* @param $id
* @param string|null $id
* The ID of the service info to retrieve.
*
* @return array
* If $id was not specified, an array of all available service classes.
* Otherwise, either the service info with the specified id (if it exists),
* or NULL.
* or NULL. Service class information is formatted as specified by
* hook_search_api_service_info(), with the addition of a "module" key
* specifying the module that adds a certain class.
*/
function search_api_get_service_info($id = NULL) {
$services = &drupal_static(__FUNCTION__);
if (!isset($services)) {
$services = module_invoke_all('search_api_service_info');
// Inlined version of module_invoke_all() to add "module" keys.
$services = array();
foreach (module_implements('search_api_service_info') as $module) {
$function = $module . '_search_api_service_info';
if (function_exists($function)) {
$new_services = $function();
if (isset($new_services) && is_array($new_services)) {
foreach ($new_services as $service => $info) {
$new_services[$service] += array('module' => $module);
}
}
$services += $new_services;
}
}
// Allow other modules to alter definitions
drupal_alter('search_api_service_info', $services);
// Same for drupal_alter().
foreach (module_implements('search_api_service_info_alter') as $module) {
$function = $module . '_search_api_service_info_alter';
if (function_exists($function)) {
$old = $services;
$function($services);
if ($new_services = array_diff_key($services, $old)) {
foreach ($new_services as $service => $info) {
$services[$service] += array('module' => $module);
}
}
}
}
}
if (isset($id)) {
@@ -1286,15 +1601,15 @@ function search_api_get_service_info($id = NULL) {
/**
* Returns information for either all item types, or a specific one.
*
* @param $type
* @param string|null $type
* If set, the item type whose information should be returned.
*
* @return
* @return array|null
* If $type is given, either an array containing the information of that item
* type, or NULL if it is unknown. Otherwise, an array keyed by type IDs
* containing the information for all item types. Item type information is
* formatted as specified by hook_search_api_item_type_info(), and has all
* optional fields filled with the defaults.
* formatted as specified by hook_search_api_item_type_info(), with the
* addition of a "module" key specifying the module that adds a certain type.
*
* @see hook_search_api_item_type_info()
*/
@@ -1302,8 +1617,34 @@ function search_api_get_item_type_info($type = NULL) {
$types = &drupal_static(__FUNCTION__);
if (!isset($types)) {
$types = module_invoke_all('search_api_item_type_info');
drupal_alter('search_api_item_type_info', $types);
// Inlined version of module_invoke_all() to add "module" keys.
$types = array();
foreach (module_implements('search_api_item_type_info') as $module) {
$function = $module . '_search_api_item_type_info';
if (function_exists($function)) {
$new_types = $function();
if (isset($new_types) && is_array($new_types)) {
foreach ($new_types as $id => $info) {
$new_types[$id] += array('module' => $module);
}
}
$types += $new_types;
}
}
// Same for drupal_alter().
foreach (module_implements('search_api_item_type_info_alter') as $module) {
$function = $module . '_search_api_item_type_info_alter';
if (function_exists($function)) {
$old = $types;
$function($types);
if ($new_types = array_diff_key($types, $old)) {
foreach ($new_types as $id => $info) {
$types[$id] += array('module' => $module);
}
}
}
}
}
if (isset($type)) {
@@ -1444,7 +1785,7 @@ function _search_api_query_add_node_access($account, SearchApiQueryInterface $qu
$query->filter($filter);
}
else {
// $query->condition('status', NODE_PUBLISHED);
$query->condition('status', NODE_PUBLISHED);
}
// Filter by node access grants.
$filter = $query->createFilter('OR');
@@ -1552,6 +1893,38 @@ function search_api_extract_inner_type($type) {
return $type;
}
/**
* Helper function for reacting to index updates with regards to the datasource.
*
* When an overridden index is reverted, its numerical ID will sometimes change.
* Since the default datasource implementation uses that for referencing
* indexes, the index ID in the items table must be updated accordingly. This is
* implemented in this function.
*
* Modules implementing other datasource controllers, that use a table other
* than {search_api_item}, can use this function, too. It should be called
* uncoditionally in a hook_search_api_index_update() implementation. If this
* function isn't used, similar code should be added there.
*
* However, note that this is only necessary (and this function should only be
* called) if the indexes are referenced by numerical ID in the items table.
*
* @param SearchApiIndex $index
* The index that was changed.
* @param string $table
* The table containing items information, analogous to {search_api_item}.
* @param string $column
* The column in $table that holds the index's numerical ID.
*/
function search_api_index_update_datasource(SearchApiIndex $index, $table, $column = 'index_id') {
if ($index->id != $index->original->id) {
db_update($table)
->fields(array($column => $index->id))
->condition($column, $index->original->id)
->execute();
}
}
/**
* Utility function for extracting specific fields from an EntityMetadataWrapper
* object.
@@ -1605,26 +1978,28 @@ function search_api_extract_fields(EntityMetadataWrapper $wrapper, array $fields
// Set "defaults" in case an error occurs later.
$info['value'] = NULL;
$info['original_type'] = $info['type'];
try {
$info['value'] = $wrapper->$field->value($value_options);
// For fulltext fields with options, also include the option labels.
if (search_api_is_text_type($info['type']) && $wrapper->$field->optionsList('view')) {
_search_api_add_option_values($info['value'], $wrapper->$field->optionsList('view'));
if (isset($wrapper->$field)) {
try {
$info['value'] = $wrapper->$field->value($value_options);
// For fulltext fields with options, also include the option labels.
if (search_api_is_text_type($info['type']) && $wrapper->$field->optionsList('view')) {
_search_api_add_option_values($info['value'], $wrapper->$field->optionsList('view'));
}
$property_info = $wrapper->$field->info();
$info['original_type'] = $property_info['type'];
// For entities, we extract the entity ID instead of the whole object.
// @todo Use 'identifier' => TRUE instead of always loading the object.
$t = search_api_extract_inner_type($property_info['type']);
if (isset($entity_infos[$t])) {
// If no object is set, set this field to NULL.
$info['value'] = $info['value'] ? _search_api_extract_entity_value($wrapper->$field, search_api_is_text_type($info['type'])) : NULL;
}
}
$property_info = $wrapper->$field->info();
$info['original_type'] = $property_info['type'];
// For entities, we extract the entity ID instead of the whole object.
// @todo Use 'identifier' => TRUE instead of always loading the object.
$t = search_api_extract_inner_type($property_info['type']);
if (isset($entity_infos[$t])) {
// If no object is set, set this field to NULL.
$info['value'] = $info['value'] ? _search_api_extract_entity_value($wrapper->$field, search_api_is_text_type($info['type'])) : NULL;
catch (EntityMetadataWrapperException $e) {
// This might happen for entity-typed properties that are NULL, e.g.,
// for comments without parent.
}
}
catch (EntityMetadataWrapperException $e) {
// This might happen for entity-typed properties that are NULL, e.g.,
// for comments without parent.
}
}
else {
list($prefix, $key) = explode(':', $field, 2);
@@ -1636,10 +2011,6 @@ function search_api_extract_fields(EntityMetadataWrapper $wrapper, array $fields
foreach ($nested as $prefix => $nested_fields) {
if (isset($wrapper->$prefix)) {
$nested_fields = search_api_extract_fields($wrapper->$prefix, $nested_fields, $value_options);
# http://drupal.org/node/1873910#comment-6876200
// $subwrapper = $wrapper->$prefix;
// $subwrapper->language( $wrapper->language->value() );
// $nested_fields = search_api_extract_fields($subwrapper, $nested_fields, $value_options);
foreach ($nested_fields as $field => $info) {
$fields["$prefix:$field"] = $info;
}
@@ -1716,19 +2087,20 @@ function search_api_server_load($id, $reset = FALSE) {
*
* @see entity_load()
*
* @param $ids
* @param array|false $ids
* An array of server IDs or machine names, or FALSE to load all servers.
* @param $conditions
* @param array $conditions
* An array of conditions on the {search_api_server} table in the form
* 'field' => $value.
* @param $reset
* @param bool $reset
* Whether to reset the internal entity_load cache.
*
* @return array
* An array of server objects keyed by machine name.
*/
function search_api_server_load_multiple($ids = array(), $conditions = array(), $reset = FALSE) {
return entity_load_multiple_by_name('search_api_server', $ids, $conditions, $reset);
$servers = entity_load('search_api_server', $ids, $conditions, $reset);
return entity_key_array_by_property($servers, 'machine_name');
}
/**
@@ -1872,12 +2244,12 @@ function search_api_index_load($id, $reset = FALSE) {
*
* @see entity_load()
*
* @param $ids
* @param array|false $ids
* An array of index IDs or machine names, or FALSE to load all indexes.
* @param $conditions
* @param array $conditions
* An array of conditions on the {search_api_index} table in the form
* 'field' => $value.
* @param $reset
* @param bool $reset
* Whether to reset the internal entity_load cache.
*
* @return array
@@ -1887,7 +2259,8 @@ function search_api_index_load_multiple($ids = array(), $conditions = array(), $
// This line is a workaround for a weird PDO bug in PHP 5.2.
// See http://drupal.org/node/889286.
new SearchApiIndex();
return entity_load_multiple_by_name('search_api_index', $ids, $conditions, $reset);
$indexes = entity_load('search_api_index', $ids, $conditions, $reset);
return entity_key_array_by_property($indexes, 'machine_name');
}
/**