summaryrefslogtreecommitdiff
path: root/modules/system/system.install
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system/system.install')
-rw-r--r--modules/system/system.install532
1 files changed, 1 insertions, 531 deletions
diff --git a/modules/system/system.install b/modules/system/system.install
index 310bc0661..c23bfddee 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -1053,541 +1053,11 @@ function system_schema() {
// Updates for core.
-/**
- * @defgroup updates-4.7.x-extra Extra system updates for 4.7.x
- * @{
- */
-
function system_update_last_removed() {
- return 179;
-}
-
-function system_update_180() {
- $ret = array();
-
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {node} DROP PRIMARY KEY");
- $ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");
- $ret[] = update_sql("ALTER TABLE {node} ADD UNIQUE (vid)");
- $ret[] = update_sql("ALTER TABLE {node} ADD INDEX (nid)");
-
- $ret[] = update_sql("ALTER TABLE {node_counter} CHANGE nid nid INT(10) NOT NULL DEFAULT '0'");
- break;
- case 'pgsql':
- $ret[] = update_sql("ALTER TABLE {node} DROP CONSTRAINT {node}_pkey"); // Change PK
- $ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");
- $ret[] = update_sql('DROP INDEX {node}_vid_idx'); // Change normal index to UNIQUE index
- $ret[] = update_sql('CREATE UNIQUE INDEX {node}_vid_idx ON {node}(vid)');
- $ret[] = update_sql('CREATE INDEX {node}_nid_idx ON {node}(nid)'); // Add index on nid
- break;
- }
-
- return $ret;
-}
-
-function system_update_181() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {profile_fields} ADD autocomplete TINYINT(1) NOT NULL AFTER visibility ;");
- break;
- case 'pgsql':
- db_add_column($ret, 'profile_fields', 'autocomplete', 'smallint', array('not null' => TRUE, 'default' => 0));
- break;
- }
- return $ret;
-}
-
-/**
- * The lid field in pgSQL should not be UNIQUE, but an INDEX.
- */
-function system_update_182() {
- $ret = array();
-
- if ($GLOBALS['db_type'] == 'pgsql') {
- $ret[] = update_sql('ALTER TABLE {locales_target} DROP CONSTRAINT {locales_target}_lid_key');
- $ret[] = update_sql('CREATE INDEX {locales_target}_lid_idx ON {locales_target} (lid)');
- }
-
- return $ret;
-}
-
-/**
- * Cid matching by MySQL should be case-sensitive.
- */
-function system_update_183() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {cache} CHANGE cid cid varchar(255) BINARY NOT NULL default ''");
- break;
- }
- return $ret;
-}
-
-function system_update_184() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {access} CHANGE aid aid int(10) NOT NULL AUTO_INCREMENT ");
- $ret[] = update_sql("ALTER TABLE {boxes} CHANGE bid bid int NOT NULL AUTO_INCREMENT ");
- break;
- case 'pgsql':
- // No database update required for PostgreSQL because it already uses big SERIAL numbers.
- }
-
- return $ret;
-}
-
-/**
- * @} End of "defgroup updates-4.7-extra"
- */
-
-/**
- * @defgroup updates-4.7-to-5.0 System updates from 4.7 to 5.0
- * @{
- */
-
-function system_update_1000() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("CREATE TABLE {blocks_roles} (
- module varchar(64) NOT NULL,
- delta varchar(32) NOT NULL,
- rid int unsigned NOT NULL,
- PRIMARY KEY (module, delta, rid)
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
- break;
-
- case 'pgsql':
- $ret[] = update_sql("CREATE TABLE {blocks_roles} (
- module varchar(64) NOT NULL,
- delta varchar(32) NOT NULL,
- rid integer NOT NULL,
- PRIMARY KEY (module, delta, rid)
- );");
- break;
-
- }
- return $ret;
-}
-
-function system_update_1001() {
- // change DB schema for better poll support
- $ret = array();
-
- switch ($GLOBALS['db_type']) {
- case 'mysqli':
- case 'mysql':
- // alter poll_votes table
- $ret[] = update_sql("ALTER TABLE {poll_votes} ADD COLUMN chorder int NOT NULL default -1 AFTER uid");
- break;
-
- case 'pgsql':
- db_add_column($ret, 'poll_votes', 'chorder', 'int', array('not null' => TRUE, 'default' => "'-1'"));
- break;
- }
-
- return $ret;
-}
-
-function system_update_1002() {
- // Make the forum's vocabulary the highest in list, if present
- $ret = array();
-
- if ($vid = (int) variable_get('forum_nav_vocabulary', 0)) {
- $ret[] = update_sql('UPDATE {vocabulary} SET weight = -10 WHERE vid = '. $vid);
- }
-
- return $ret;
-}
-
-function system_update_1003() {
- // Make use of guid in feed items
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {aggregator_item} ADD guid varchar(255) AFTER timestamp ;");
- break;
- case 'pgsql':
- db_add_column($ret, 'aggregator_item', 'guid', 'varchar(255)');
- break;
- }
- return $ret;
-}
-
-
-function system_update_1004() {
- // Increase the size of bid in boxes and aid in access
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {access} CHANGE `aid` `aid` int NOT NULL AUTO_INCREMENT ");
- $ret[] = update_sql("ALTER TABLE {boxes} CHANGE `bid` `bid` int NOT NULL AUTO_INCREMENT ");
- break;
- case 'pgsql':
- // No database update required for PostgreSQL because it already uses big SERIAL numbers.
- break;
- }
- return $ret;
-}
-
-function system_update_1005() {
- // Add ability to create dynamic node types like the CCK module
- $ret = array();
-
- // The node_type table may already exist for anyone who ever used CCK in 4.7,
- // even if CCK is no longer installed. We need to make sure any previously
- // created table gets renamed before we create the new node_type table in
- // order to ensure that the new table gets created without errors.
- // TODO: This check should be removed for Drupal 6.
- if (db_table_exists('node_type')) {
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql('RENAME TABLE {node_type} TO {node_type_content}');
- break;
-
- case 'pgsql':
- $ret[] = update_sql('ALTER TABLE {node_type} RENAME TO {node_type_content}');
- break;
- }
- }
-
- switch ($GLOBALS['db_type']) {
- case 'mysqli':
- case 'mysql':
- // Create node_type table
- $ret[] = update_sql("CREATE TABLE {node_type} (
- type varchar(32) NOT NULL,
- name varchar(255) NOT NULL,
- module varchar(255) NOT NULL,
- description mediumtext NOT NULL,
- help mediumtext NOT NULL,
- has_title tinyint unsigned NOT NULL,
- title_label varchar(255) NOT NULL default '',
- has_body tinyint unsigned NOT NULL,
- body_label varchar(255) NOT NULL default '',
- min_word_count smallint unsigned NOT NULL,
- custom tinyint NOT NULL DEFAULT '0',
- modified tinyint NOT NULL DEFAULT '0',
- locked tinyint NOT NULL DEFAULT '0',
- orig_type varchar(255) NOT NULL default '',
- PRIMARY KEY (type)
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
- break;
-
- case 'pgsql':
- // add new unsigned types for pgsql
- $ret[] = update_sql("CREATE DOMAIN int_unsigned integer CHECK (VALUE >= 0)");
- $ret[] = update_sql("CREATE DOMAIN smallint_unsigned smallint CHECK (VALUE >= 0)");
- $ret[] = update_sql("CREATE DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0)");
-
- $ret[] = update_sql("CREATE TABLE {node_type} (
- type varchar(32) NOT NULL,
- name varchar(255) NOT NULL,
- module varchar(255) NOT NULL,
- description text NOT NULL,
- help text NOT NULL,
- has_title smallint_unsigned NOT NULL,
- title_label varchar(255) NOT NULL default '',
- has_body smallint_unsigned NOT NULL,
- body_label varchar(255) NOT NULL default '',
- min_word_count smallint_unsigned NOT NULL,
- custom smallint NOT NULL DEFAULT '0',
- modified smallint NOT NULL DEFAULT '0',
- locked smallint NOT NULL DEFAULT '0',
- orig_type varchar(255) NOT NULL default '',
- PRIMARY KEY (type)
- );");
- break;
- }
-
- // Insert default user-defined node types into the database.
- $types = array(
- array(
- 'type' => 'page',
- 'name' => t('Page'),
- 'module' => 'node',
- 'description' => t('If you want to add a static page, like a contact page or an about page, use a page.'),
- 'custom' => TRUE,
- 'modified' => TRUE,
- 'locked' => FALSE,
- ),
- array(
- 'type' => 'story',
- 'name' => t('Story'),
- 'module' => 'node',
- 'description' => t('Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extended by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.'),
- 'custom' => TRUE,
- 'modified' => TRUE,
- 'locked' => FALSE,
- )
- );
-
- foreach ($types as $type) {
- $type = (object) _node_type_set_defaults($type);
- node_type_save($type);
- }
-
- cache_clear_all();
-
- include_once './'. drupal_get_path('module', 'system') .'/system.admin.inc';
- system_modules();
-
- menu_rebuild();
- node_types_rebuild();
-
- // Migrate old values for 'minimum_x_size' variables to the node_type table.
- $query = db_query('SELECT type FROM {node_type}');
- while ($result = db_fetch_object($query)) {
- $variable_name = 'minimum_'. $result->type .'_size';
- if ($value = db_fetch_object(db_query("SELECT value FROM {variable} WHERE name = '%s'", $variable_name))) {
- $value = (int) unserialize($value->value);
- db_query("UPDATE {node_type} SET min_word_count = %d, modified = %d WHERE type = '%s'", $value, 1, $result->type);
- variable_del($variable_name);
- }
- }
-
- node_types_rebuild();
-
- return $ret;
-}
-
-function system_update_1006() {
- // Add a customizable title to all blocks.
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {blocks} ADD title VARCHAR(64) NOT NULL DEFAULT ''");
- break;
- case 'pgsql':
- db_add_column($ret, 'blocks', 'title', 'varchar(64)', array('default' => "''", 'not null' => TRUE));
- break;
- }
- // Migrate custom block titles to new column.
- $boxes = db_query('SELECT bid, title from {boxes}');
- while ($box = db_fetch_object($boxes)) {
- db_query("UPDATE {blocks} SET title = '%s' WHERE delta = %d and module = 'block'", $box->title, $box->bid);
- }
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql('ALTER TABLE {boxes} DROP title');
- break;
- case 'pgsql':
- $ret[] = update_sql('ALTER TABLE {boxes} DROP COLUMN title');
- break;
- }
- return $ret;
-}
-
-function system_update_1007() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {aggregator_item} ADD INDEX (fid)");
- break;
- case 'pgsql':
- $ret[] = update_sql("CREATE INDEX {aggregator_item}_fid_idx ON {aggregator_item} (fid)");
- break;
- }
- return $ret;
-}
-
-/**
- * Performance update for queries that are related to the locale.module
- */
-function system_update_1008() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql('ALTER TABLE {locales_source} ADD KEY source (source(30))');
- break;
- case 'pgsql':
- $ret[] = update_sql("CREATE INDEX {locales_source}_source_idx on {locales_source} (source)");
- }
-
- return $ret;
-}
-
-function system_update_1010() {
- $ret = array();
-
- // Disable urlfilter.module, if it exists.
- if (module_exists('urlfilter')) {
- module_disable(array('urlfilter'));
- $ret[] = update_sql("UPDATE {filter_formats} SET module = 'filter', delta = 3 WHERE module = 'urlfilter'");
- $ret[] = t('URL Filter module was disabled; this functionality has now been added to core.');
- }
-
- return $ret;
-}
-
-function system_update_1011() {
- $ret = array();
- $ret[] = update_sql('UPDATE {menu} SET mid = 2 WHERE mid = 0');
- cache_clear_all();
- return $ret;
-}
-
-function system_update_1012() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {file_revisions} ADD INDEX(vid)");
- $ret[] = update_sql("ALTER TABLE {files} ADD INDEX(nid)");
- break;
- case 'pgsql':
- $ret[] = update_sql('CREATE INDEX {file_revisions}_vid_idx ON {file_revisions} (vid)');
- $ret[] = update_sql('CREATE INDEX {files}_nid_idx ON {files} (nid)');
- break;
- }
- return $ret;
-}
-
-function system_update_1013() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {sessions} CHANGE COLUMN sid sid varchar(64) NOT NULL default ''");
- break;
- case 'pgsql':
- db_change_column($ret, 'sessions', 'sid', 'sid', 'varchar(64)', array('not null' => TRUE, 'default' => "''"));
- break;
- }
- return $ret;
-}
-
-function system_update_1014() {
- variable_del('cron_busy');
- return array();
-}
-
-/**
- * Add an index on watchdog type.
- */
-function system_update_1015() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql('ALTER TABLE {watchdog} ADD INDEX (type)');
- break;
- case 'pgsql':
- $ret[] = update_sql('CREATE INDEX {watchdog}_type_idx ON {watchdog}(type)');
- break;
- }
- return $ret;
-}
-
-/**
- * Allow for longer URL encoded (%NN) UTF-8 characters in the location field of watchdog table.
- */
-function system_update_1016() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {watchdog} CHANGE COLUMN location location text NOT NULL");
- break;
- case 'pgsql':
- db_change_column($ret, 'watchdog', 'location', 'location', 'text', array('not null' => TRUE, 'default' => "''"));
- break;
- }
- return $ret;
-}
-
-/**
- * Allow role names to be up to 64 characters.
- */
-function system_update_1017() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'pgsql':
- db_change_column($ret, 'role', 'name', 'name', 'varchar(64)', array('not null' => TRUE, 'default' => "''"));
- break;
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {role} CHANGE name name varchar(64) NOT NULL default ''");
- break;
- }
- return $ret;
-}
-
-/**
- * Change break tag (was removed, see 1020).
- */
-function system_update_1018() {
- variable_set('update_1020_ok', TRUE);
- return array();
-}
-
-/**
- * Change variable format for user-defined e-mails.
- */
-function system_update_1019() {
- $message_ids = array('welcome_subject', 'welcome_body',
- 'approval_subject', 'approval_body',
- 'pass_subject', 'pass_body',
- );
- foreach ($message_ids as $id) {
- // Replace all %vars with !vars
- if ($message = variable_get('user_mail_'. $id, NULL)) {
- $fixed = preg_replace('/%([A-Za-z_-]+)/', '!\1', $message);
- variable_set('user_mail_'. $id, $fixed);
- }
- }
- return array();
-}
-
-/**
- * Change break tag back (was removed from head).
- */
-function system_update_1020() {
- $ret = array();
- if (!variable_get('update_1020_ok', FALSE)) {
- $ret[] = update_sql("UPDATE {node_revisions} SET body = REPLACE(body, '<break>', '<!--break-->')");
- }
- variable_del('update_1020_ok');
- return $ret;
+ return 1021;
}
/**
- * Update two more variables that were missing from system_update_1019.
- */
-function system_update_1021() {
- $message_ids = array('admin_body', 'admin_subject');
- foreach ($message_ids as $id) {
- // Replace all %vars with !vars
- if ($message = variable_get('user_mail_'. $id, NULL)) {
- $fixed = preg_replace('/%([A-Za-z_-]+)/', '!\1', $message);
- variable_set('user_mail_'. $id, $fixed);
- }
- }
- return array();
-}
-
-/**
- * @} End of "defgroup updates-4.7-to-5.0"
- */
-
-
-/**
* @defgroup updates-5.x-extra Extra system updates for 5.x
* @{
*/