You are here

devel.install in Devel 5

File

devel.install
View source
<?php

/**
 * Implementation of hook_install()
 */
function devel_install() {

  // New module weights in core: put devel as the very last in the chain.
  db_query("UPDATE {system} SET weight = 88 WHERE name = 'devel'");
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $sql = "CREATE TABLE {devel_queries} (\n        qid int(10) NOT NULL auto_increment,\n        function varchar(255) NOT NULL default '',\n        query text NOT NULL,\n        hash varchar(255) NOT NULL default '',\n        PRIMARY KEY (`hash`),\n        KEY qid (qid)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
      db_query($sql);
      $sql = "CREATE TABLE {devel_times} (\n        tid int(10) NOT NULL auto_increment,\n        qid int(10) NOT NULL default 0,\n        time float default NULL,\n        PRIMARY KEY (tid),\n        KEY qid (qid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
      db_query($sql);
      break;
    case 'mssql':
      $sql = "CREATE TABLE {devel_queries} (\n        qid INT IDENTITY(1,1),\n        \"function\" varchar(255) NOT NULL default '',\n        query text NOT NULL,\n        hash varchar(255) NOT NULL default '',\n        PRIMARY KEY (qid));";
      db_query($sql);
      $sql = "CREATE TABLE {devel_times} (\n        tid INT IDENTITY(1,1),\n        qid INT NOT NULL default 0,\n        time FLOAT default NULL,\n        PRIMARY KEY (tid)\n      );";
      db_query($sql);
  }
}

/**
 * Implementation of hook_disable().
 */
function devel_disable() {

  // Query logging should probably not be set if devel.module is disabled.
  if (variable_get('dev_query', 0)) {
    variable_set('dev_query', 0);
    drupal_set_message(t('Disabled query logging since devel module is disabled.'));
  }
}

/**
 * Do update 1 again as the hook_install() was missing and new
 * installations are not having the weight set.
 */
function devel_update_2() {

  // New module weights in core: put devel as the very last in the chain.
  $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'devel'");
  return $ret;
}
function devel_update_3() {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $sql = "CREATE TABLE {devel_queries} (\n        qid int(10) NOT NULL auto_increment,\n        query varchar(255) NOT NULL default '',\n        hash varchar(255) NOT NULL default '',\n        PRIMARY KEY (`hash`),\n        KEY qid (qid)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
      $ret[] = update_sql($sql);
      $sql = "CREATE TABLE {devel_times} (\n        tid int(10) NOT NULL auto_increment,\n        qid int(10) NOT NULL default 0,\n        time float default NULL,\n        PRIMARY KEY (tid),\n        KEY qid (qid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
      $ret[] = update_sql($sql);
      return $ret;
  }
}
function devel_update_4() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $ret[] = update_sql("ALTER TABLE {devel_queries} ADD `function` varchar(255) NOT NULL default ''");
  }
  return $ret;
}
function devel_update_5() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $ret[] = update_sql("ALTER TABLE {devel_queries} CHANGE query query text NOT NULL");
  }
  return $ret;
}

Functions

Namesort descending Description
devel_disable Implementation of hook_disable().
devel_install Implementation of hook_install()
devel_update_2 Do update 1 again as the hook_install() was missing and new installations are not having the weight set.
devel_update_3
devel_update_4
devel_update_5