You are here

function current_search_update_7101 in Facet API 7

Same name and namespace in other branches
  1. 7.2 contrib/current_search/current_search.install \current_search_update_7101()

Update the structure of saved settings objects.

File

contrib/current_search/current_search.install, line 92
Install, update, and uninstall functions for the Current Search Blocks module.

Code

function current_search_update_7101() {

  // @see http://drupal.org/node/1379166
  $result = db_query('SELECT name, settings FROM {current_search}');
  foreach ($result as $record) {
    $settings = unserialize($record->settings);

    // Make our best guess as to whether or not we are using the old structure.
    if (count($settings) != 2 || !isset($settings['items']) || !isset($settings['advanced'])) {
      $settings = array(
        'items' => $settings,
        'advanced' => array(
          'empty_searches' => 0,
        ),
      );
      db_update('current_search')
        ->fields(array(
        'settings' => serialize($settings),
      ))
        ->execute();
    }
  }
}