You are here

function search_autocomplete_update_7301 in Search Autocomplete 7.3

Get ready for Search Autocomplete 7.x-3.0-rc2

File

./search_autocomplete.install, line 241
This file is used to install/update/delete the module tables in database

Code

function search_autocomplete_update_7301(&$sandbox) {
  global $base_url;
  $ret = array();
  $result = db_select('search_autocomplete_forms', 'f')
    ->fields('f', array(
    'fid',
    'data_callback',
  ))
    ->execute()
    ->fetchAll();
  foreach ($result as $item) {
    db_update('search_autocomplete_forms')
      ->fields(array(
      'data_callback' => str_replace($base_url . "/", "", $item->data_callback),
    ))
      ->condition('fid', $item->fid)
      ->execute();
  }
  drupal_clear_js_cache();
  return t('Update has:<br/>- change internal callback URL from absolute to relative.<br/>- clear JS cache.<br/> Done with success.');

  // In case of an error, simply throw an exception with an error message.
  throw new DrupalUpdateException('Something went wrong. Please uninstall and install the module again.');
  return $ret;
}