function search_api_update_7105 in Search API 7
Remove all empty aggregated fields for the search_api_alter_add_fulltext data alterations.
File
- ./
search_api.install, line 692 - Install, update and uninstall functions for the Search API module.
Code
function search_api_update_7105() {
$rows = db_select('search_api_index', 'i')
->fields('i', array(
'id',
'options',
))
->execute()
->fetchAllKeyed();
foreach ($rows as $id => $options) {
$opt = unserialize($options);
if (isset($opt['data_alter_callbacks']['search_api_alter_add_fulltext']['settings']['fields'])) {
foreach ($opt['data_alter_callbacks']['search_api_alter_add_fulltext']['settings']['fields'] as $name => $field) {
if (empty($field['name']) || empty($field['fields'])) {
unset($opt['data_alter_callbacks']['search_api_alter_add_fulltext']['settings']['fields'][$name]);
}
}
}
$opt = serialize($opt);
if ($opt != $options) {
db_update('search_api_index')
->fields(array(
'options' => $opt,
))
->condition('id', $id)
->execute();
}
}
}