You are here

update_status.install in Update Status 5.2

File

update_status.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function update_status_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {cache_update_status} (\n        cid varchar(255) NOT NULL default '',\n        data longblob,\n        expire int(11) NOT NULL default '0',\n        created int(11) NOT NULL default '0',\n        PRIMARY KEY (cid)\n      )");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {cache_update_status} (\n        cid varchar(255) NOT NULL default '',\n        data bytea,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        PRIMARY KEY (cid)\n      )");
      break;
  }
}

/**
 * Implementation of hook_uninstall().
 */
function update_status_uninstall() {
  $variables = array(
    'update_status_settings',
    'update_status_notify_emails',
    'update_status_check_frequency',
    'update_status_notification_threshold',
    'update_status_last',
    'update_status_fetch_url',
    'update_status_check_disabled',
  );
  foreach ($variables as $variable) {
    variable_del($variable);
  }
  db_query("DROP TABLE {cache_update_status}");
  cache_clear_all();
}

/**
 * Remove the old data in stale variables used by the 5.x-1.* releases.
 */
function update_status_update_5200() {
  $ret = array();
  foreach (array(
    'update_status_last',
    'update_status',
  ) as $variable) {
    variable_del($variable);
    $ret[] = array(
      'success' => TRUE,
      'query' => "variable_del({$variable})",
    );
  }
  return $ret;
}

/**
 * Database changes required for 5.x-2.0-rc2:
 * - Rename and prune dead variables.
 * - Clear menu cache.
 */
function update_status_update_5201() {
  $ret = array();
  $error_threshold = variable_get('update_status_error_threshold', '');
  if (!empty($error_threshold)) {
    variable_set('update_status_notification_threshold', $error_threshold);
    $ret[] = array(
      'success' => TRUE,
      'query' => "variable_set('update_status_notification_threshold', {$error_threshold})",
    );
  }
  foreach (array(
    'update_status_error_threshold',
    'update_status_usage_stats',
  ) as $variable) {
    variable_del($variable);
    $ret[] = array(
      'success' => TRUE,
      'query' => "variable_del({$variable})",
    );
  }

  // Reset the menu cache since admin/logs/updates/check is a new path.
  cache_clear_all();
  return $ret;
}

/**
 * More thorough attempt at rebuilding the menu cache, since
 * admin/logs/updates/check is a new path.
 */
function update_status_update_5202() {
  $ret = array();
  cache_clear_all();
  menu_rebuild();
  return $ret;
}

/**
 * Backport seperate cache table and functionality from 6.x (#155450).
 */
function update_status_update_5203() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("CREATE TABLE {cache_update_status} (\n        cid varchar(255) NOT NULL default '',\n        data longblob,\n        expire int(11) NOT NULL default '0',\n        created int(11) NOT NULL default '0',\n        PRIMARY KEY (cid)\n      )");
      break;
    case 'pgsql':
      $ret[] = update_sql("CREATE TABLE {cache_update_status} (\n        cid varchar(255) NOT NULL default '',\n        data bytea,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        PRIMARY KEY (cid)\n      )");
      break;
  }
  return $ret;
}

Functions

Namesort descending Description
update_status_install Implementation of hook_install().
update_status_uninstall Implementation of hook_uninstall().
update_status_update_5200 Remove the old data in stale variables used by the 5.x-1.* releases.
update_status_update_5201 Database changes required for 5.x-2.0-rc2:
update_status_update_5202 More thorough attempt at rebuilding the menu cache, since admin/logs/updates/check is a new path.
update_status_update_5203 Backport seperate cache table and functionality from 6.x (#155450).