You are here

function location_update_6303 in Location 6.3

Same name and namespace in other branches
  1. 7.5 location.install \location_update_6303()
  2. 7.3 location.install \location_update_6303()
  3. 7.4 location.install \location_update_6303()

Drupal 6 location 3.x update, part 3.

File

./location.install, line 949
Installation / uninstallation routines.

Code

function location_update_6303() {
  $ret = array();
  if (!variable_get('location_update_5304_done', FALSE)) {

    // Do the same updates as 5304.
    // Delete unused variables.
    variable_del('location_configured_countries');
    variable_del('location_garbagecollect');

    // Update province code for Italy/Forlì-Cesena.
    $ret[] = update_sql("UPDATE {location} SET province = 'FC' WHERE country = 'it' AND province = 'FO'");

    // Update province code for Italy/Pesaro e Urbino.
    $ret[] = update_sql("UPDATE {location} SET province = 'PU' WHERE country = 'it' AND province = 'PS'");

    // Do one final garbage collection by hand.
    $ret[] = update_sql('DELETE FROM {location} WHERE lid NOT IN (SELECT lid FROM {location_instance})');

    // Garbage collect {location_phone} by hand.
    if (db_table_exists('location_phone')) {
      $ret[] = update_sql('DELETE FROM {location_phone} WHERE lid NOT IN (SELECT lid FROM {location})');
    }

    // Garbage collect {location_fax} by hand.
    if (db_table_exists('location_fax')) {
      $ret[] = update_sql('DELETE FROM {location_fax} WHERE lid NOT IN (SELECT lid FROM {location})');
    }
    variable_del('location_update_5304_done');
  }
  return $ret;
}