summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-09-29 15:13:57 +0000
committerDries Buytaert <dries@buytaert.net>2009-09-29 15:13:57 +0000
commitcef10893892a1c40f73fd972969c3512b0983cd6 (patch)
treec295a5dea1cc8f5d0ced7e7c967c70cf34f33c73 /modules
parent0a0b067c2404b041454cc7a5fc8cfbbb9ecd6027 (diff)
downloadbrdo-cef10893892a1c40f73fd972969c3512b0983cd6.tar.gz
brdo-cef10893892a1c40f73fd972969c3512b0983cd6.tar.bz2
- Patch #570900 by Crell | asimmonds: Changed Destroy remnants of update_sql().
Diffstat (limited to 'modules')
-rw-r--r--modules/aggregator/aggregator.install5
-rw-r--r--modules/block/block.install12
-rw-r--r--modules/comment/comment.install42
-rw-r--r--modules/contact/contact.install1
-rw-r--r--modules/dblog/dblog.install14
-rw-r--r--modules/field/modules/field_sql_storage/field_sql_storage.module26
-rw-r--r--modules/filter/filter.install62
-rw-r--r--modules/forum/forum.install7
-rw-r--r--modules/locale/locale.install6
-rw-r--r--modules/node/node.install50
-rw-r--r--modules/poll/poll.install10
-rw-r--r--modules/profile/profile.install6
-rw-r--r--modules/search/search.install13
-rw-r--r--modules/simpletest/drupal_web_test_case.php2
-rw-r--r--modules/simpletest/simpletest.module3
-rw-r--r--modules/simpletest/tests/database_test.test29
-rw-r--r--modules/simpletest/tests/field_test.module4
-rw-r--r--modules/simpletest/tests/schema.test21
-rw-r--r--modules/statistics/statistics.install4
-rw-r--r--modules/system/system.api.php42
-rw-r--r--modules/system/system.install366
-rw-r--r--modules/taxonomy/taxonomy.install9
-rw-r--r--modules/tracker/tracker.install4
-rw-r--r--modules/trigger/trigger.install14
-rw-r--r--modules/upload/upload.install5
-rw-r--r--modules/user/user.install54
26 files changed, 392 insertions, 419 deletions
diff --git a/modules/aggregator/aggregator.install b/modules/aggregator/aggregator.install
index cc4d2258a..8cfb79c6f 100644
--- a/modules/aggregator/aggregator.install
+++ b/modules/aggregator/aggregator.install
@@ -266,10 +266,9 @@ function aggregator_schema() {
* Add hash column to aggregator_feed table.
*/
function aggregator_update_7000() {
- $ret = array();
- db_add_field($ret, 'aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''));
- return $ret;
+ db_add_field('aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''));
}
+
/**
* Add aggregator teaser length to settings from old global default teaser length
*/
diff --git a/modules/block/block.install b/modules/block/block.install
index f1b2b3e7a..33275506b 100644
--- a/modules/block/block.install
+++ b/modules/block/block.install
@@ -223,9 +223,10 @@ function block_install() {
* so before block module runs, there will not be much to alter.
*/
function block_update_7000() {
- $ret = array();
- $ret[] = update_sql("UPDATE {system} SET weight = -5 WHERE name = 'block'");
- return $ret;
+ db_update('system')
+ ->fields(array('weight', '-5'))
+ ->condition('name', 'block')
+ ->execute();
}
@@ -233,8 +234,6 @@ function block_update_7000() {
* Add the block_node_type table.
*/
function block_update_7001() {
- $ret = array();
-
$schema['block_node_type'] = array(
'description' => 'Sets up display criteria for blocks based on content types',
'fields' => array(
@@ -263,6 +262,5 @@ function block_update_7001() {
),
);
- db_create_table($ret, 'block_node_type', $schema['block_node_type']);
- return $ret;
+ db_create_table('block_node_type', $schema['block_node_type']);
}
diff --git a/modules/comment/comment.install b/modules/comment/comment.install
index 1b63d4aa3..300534544 100644
--- a/modules/comment/comment.install
+++ b/modules/comment/comment.install
@@ -58,40 +58,42 @@ function comment_update_7000() {
foreach ($types as $type => $object) {
variable_del('comment_default_order' . $type);
}
- return array(array('success' => TRUE, 'query' => 'Comment order settings removed.'));
+ return t('Comment order settings removed.');
}
/**
* Change comment status from published being 0 to being 1
*/
function comment_update_7001() {
- $ret = array();
- $ret[] = update_sql("UPDATE {comments} SET status = 3 WHERE status = 0");
- $ret[] = update_sql("UPDATE {comments} SET status = 0 WHERE status = 1");
- $ret[] = update_sql("UPDATE {comments} SET status = 1 WHERE status = 3");
+ $changes = array(
+ 3 => 0,
+ 0 => 1,
+ 1 => 3,
+ );
- return $ret;
+ foreach ($changes as $old => $new) {
+ db_update('comments')
+ ->fields(array('status', $new))
+ ->condition('status', $old)
+ ->execute();
+ }
}
/**
* Rename {comments} table to {comment}.
*/
function comment_update_7002() {
- $ret = array();
- db_rename_table($ret, 'comments', 'comment');
- return $ret;
+ db_rename_table('comments', 'comment');
}
/**
* Improve indexes on the comment table.
*/
function comment_update_7003() {
- $ret = array();
- db_drop_index($ret, 'comment', 'status');
- db_drop_index($ret, 'comment', 'pid');
- db_add_index($ret, 'comment', 'comment_pid_status', array('pid', 'status'));
- db_add_index($ret, 'comment', 'comment_num_new', array('nid', 'timestamp', 'status'));
- return $ret;
+ db_drop_index('comment', 'status');
+ db_drop_index('comment', 'pid');
+ db_add_index('comment', 'comment_pid_status', array('pid', 'status'));
+ db_add_index('comment', 'comment_num_new', array('nid', 'timestamp', 'status'));
}
/**
@@ -108,29 +110,23 @@ function comment_update_7004() {
variable_set('comment_default_mode_' . $type, 0);
}
}
- return array();
}
/**
* Create comment Field API bundles.
*/
function comment_update_7005() {
- $ret = array();
-
foreach (node_type_get_types() as $info) {
field_attach_create_bundle('comment_node_' . $info->type);
}
- return $ret;
}
/**
* Create user related indexes.
*/
function comment_update_7006() {
- $ret = array();
- db_add_index($ret, 'comment', 'comment_uid', array('uid'));
- db_add_index($ret, 'node_comment_statistics', 'last_comment_uid', array('last_comment_uid'));
- return $ret;
+ db_add_index('comment', 'comment_uid', array('uid'));
+ db_add_index('node_comment_statistics', 'last_comment_uid', array('last_comment_uid'));
}
/**
diff --git a/modules/contact/contact.install b/modules/contact/contact.install
index 7b3e57b71..0ebe73c9e 100644
--- a/modules/contact/contact.install
+++ b/modules/contact/contact.install
@@ -85,7 +85,6 @@ function contact_schema() {
function contact_update_7000() {
variable_set('contact_threshold_limit', variable_get('contact_hourly_threshold', 5));
variable_del('contact_hourly_threshold');
- return array();
}
/**
diff --git a/modules/dblog/dblog.install b/modules/dblog/dblog.install
index fef784fb7..cb417c0fb 100644
--- a/modules/dblog/dblog.install
+++ b/modules/dblog/dblog.install
@@ -96,26 +96,20 @@ function dblog_schema() {
* Allow NULL values for links and longer referers.
*/
function dblog_update_7001() {
- $ret = array();
- db_change_field($ret, 'watchdog', 'link', 'link', array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'default' => ''));
- db_change_field($ret, 'watchdog', 'referer', 'referer', array('type' => 'text', 'not null' => FALSE));
- return $ret;
+ db_change_field('watchdog', 'link', 'link', array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'default' => ''));
+ db_change_field('watchdog', 'referer', 'referer', array('type' => 'text', 'not null' => FALSE));
}
/**
* Add index on uid.
*/
function dblog_update_7002() {
- $ret = array();
- db_add_index($ret, 'watchdog', 'uid', array('uid'));
- return $ret;
+ db_add_index('watchdog', 'uid', array('uid'));
}
/**
* Allow longer type values.
*/
function dblog_update_7003() {
- $ret = array();
- db_change_field($ret, 'watchdog', 'type', 'type', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
- return $ret;
+ db_change_field('watchdog', 'type', 'type', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
}
diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.module b/modules/field/modules/field_sql_storage/field_sql_storage.module
index 09dee368a..fd06e2ea1 100644
--- a/modules/field/modules/field_sql_storage/field_sql_storage.module
+++ b/modules/field/modules/field_sql_storage/field_sql_storage.module
@@ -211,7 +211,7 @@ function _field_sql_storage_schema($field) {
function field_sql_storage_field_storage_create_field($field) {
$schema = _field_sql_storage_schema($field);
foreach ($schema as $name => $table) {
- db_create_table($ret, $name, $table);
+ db_create_table($name, $table);
}
}
@@ -231,17 +231,15 @@ function field_sql_storage_field_update_forbid($field, $prior_field, $has_data)
* Implement hook_field_storage_update_field().
*/
function field_sql_storage_field_storage_update_field($field, $prior_field, $has_data) {
- $ret = array();
-
if (! $has_data) {
// There is no data. Re-create the tables completely.
$prior_schema = _field_sql_storage_schema($prior_field);
foreach ($prior_schema as $name => $table) {
- db_drop_table($ret, $name, $table);
+ db_drop_table($name, $table);
}
$schema = _field_sql_storage_schema($field);
foreach ($schema as $name => $table) {
- db_create_table($ret, $name, $table);
+ db_create_table($name, $table);
}
}
else {
@@ -253,8 +251,8 @@ function field_sql_storage_field_storage_update_field($field, $prior_field, $has
foreach ($prior_field['indexes'] as $name => $columns) {
if (!isset($field['indexes'][$name]) || $columns != $field['indexes'][$name]) {
$real_name = _field_sql_storage_indexname($field['field_name'], $name);
- db_drop_index($ret, $table, $real_name);
- db_drop_index($ret, $revision_table, $real_name);
+ db_drop_index($table, $real_name);
+ db_drop_index($revision_table, $real_name);
}
}
$table = _field_sql_storage_tablename($field);
@@ -266,8 +264,8 @@ function field_sql_storage_field_storage_update_field($field, $prior_field, $has
foreach ($columns as $column_name) {
$real_columns[] = _field_sql_storage_columnname($field['field_name'], $column_name);
}
- db_add_index($ret, $table, $real_name, $real_columns);
- db_add_index($ret, $revision_table, $real_name, $real_columns);
+ db_add_index($table, $real_name, $real_columns);
+ db_add_index($revision_table, $real_name, $real_columns);
}
}
}
@@ -286,12 +284,11 @@ function field_sql_storage_field_storage_delete_field($field) {
->execute();
// Move the table to a unique name while the table contents are being deleted.
- $ret = array();
$field['deleted'] = 1;
$new_table = _field_sql_storage_tablename($field);
$revision_new_table = _field_sql_storage_revision_tablename($field);
- db_rename_table($ret, $table, $new_table);
- db_rename_table($ret, $revision_table, $revision_new_table);
+ db_rename_table($table, $new_table);
+ db_rename_table($revision_table, $revision_new_table);
drupal_get_schema(NULL, TRUE);
}
@@ -655,10 +652,9 @@ function field_sql_storage_field_attach_rename_bundle($bundle_old, $bundle_new)
* that is left is to delete the table.
*/
function field_sql_storage_field_storage_purge_field($field) {
- $ret = array();
$table_name = _field_sql_storage_tablename($field);
$revision_name = _field_sql_storage_revision_tablename($field);
- db_drop_table($ret, $table_name);
- db_drop_table($ret, $revision_name);
+ db_drop_table($table_name);
+ db_drop_table($revision_name);
}
diff --git a/modules/filter/filter.install b/modules/filter/filter.install
index 5685ea577..deda8bc32 100644
--- a/modules/filter/filter.install
+++ b/modules/filter/filter.install
@@ -113,42 +113,44 @@ function filter_schema() {
* Add a weight column to the filter formats table.
*/
function filter_update_7000() {
- $ret = array();
- db_add_field($ret, 'filter_formats', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
- return $ret;
+ db_add_field('filter_formats', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
}
/**
* Break out "escape HTML filter" option to its own filter.
*/
function filter_update_7001() {
- $ret = array();
$result = db_query("SELECT format FROM {filter_formats}");
+ $insert = db_insert('filters')->fields(array('format', 'module', 'delta', 'weight'));
+
foreach ($result as $format) {
// Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE = 2.
if (variable_get('filter_html_' . $format->format, 1) == 2) {
- $ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (" . $format->format . ", 'filter', 4, 0)");
+ $insert->values(array(
+ 'format' => $format->format,
+ 'filter' => 'filter',
+ 'delta' => 4,
+ 'weight' => 0,
+ ));
}
variable_del('filter_html_' . $format->format);
}
- return $ret;
+
+ $insert->execute();
}
/**
* Rename {filters} table to {filter} and {filter_formats} table to {filter_format}.
*/
function filter_update_7002() {
- $ret = array();
- db_rename_table($ret, 'filters', 'filter');
- db_rename_table($ret, 'filter_formats', 'filter_format');
- return $ret;
+ db_rename_table('filters', 'filter');
+ db_rename_table('filter_formats', 'filter_format');
}
/**
* Remove hardcoded numeric deltas from all filters in core.
*/
function filter_update_7003() {
- $ret = array();
// Get an array of the renamed filter deltas, organized by module.
$renamed_deltas = array(
'filter' => array(
@@ -164,9 +166,9 @@ function filter_update_7003() {
);
// Rename field 'delta' to 'name'.
- db_drop_unique_key($ret, 'filter', 'fmd');
- db_drop_index($ret, 'filter', 'list');
- db_change_field($ret, 'filter', 'delta', 'name',
+ db_drop_unique_key('filter', 'fmd');
+ db_drop_index('filter', 'list');
+ db_change_field('filter', 'delta', 'name',
array(
'type' => 'varchar',
'length' => 32,
@@ -187,10 +189,13 @@ function filter_update_7003() {
// Loop through each filter and make changes to the core filter table.
foreach ($renamed_deltas as $module => $deltas) {
foreach ($deltas as $old_delta => $new_delta) {
- $ret[] = update_sql("UPDATE {filter} SET name = '" . $new_delta . "' WHERE module = '" . $module . "' AND name = '" . $old_delta . "'");
+ db_update('filter')
+ ->fields(array('name', $new_delta))
+ ->condition('module', $module)
+ ->condition('name', $old_delta)
+ ->execute();
}
}
- return $ret;
}
/**
@@ -202,10 +207,9 @@ function filter_update_7003() {
* - Add {filter}.settings.
*/
function filter_update_7004() {
- $ret = array();
- db_drop_field($ret, 'filter', 'fid');
- db_add_primary_key($ret, 'filter', array('format', 'name'));
- db_add_field($ret, 'filter', 'status',
+ db_drop_field('filter', 'fid');
+ db_add_primary_key('filter', array('format', 'name'));
+ db_add_field('filter', 'status',
array(
'type' => 'int',
'not null' => TRUE,
@@ -213,7 +217,7 @@ function filter_update_7004() {
'description' => 'Filter enabled status. (1 = enabled, 0 = disabled)',
)
);
- db_add_field($ret, 'filter', 'settings',
+ db_add_field('filter', 'settings',
array(
'type' => 'text',
'not null' => FALSE,
@@ -224,7 +228,9 @@ function filter_update_7004() {
);
// Enable all existing filters ({filter} contained only enabled previously).
- $ret[] = update_sql("UPDATE {filter} SET status = 1");
+ db_update('filter')
+ ->fields('status', '1')
+ ->execute();
// Move filter settings from system variables into {filter}.settings.
$filters = db_query("SELECT * FROM {filter} WHERE module = :name", array(':name' => 'filter'));
@@ -251,11 +257,13 @@ function filter_update_7004() {
}
}
if (!empty($settings)) {
- $ret[] = update_sql("UPDATE {filter} SET settings = '" . serialize($settings) . "' WHERE format = {$filter->format} AND name = '{$filter->name}'");
+ db_upddate('filter')
+ ->fields(array('settings' => serialize($settings)))
+ ->condition('format', $filter->format)
+ ->condition('name', $filter->name)
+ ->execute();
}
}
-
- return $ret;
}
/**
@@ -267,7 +275,6 @@ function filter_update_7004() {
* in cases that used to rely on a single site-wide default.
*/
function filter_update_7005() {
- $ret = array();
// Move role data from the filter system to the user permission system.
$all_roles = array_keys(user_roles());
@@ -286,7 +293,7 @@ function filter_update_7005() {
}
// Drop the roles field from the {filter_format} table.
- db_drop_field($ret, 'filter_format', 'roles');
+ db_drop_field('filter_format', 'roles');
// Add a fallback text format which outputs plain text and appears last on
// the list for all users. Generate a unique name for it, starting with
@@ -336,7 +343,6 @@ function filter_update_7005() {
// We do not delete the 'filter_default_format' variable, since other modules
// may need it in their update functions.
// @todo This variable can be deleted in Drupal 8.
- return $ret;
}
/**
diff --git a/modules/forum/forum.install b/modules/forum/forum.install
index c42490e2e..df6ccf48d 100644
--- a/modules/forum/forum.install
+++ b/modules/forum/forum.install
@@ -116,9 +116,6 @@ function forum_schema() {
* Add new index to forum table.
*/
function forum_update_7000() {
- $ret = array();
- db_drop_index($ret, 'forum', 'nid');
- db_add_index($ret, 'forum', 'forum_topic', array('nid', 'tid'));
-
- return $ret;
+ db_drop_index('forum', 'nid');
+ db_add_index('forum', 'forum_topic', array('nid', 'tid'));
}
diff --git a/modules/locale/locale.install b/modules/locale/locale.install
index d487803c1..73d8814e1 100644
--- a/modules/locale/locale.install
+++ b/modules/locale/locale.install
@@ -36,10 +36,8 @@ function locale_install() {
* Allow longer location.
*/
function locale_update_7000() {
- $ret = array();
- db_drop_index($ret, 'locales_source', 'source');
- db_add_index($ret, 'locales_source', 'source_context', array(array('source', 30), 'context'));
- return $ret;
+ db_drop_index('locales_source', 'source');
+ db_add_index('locales_source', 'source_context', array(array('source', 30), 'context'));
}
/**
diff --git a/modules/node/node.install b/modules/node/node.install
index 6ac772029..947757605 100644
--- a/modules/node/node.install
+++ b/modules/node/node.install
@@ -360,42 +360,34 @@ function node_schema() {
* Fix node type 'module' attribute to avoid name-space conflicts.
*/
function node_update_7000() {
- $ret = array();
-
- $ret[] = update_sql("UPDATE {node_type} SET module = 'node_content' WHERE module = 'node'");
- db_change_field($ret, 'node_type', 'module', 'base', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
-
- return $ret;
+ db_update('node_type')
+ ->fields(array('module' => 'node_content'))
+ ->condition('module', 'node')
+ ->execute();
}
/**
* Rename {node_revisions} table to {node_revision}.
*/
function node_update_7001() {
- $ret = array();
- db_rename_table($ret, 'node_revisions', 'node_revision');
- return $ret;
+ db_rename_table('node_revisions', 'node_revision');
}
/**
* Extend the node_promote_status index to include all fields required for the node page query.
*/
function node_update_7002() {
- $ret = array();
- db_drop_index($ret, 'node', 'node_promote_status');
- db_add_index($ret, 'node', 'node_frontpage', array('promote', 'status', 'sticky', 'created'));
- return $ret;
+ db_drop_index('node', 'node_promote_status');
+ db_add_index('node', 'node_frontpage', array('promote', 'status', 'sticky', 'created'));
}
/**
* Remove the node_counter if the statistics module is uninstalled.
*/
function node_update_7003() {
- $ret = array();
if (drupal_get_installed_schema_version('statistics') == SCHEMA_UNINSTALLED) {
- db_drop_table($ret, 'node_counter');
+ db_drop_table('node_counter');
}
- return $ret;
}
/**
@@ -418,30 +410,26 @@ function node_update_7004() {
}
// Delete old variable but leave 'teaser_length' for aggregator module upgrade.
variable_del('node_preview');
-
- return array();
}
/**
* Add status/comment/promote and sticky columns to the {node_revision} table.
*/
function node_update_7005() {
- $ret = array();
foreach(array('status', 'comment', 'promote', 'sticky') as $column) {
- db_add_field($ret, 'node_revision', $column, array(
+ db_add_field('node_revision', $column, array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
));
}
- return $ret;
}
/**
* Convert body and teaser from node properties to fields, and migrate status/comment/promote and sticky columns to the {node_revision} table.
*/
function node_update_7006(&$context) {
- $ret = array('#finished' => 0);
+ $context['#finished'] = 0;
// Get node type info for every invocation.
drupal_static_reset('_node_types_build');
@@ -536,33 +524,29 @@ function node_update_7006(&$context) {
}
}
- $ret['#finished'] = min(0.99, $context['count'] / $context['total']);
+ $context['#finished'] = min(0.99, $context['count'] / $context['total']);
}
if (!$found) {
// All nodes are processed.
- $ret[] = array('success' => TRUE, 'query' => "{$context['total']} node body and teaser properties migrated to the 'body' field.");
// Remove the now-obsolete body info from node_revision.
- db_drop_field($ret, 'node_revision', 'body');
- db_drop_field($ret, 'node_revision', 'teaser');
- db_drop_field($ret, 'node_revision', 'format');
+ db_drop_field('node_revision', 'body');
+ db_drop_field('node_revision', 'teaser');
+ db_drop_field('node_revision', 'format');
// We're done.
- $ret['#finished'] = 1;
+ $context['#finished'] = 1;
+ return t("!number node body and teaser properties migrated to the 'body' field.", array('!number' => $context['total']));
}
}
-
- return $ret;
}
/**
* Remove column min_word_count.
*/
function node_update_7007() {
- $ret = array();
- db_drop_field($ret, 'node_type', 'min_word_count');
- return $ret;
+ db_drop_field('node_type', 'min_word_count');
}
/**
diff --git a/modules/poll/poll.install b/modules/poll/poll.install
index 880b317fc..4bd7a214f 100644
--- a/modules/poll/poll.install
+++ b/modules/poll/poll.install
@@ -141,22 +141,18 @@ function poll_schema() {
* Rename {poll_choices} table to {poll_choice} and {poll_votes} to {poll_vote}.
*/
function poll_update_7001() {
- $ret = array();
- db_rename_table($ret, 'poll_choices', 'poll_choice');
- db_rename_table($ret, 'poll_votes', 'poll_vote');
- return $ret;
+ db_rename_table('poll_choices', 'poll_choice');
+ db_rename_table('poll_votes', 'poll_vote');
}
/**
* Add timestamp field to {poll_votes}.
*/
function poll_update_7002() {
- $ret = array();
$field = array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
);
- db_add_field($ret, 'poll_votes', 'timestamp', $field);
- return $ret;
+ db_add_field('poll_votes', 'timestamp', $field);
}
diff --git a/modules/profile/profile.install b/modules/profile/profile.install
index b07780671..153f30959 100644
--- a/modules/profile/profile.install
+++ b/modules/profile/profile.install
@@ -151,8 +151,6 @@ function profile_schema() {
* Rename {profile_fields} table to {profile_field} and {profile_values} to {profile_value}.
*/
function profile_update_7001() {
- $ret = array();
- db_rename_table($ret, 'profile_fields', 'profile_field');
- db_rename_table($ret, 'profile_values', 'profile_value');
- return $ret;
+ db_rename_table('profile_fields', 'profile_field');
+ db_rename_table('profile_values', 'profile_value');
}
diff --git a/modules/search/search.install b/modules/search/search.install
index 5cb6f887b..8582fc0d3 100644
--- a/modules/search/search.install
+++ b/modules/search/search.install
@@ -154,13 +154,10 @@ function search_schema() {
* Replace unique keys in 'search_dataset' and 'search_index' by primary keys.
*/
function search_update_7000() {
- $ret = array();
- db_drop_unique_key($ret, 'search_dataset', 'sid_type');
- db_add_primary_key($ret, 'search_dataset', array('sid', 'type'));
+ db_drop_unique_key('search_dataset', 'sid_type');
+ db_add_primary_key('search_dataset', array('sid', 'type'));
- db_drop_index($ret, 'search_index', 'word');
- db_drop_unique_key($ret, 'search_index', 'word_sid_type');
- db_add_primary_key($ret, 'search_index', array('word', 'sid', 'type'));
-
- return $ret;
+ db_drop_index('search_index', 'word');
+ db_drop_unique_key('search_index', 'word_sid_type');
+ db_add_primary_key('search_index', array('word', 'sid', 'type'));
}
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 455a1213a..1a49c9b5b 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -1180,7 +1180,7 @@ class DrupalWebTestCase extends DrupalTestCase {
$schema = drupal_get_schema(NULL, TRUE);
$ret = array();
foreach ($schema as $name => $table) {
- db_drop_table($ret, $name);
+ db_drop_table($name);
}
// Return the database prefix to the original.
diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module
index b494622e4..84ce85e71 100644
--- a/modules/simpletest/simpletest.module
+++ b/modules/simpletest/simpletest.module
@@ -413,12 +413,11 @@ function simpletest_clean_environment() {
function simpletest_clean_database() {
$tables = db_find_tables(Database::getConnection()->prefixTables('{simpletest}') . '%');
$schema = drupal_get_schema_unprocessed('simpletest');
- $ret = array();
foreach (array_diff_key($tables, $schema) as $table) {
// Strip the prefix and skip tables without digits following "simpletest",
// e.g. {simpletest_test_id}.
if (preg_match('/simpletest\d+.*/', $table, $matches)) {
- db_drop_table($ret, $matches[0]);
+ db_drop_table($matches[0]);
}
}
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index 1e3a52fe7..5499cee43 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -40,12 +40,11 @@ class DatabaseTestCase extends DrupalWebTestCase {
*/
function installTables($schema) {
// This ends up being a test for table drop and create, too, which is nice.
- $ret = array();
foreach ($schema as $name => $data) {
if (db_table_exists($name)) {
- db_drop_table($ret, $name);
+ db_drop_table($name);
}
- db_create_table($ret, $name, $data);
+ db_create_table($name, $data);
}
foreach ($schema as $name => $data) {
@@ -1369,14 +1368,14 @@ class DatabaseSelectTestCase extends DatabaseTestCase {
$query_1->union($query_2);
$names = $query_1->execute()->fetchCol();
-
+
// Ensure we only get 2 records.
$this->assertEqual(count($names), 2, t('UNION correctly discarded duplicates.'));
$this->assertEqual($names[0], 'George', t('First query returned correct name.'));
$this->assertEqual($names[1], 'Ringo', t('Second query returned correct name.'));
}
-
+
/**
* Test that we can UNION ALL multiple Select queries together.
*/
@@ -1384,7 +1383,7 @@ class DatabaseSelectTestCase extends DatabaseTestCase {
$query_1 = db_select('test', 't')
->fields('t', array('name'))
->condition('age', array(27, 28), 'IN');
-
+
$query_2 = db_select('test', 't')
->fields('t', array('name'))
->condition('age', 28);
@@ -2904,9 +2903,8 @@ class DatabaseExtraTypesTestCase extends DrupalWebTestCase {
),
),
);
- $ret = array();
- db_create_table($ret, 'date_table', $date_table);
- $this->assertEqual($ret[0]['success'], 1, t('Created table with date field'));
+ db_create_table('date_table', $date_table);
+ $this->assertTrue(db_table_exists('date_table'), t('Created table with date field'));
db_insert('date_table')->fields(array('date_field'))
->values(array('date_field' => '2001-01-01'))
@@ -2926,8 +2924,8 @@ class DatabaseExtraTypesTestCase extends DrupalWebTestCase {
$this->assertEqual($date, '2100-06-30', t('Date retrieved in order @date', array('@date' => $date)));
- db_drop_table($ret, 'date_table');
- $this->assertEqual($ret[1]['success'], 1, t('Dropped table with date field'));
+ db_drop_table('date_table');
+ $this->assertFalse(db_table_exists('date_table'), t('Dropped table with date field'));
} catch (Exception $e) {
$this->fail($e->getMessage());
@@ -2949,9 +2947,8 @@ class DatabaseExtraTypesTestCase extends DrupalWebTestCase {
),
),
);
- $ret = array();
- db_create_table($ret, 'time_table', $time_table);
- $this->assertEqual($ret[0]['success'], 1, t('Created table with time field'));
+ db_create_table('time_table', $time_table);
+ $this->assertTrue(db_table_exists('time_table'), t('Created table with time field'));
db_insert('time_table')->fields(array('time_field'))
->values(array('time_field' => '12:59:00'))
@@ -2970,8 +2967,8 @@ class DatabaseExtraTypesTestCase extends DrupalWebTestCase {
$time = $res->fetch()->time_field;
$this->assertEqual($time, '23:17:00', t('Time retrieved in order @time', array('@time' => $time)));
- db_drop_table($ret, 'time_table');
- $this->assertEqual($ret[1]['success'], 1, t('Dropped table with time field'));
+ db_drop_table('time_table');
+ $this->assertFalse(db_table_exists('time_table'), t('Dropped table with time field'));
} catch (Exception $e) {
$this->fail($e->getMessage());
}
diff --git a/modules/simpletest/tests/field_test.module b/modules/simpletest/tests/field_test.module
index 93b8084e5..6d463daee 100644
--- a/modules/simpletest/tests/field_test.module
+++ b/modules/simpletest/tests/field_test.module
@@ -1115,9 +1115,9 @@ function field_test_memorize($key = NULL, $value = NULL) {
$memorize = &drupal_static(__FUNCTION__, NULL);
if (is_null($key)) {
- $ret = $memorize;
+ $return = $memorize;
$memorize = array();
- return $ret;
+ return $return;
}
if (is_array($memorize)) {
$memorize[$key][] = $value;
diff --git a/modules/simpletest/tests/schema.test b/modules/simpletest/tests/schema.test
index 3054a1e7c..da48b9395 100644
--- a/modules/simpletest/tests/schema.test
+++ b/modules/simpletest/tests/schema.test
@@ -37,8 +37,7 @@ class SchemaTestCase extends DrupalWebTestCase {
),
),
);
- $ret = array();
- db_create_table($ret, 'test_table', $table_specification);
+ db_create_table('test_table', $table_specification);
// Assert that the table exists.
$this->assertTrue(db_table_exists('test_table'), t('The table exists.'));
@@ -53,19 +52,19 @@ class SchemaTestCase extends DrupalWebTestCase {
$this->assertFalse($this->tryInsert(), t('Insert without a default failed.'));
// Add a default value to the column.
- db_field_set_default($ret, 'test_table', 'test_field', 0);
+ db_field_set_default('test_table', 'test_field', 0);
// The insert should now succeed.
$this->assertTrue($this->tryInsert(), t('Insert with a default succeeded.'));
// Remove the default.
- db_field_set_no_default($ret, 'test_table', 'test_field');
+ db_field_set_no_default('test_table', 'test_field');
// The insert should fail again.
$this->assertFalse($this->tryInsert(), t('Insert without a default failed.'));
// Rename the table.
- db_rename_table($ret, 'test_table', 'test_table2');
+ db_rename_table('test_table', 'test_table2');
// We need the default so that we can insert after the rename.
- db_field_set_default($ret, 'test_table2', 'test_field', 0);
+ db_field_set_default('test_table2', 'test_field', 0);
$this->assertFalse($this->tryInsert(), t('Insert into the old table failed.'));
$this->assertTrue($this->tryInsert('test_table2'), t('Insert into the new table succeeded.'));
@@ -74,19 +73,19 @@ class SchemaTestCase extends DrupalWebTestCase {
$this->assertEqual($count, 2, t('Two fields were successfully inserted.'));
// Try to drop the table.
- db_drop_table($ret, 'test_table2');
+ db_drop_table('test_table2');
$this->assertFalse(db_table_exists('test_table2'), t('The dropped table does not exist.'));
// Recreate the table.
- db_create_table($ret, 'test_table', $table_specification);
- db_field_set_default($ret, 'test_table', 'test_field', 0);
- db_add_field($ret, 'test_table', 'test_serial', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Added column description.'));
+ db_create_table('test_table', $table_specification);
+ db_field_set_default('test_table', 'test_field', 0);
+ db_add_field('test_table', 'test_serial', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Added column description.'));
// Assert that the column comment has been set.
$this->checkSchemaComment('Added column description.', 'test_table', 'test_serial');
// Change the new field to a serial column.
- db_change_field($ret, 'test_table', 'test_serial', 'test_serial', array('type' => 'serial', 'not null' => TRUE, 'description' => 'Changed column description.'), array('primary key' => array('test_serial')));
+ db_change_field('test_table', 'test_serial', 'test_serial', array('type' => 'serial', 'not null' => TRUE, 'description' => 'Changed column description.'), array('primary key' => array('test_serial')));
// Assert that the column comment has been set.
$this->checkSchemaComment('Changed column description.', 'test_table', 'test_serial');
diff --git a/modules/statistics/statistics.install b/modules/statistics/statistics.install
index 396faab80..5fd499707 100644
--- a/modules/statistics/statistics.install
+++ b/modules/statistics/statistics.install
@@ -142,9 +142,7 @@ function statistics_schema() {
* Allow longer referrers.
*/
function statistics_update_7000() {
- $ret = array();
- db_change_field($ret, 'accesslog', 'url', 'url', array('type' => 'text', 'not null' => FALSE));
- return $ret;
+ db_change_field('accesslog', 'url', 'url', array('type' => 'text', 'not null' => FALSE));
}
/**
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index 559d64761..c49f1e95c 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -684,7 +684,7 @@ function hook_image_toolkits() {
* An array containing the message data. Keys in this array include:
* - 'id':
* The drupal_mail() id of the message. Look at module source code or
- * drupal_mail() for possible id values.
+ * drupal_mail() for possible id values.
* - 'to':
* The address or addresses the message will be sent to. The
* formatting of this string must comply with RFC 2822.
@@ -696,7 +696,7 @@ function hook_image_toolkits() {
* characters, or the email may not be sent properly.
* - 'body':
* An array of strings containing the message text. The message body is
- * created by concatenating the individual array strings into a single text
+ * created by concatenating the individual array strings into a single text
* string using "\n\n" as a separator.
* - 'headers':
* Associative array containing mail headers, such as From, Sender,
@@ -1897,30 +1897,28 @@ function hook_install() {
* If your update task is potentially time-consuming, you'll need to implement a
* multipass update to avoid PHP timeouts. Multipass updates use the $sandbox
* parameter provided by the batch API (normally, $context['sandbox']) to store
- * information between successive calls, and the $ret['#finished'] return value
+ * information between successive calls, and the $sandbox['#finished'] value
* to provide feedback regarding completion level.
*
* See the batch operations page for more information on how to use the batch API:
* @link http://drupal.org/node/146843 http://drupal.org/node/146843 @endlink
*
- * @return An array with the results of the calls to update_sql(). An upate
- * function can force the current and all later updates for this
- * module to abort by returning a $ret array with an element like:
- * $ret['#abort'] = array('success' => FALSE, 'query' => 'What went wrong');
- * The schema version will not be updated in this case, and all the
- * aborted updates will continue to appear on update.php as updates that
- * have not yet been run. Multipass update functions will also want to pass
- * back the $ret['#finished'] variable to inform the batch API of progress.
+ * @throws DrupalUpdateException, PDOException
+ * In case of error, update hooks should throw an instance of DrupalUpdateException
+ * with a meaningful message for the user. If a database query fails for whatever
+ * reason, it will throw a PDOException.
+ *
+ * @return
+ * Optionally update hooks may return a translated string that will be displayed
+ * to the user. If no message is returned, no message will be presented to the
+ * user.
*/
function hook_update_N(&$sandbox = NULL) {
// For most updates, the following is sufficient.
- $ret = array();
- db_add_field($ret, 'mytable1', 'newcol', array('type' => 'int', 'not null' => TRUE, 'description' => 'My new integer column.'));
- return $ret;
+ db_add_field('mytable1', 'newcol', array('type' => 'int', 'not null' => TRUE, 'description' => 'My new integer column.'));
// However, for more complex operations that may take a long time,
// you may hook into Batch API as in the following example.
- $ret = array();
// Update 3 users at a time to have an exclamation point after their names.
// (They're really happy that we can do batch API in this hook!)
@@ -1938,15 +1936,23 @@ function hook_update_N(&$sandbox = NULL) {
->execute();
foreach ($users as $user) {
$user->name .= '!';
- $ret[] = update_sql("UPDATE {users} SET name = '$user->name' WHERE uid = $user->uid");
+ db_update('users')
+ ->fields(array('name' => $user->name))
+ ->condition('uid', $user->uid)
+ ->execute();
$sandbox['progress']++;
$sandbox['current_uid'] = $user->uid;
}
- $ret['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
+ $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
+
+ // To display a message to the user when the update is completed, return it.
+ // If you do not want to display a completion message, simply return nothing.
+ return t('The update did what it was supposed to do.');
- return $ret;
+ // In case of an error, simply throw an exception with an error message.
+ throw new DrupalUpdateException('Something went wrong; here is what you should do.');
}
/**
diff --git a/modules/system/system.install b/modules/system/system.install
index 3245fc303..0f337467e 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -1527,7 +1527,6 @@ function system_update_last_removed() {
* Rename blog and forum permissions to be consistent with other content types.
*/
function system_update_7000() {
- $ret = array();
$result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
foreach ($result as $role) {
$renamed_permission = preg_replace('/(?<=^|,\ )create\ blog\ entries(?=,|$)/', 'create blog content', $role->perm);
@@ -1543,28 +1542,25 @@ function system_update_7000() {
$renamed_permission = preg_replace('/(?<=^|,\ )edit\ own\ forum\ topics(?=,|$)/', 'edit own forum content', $role->perm);
if ($renamed_permission != $role->perm) {
- $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid");
+ db_update('permission')
+ ->fields(array('perm' => $renamed_permission))
+ ->condition('rid', $role->rid)
+ ->execute();
}
}
-
- return $ret;
}
/**
* Generate a cron key and save it in the variables table.
*/
function system_update_7001() {
- $ret = array();
variable_set('cron_key', md5(mt_rand()));
- $ret[] = array('success' => TRUE, 'query' => "variable_set('cron_key')");
- return $ret;
}
/**
* Add a table to store blocked IP addresses.
*/
function system_update_7002() {
- $ret = array();
$schema['blocked_ips'] = array(
'description' => 'Stores blocked IP addresses.',
'fields' => array(
@@ -1588,16 +1584,14 @@ function system_update_7002() {
'primary key' => array('iid'),
);
- db_create_table($ret, 'blocked_ips', $schema['blocked_ips']);
-
- return $ret;
+ db_create_table('blocked_ips', $schema['blocked_ips']);
}
/**
* Update {blocked_ips} with valid IP addresses from {access}.
*/
function system_update_7003() {
- $ret = array();
+ $messages = array();
$type = 'host';
$result = db_query("SELECT mask FROM {access} WHERE status = :status AND type = :type", array(
':status' => 0,
@@ -1605,16 +1599,17 @@ function system_update_7003() {
));
foreach ($result as $blocked) {
if (filter_var($blocked->mask, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) !== FALSE) {
- $ret[] = update_sql("INSERT INTO {blocked_ips} (ip) VALUES ('$blocked->mask')");
+ db_insert('blocked_ips')
+ ->fields(array('ip' => $blocked->mask))
+ ->execute();
}
else {
$invalid_host = check_plain($blocked->mask);
- $ret[] = array('success' => TRUE, 'query' => 'The host ' . $invalid_host . ' is no longer blocked because it is not a valid IP address.');
+ $messages[] = t('The host !host is no longer blocked because it is not a valid IP address.', array('!host' => $invalid_host ));
}
}
if (isset($invalid_host)) {
drupal_set_message('Drupal no longer supports wildcard IP address blocking. Visitors whose IP addresses match ranges you have previously set using <em>access rules</em> will no longer be blocked from your site when you put the site online. See the <a href="http://drupal.org/node/24302">IP address and referrer blocking Handbook page</a> for alternative methods.', 'warning');
- $ret[] = array('success' => TRUE, 'query' => '');
}
// Make sure not to block any IP addresses that were specifically allowed by access rules.
if (!empty($result)) {
@@ -1622,19 +1617,22 @@ function system_update_7003() {
':status' => 1,
':type' => $type,
));
+ $or = db_condition('or');
foreach ($result as $allowed) {
- $ret[] = update_sql("DELETE FROM {blocked_ips} WHERE LOWER(ip) LIKE LOWER('$allowed->mask')");
+ $or->where('LOWER(ip) LIKE LOWER(:mask)', array(':mask' => $allowed->mask));
+ }
+ if (count($or)) {
+ db_delete('blocked_ips')
+ ->condition($or)
+ ->execute();
}
}
-
- return $ret;
}
/**
* Remove hardcoded numeric deltas from all blocks in core.
*/
function system_update_7004(&$sandbox) {
- $ret = array();
// Get an array of the renamed block deltas, organized by module.
$renamed_deltas = array(
'blog' => array('0' => 'recent'),
@@ -1672,7 +1670,11 @@ function system_update_7004(&$sandbox) {
))
->fetchField();
if ($block_exists) {
- $ret[] = update_sql("UPDATE {" . $table . "} SET delta = '" . $new_delta . "' WHERE module = '" . $module . "' AND delta = '" . $old_delta . "'");
+ db_update($table)
+ ->fields(array('delta' => $new_delta))
+ ->condition('module', $module)
+ ->condition('delta', $old_delta)
+ ->execute();
}
}
}
@@ -1728,24 +1730,20 @@ function system_update_7004(&$sandbox) {
}
// Indicate our current progress to the batch update system.
if ($sandbox['progress'] < $sandbox['max']) {
- $ret['#finished'] = $sandbox['progress'] / $sandbox['max'];
+ $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max'];
}
- return $ret;
}
/**
* Remove throttle columns and variables.
*/
function system_update_7005() {
- $ret = array();
- db_drop_field($ret, 'blocks', 'throttle');
- db_drop_field($ret, 'system', 'throttle');
+ db_drop_field('blocks', 'throttle');
+ db_drop_field('system', 'throttle');
variable_del('throttle_user');
variable_del('throttle_anonymous');
variable_del('throttle_level');
variable_del('throttle_probability_limiter');
-
- return $ret;
}
/**
@@ -1753,7 +1751,6 @@ function system_update_7005() {
* longer needed.
*/
function system_update_7006() {
- $ret = array();
$schema['registry'] = array(
'fields' => array(
'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
@@ -1787,11 +1784,10 @@ function system_update_7006() {
'indexes' => array('expire' => array('expire')),
'primary key' => array('cid'),
);
- db_create_table($ret, 'cache_registry', $schema['cache_registry']);
- db_create_table($ret, 'registry', $schema['registry']);
- db_create_table($ret, 'registry_file', $schema['registry_file']);
+ db_create_table('cache_registry', $schema['cache_registry']);
+ db_create_table('registry', $schema['registry']);
+ db_create_table('registry_file', $schema['registry_file']);
registry_rebuild();
- return $ret;
}
/**
@@ -1801,8 +1797,6 @@ function system_update_7006() {
* all modules can use the updated permission scheme during their updates.
*/
function system_update_7007() {
- $ret = array();
-
$schema['role_permission'] = array(
'fields' => array(
'rid' => array(
@@ -1823,9 +1817,10 @@ function system_update_7007() {
),
);
- db_create_table($ret, 'role_permission', $schema['role_permission']);
+ db_create_table('role_permission', $schema['role_permission']);
// Copy the permissions from the old {permission} table to the new {role_permission} table.
+ $messages = array();
$result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid ASC");
$query = db_insert('role_permission')->fields(array('rid', 'permission'));
foreach ($result as $role) {
@@ -1835,12 +1830,12 @@ function system_update_7007() {
'permission' => $perm,
));
}
- $ret[] = array('success' => TRUE, 'query' => "Inserted into {role_permission} the permissions for role ID " . $role->rid);
+ $messages[] = t('Inserted into {role_permission} the permissions for role ID !id', array('!id' => $role->rid));
}
$query->execute();
- db_drop_table($ret, 'permission');
+ db_drop_table('permission');
- return $ret;
+ return implode(', ', $messages);
}
@@ -1849,20 +1844,18 @@ function system_update_7007() {
* the choice order. Rename chorder to weight.
*/
function system_update_7008() {
- $ret = array();
if (db_table_exists('poll_votes')) {
// Add chid column and convert existing votes.
- db_add_field($ret, 'poll_votes', 'chid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
- db_add_index($ret, 'poll_votes', 'chid', array('chid'));
- $ret[] = update_sql("UPDATE {poll_votes} SET chid = (SELECT chid FROM {poll_choices} c WHERE {poll_votes}.chorder = c.chorder AND {poll_votes}.nid = c.nid)");
+ db_add_field('poll_votes', 'chid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+ db_add_index('poll_votes', 'chid', array('chid'));
+ db_query("UPDATE {poll_votes} SET chid = (SELECT chid FROM {poll_choices} c WHERE {poll_votes}.chorder = c.chorder AND {poll_votes}.nid = c.nid)");
// Remove old chorder column.
- db_drop_field($ret, 'poll_votes', 'chorder');
+ db_drop_field('poll_votes', 'chorder');
}
if (db_table_exists('poll_choices')) {
// Change the chorder column to weight in poll_choices.
- db_change_field($ret, 'poll_choices', 'chorder', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
+ db_change_field('poll_choices', 'chorder', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
}
- return $ret;
}
/**
@@ -1870,30 +1863,29 @@ function system_update_7008() {
*
*/
function system_update_7009() {
- $ret = array();
- $ret[] = update_sql("UPDATE {variable} SET name = 'menu_main_links_source' WHERE name = 'menu_primary_links_source'");
-
- return $ret;
+ db_update('variable')
+ ->fields(array('name' => 'main_menu_links_source'))
+ ->condition('name', 'menu_primary_links_source')
+ ->execute();
}
/**
* Moved to system_update_6048().
*/
function system_update_7010() {
- return array();
+ return '';
}
/**
* Split the 'bypass node access' permission from 'administer nodes'.
*/
function system_update_7011() {
- $ret = array();
// Get existing roles that can 'administer nodes'.
$rids = array();
$rids = db_query("SELECT rid FROM {role_permission} WHERE permission = :perm", array(':perm' => 'administer nodes'))->fetchCol();
// None found.
if (empty($rids)) {
- return $ret;
+ return;
}
$insert = db_insert('role_permission')->fields(array('rid', 'permission'));
foreach ($rids as $rid) {
@@ -1903,7 +1895,6 @@ function system_update_7011() {
));
}
$insert->execute();
- return $ret;
}
/**
@@ -1911,18 +1902,15 @@ function system_update_7011() {
* {boxes} to {box}.
*/
function system_update_7012() {
- $ret = array();
- db_rename_table($ret, 'blocks', 'block');
- db_rename_table($ret, 'blocks_roles', 'block_role');
- db_rename_table($ret, 'boxes', 'box');
- return $ret;
+ db_rename_table('blocks', 'block');
+ db_rename_table('blocks_roles', 'block_role');
+ db_rename_table('boxes', 'box');
}
/**
* Convert default time zone offset to default time zone name.
*/
function system_update_7013() {
- $ret = array();
$timezone = NULL;
$timezones = system_time_zones();
// If the contributed Date module set a default time zone name, use this
@@ -1956,32 +1944,33 @@ function system_update_7013() {
}
variable_set('date_default_timezone', $timezone);
drupal_set_message('The default time zone has been set to <em>' . check_plain($timezone) . '</em>. Please check the ' . l('date and time configuration page', 'admin/config/regional/settings') . ' to configure it correctly.', 'warning');
- return $ret;
}
/**
* Drop the bootstrap column from the {system} table. This was reverted.
*/
function system_update_7014() {
- $ret = array();
- return $ret;
}
/**
* Change the user logout path.
*/
function system_update_7015() {
- $ret = array();
- $ret[] = update_sql("UPDATE {menu_links} SET link_path = 'user/logout' WHERE link_path = 'logout'");
- $ret[] = update_sql("UPDATE {menu_links} SET router_path = 'user/logout' WHERE router_path = 'logout'");
- return $ret;
+ db_update('menu_links')
+ ->fields(array('link_path' => 'user/logout'))
+ ->condition('link_path', 'logout')
+ ->execute();
+
+ db_update('menu_links')
+ ->fields(array('router_path' => 'user/logout'))
+ ->condition('router_path', 'logout')
+ ->execute();
}
/**
* Remove custom datatype *_unsigned in PostgreSQL.
*/
function system_update_7016() {
- $ret = array();
// Only run these queries if the driver used is pgsql.
if (db_driver() == 'pgsql') {
$result = db_query("SELECT c.relname AS table, a.attname AS field,
@@ -2001,28 +1990,25 @@ function system_update_7016() {
$datatype = 'bigint';
break;
}
- $ret[] = update_sql('ALTER TABLE ' . $row->table . ' ALTER COLUMN ' . $row->field . ' TYPE ' . $datatype);
- $ret[] = update_sql('ALTER TABLE ' . $row->table . ' ADD CHECK (' . $row->field . ' >= 0)');
+ db_query('ALTER TABLE ' . $row->table . ' ALTER COLUMN ' . $row->field . ' TYPE ' . $datatype);
+ db_query('ALTER TABLE ' . $row->table . ' ADD CHECK (' . $row->field . ' >= 0)');
}
- $ret[] = update_sql('DROP DOMAIN smallint_unsigned');
- $ret[] = update_sql('DROP DOMAIN int_unsigned');
- $ret[] = update_sql('DROP DOMAIN bigint_unsigned');
+ db_query('DROP DOMAIN smallint_unsigned');
+ db_query('DROP DOMAIN int_unsigned');
+ db_query('DROP DOMAIN bigint_unsigned');
}
- return $ret;
}
/**
* Change the theme setting 'toggle_node_info' into a per content type variable.
*/
function system_update_7017() {
- $ret = array();
$types = node_type_get_types();
if (count($types)) {
foreach ($types as $type) {
$node_info = theme_get_setting('toggle_node_info_' . $type->type);
if ($node_info !== NULL) {
variable_set('node_submitted_' . $type->type, $node_info);
- $ret[] = array('success' => TRUE, 'query' => "variable_set('node_submitted_$type->type')");
}
}
}
@@ -2035,85 +2021,148 @@ function system_update_7017() {
}
}
variable_set('theme_settings', $theme_settings);
- $ret[] = array('success' => TRUE, 'query' => "variable_set('theme_settings')");
-
- return $ret;
}
/**
* Shorten the {system}.type column and add an index on type and name.
*/
function system_update_7018() {
- $ret = array();
- db_drop_index($ret, 'system', 'modules');
- db_drop_index($ret, 'system', 'type_name');
- db_change_field($ret, 'system', 'type', 'type', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
- db_add_index($ret, 'system', 'modules', array('type', 'status', 'weight', 'name'));
- db_add_index($ret, 'system', 'type_name', array('type', 'name'));
- return $ret;
+ db_drop_index('system', 'modules');
+ db_drop_index('system', 'type_name');
+ db_change_field('system', 'type', 'type', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
+ db_add_index('system', 'modules', array('type', 'status', 'weight', 'name'));
+ db_add_index('system', 'type_name', array('type', 'name'));
}
/**
* Enable field module.
*/
function system_update_7020() {
- $ret = array();
$module_list = array('field_sql_storage', 'field');
drupal_install_modules($module_list);
module_enable($module_list);
- return $ret;
}
/**
* Add new blocks to new regions, migrate custom variables to blocks.
*/
function system_update_7021() {
- $ret = array();
-
// Collect a list of themes with blocks.
$themes_with_blocks = array();
$result = db_query("SELECT s.name FROM {system} s INNER JOIN {block} b ON s.name = b.theme WHERE s.type = 'theme' GROUP by s.name");
+
+ $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($result as $theme) {
$themes_with_blocks[] = $theme->name;
// Add new system generated help block.
- $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('system', 'help', '" . $theme->name . "', 1, 0, 'help', '', 1)");
+ $insert->values(array(
+ 'module' => 'system',
+ 'delta' => 'help',
+ 'theme' => $theme->name,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'help',
+ 'pages' => '',
+ 'cache' => 1,
+ ));
// Add new system generated main page content block.
- $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('system', 'main', '" . $theme->name . "', 1, 0, 'content', '', -1)");
+ $insert->values(array(
+ 'module' => 'system',
+ 'delta' => 'main',
+ 'theme' => $theme->name,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'content',
+ 'pages' => '',
+ 'cache' => -1,
+ ));
}
+ $insert->execute();
// Migrate blocks from left/right regions to first/second regions.
- $ret[] = update_sql("UPDATE {block} SET region = 'sidebar_first' WHERE region = 'left'");
- $ret[] = update_sql("UPDATE {block} SET region = 'sidebar_second' WHERE region = 'right'");
+ db_update('block')
+ ->fields(array('region' => 'sidebar_first'))
+ ->condition('region', 'left')
+ ->execute();
+ db_update('block')
+ ->fields(array('region' => 'sidebar_second'))
+ ->condition('region', 'right')
+ ->execute();
// Migrate contact form information.
$default_format = variable_get('filter_default_format', 1);
if ($contact_help = variable_get('contact_form_information', '')) {
- $bid = db_insert('box')->fields(array('body' => $contact_help, 'info' => 'Contact page help', 'format' => $default_format))->execute();
+ $bid = db_insert('box')
+ ->fields(array(
+ 'body' => $contact_help,
+ 'info' => 'Contact page help',
+ 'format' => $default_format,
+ ))
+ ->execute();
+
+ $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
foreach ($themes_with_blocks as $theme) {
// Add contact help block for themes, which had blocks.
- $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, visibility, pages, cache) VALUES ('block', '" . $bid . "', '" . $theme . "', 1, 5, 'help', 1, 'contact', -1)");
+ $insert->values(array(
+ 'module' => 'block',
+ 'delta' => $bid,
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 5,
+ 'region' => 'help',
+ 'visibility' => 1,
+ 'pages' => 'contact',
+ 'cache' => -1,
+ ));
}
drupal_set_message('The contact form information setting was migrated to <a href="' . url('admin/structure/block/configure/block/' . $bid) . '">a custom block</a> and set up to only show on the site-wide contact page. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right.');
}
+ $insert->execute();
// Migrate user help setting.
if ($user_help = variable_get('user_registration_help', '')) {
$bid = db_insert('box')->fields(array('body' => $user_help, 'info' => 'User registration guidelines', 'format' => $default_format))->execute();
+
+ $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
foreach ($themes_with_blocks as $theme) {
// Add user registration help block for themes, which had blocks.
- $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, visibility, pages, cache) VALUES ('block', '" . $bid . "', '" . $theme . "', 1, 5, 'help', 1, 'user/register', -1)");
+ $insert->values(array(
+ 'module' => 'block',
+ 'delta' => $bid,
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 5,
+ 'region' => 'help',
+ 'visibility' => 1,
+ 'pages' => 'user/register',
+ 'cache' => -1,
+ ));
}
drupal_set_message('The user registration guidelines were migrated to <a href="' . url('admin/structure/block/configure/block/' . $bid) . '">a custom block</a> and set up to only show on the user registration page. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right.');
+ $insert->execute();
}
// Migrate site mission setting.
if ($mission = variable_get('site_mission')) {
$bid = db_insert('box')->fields(array('body' => $mission, 'info' => 'Site mission', 'format' => $default_format))->execute();
+
+ $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
foreach ($themes_with_blocks as $theme) {
// Add mission block for themes, which had blocks.
- $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, visibility, pages, cache) VALUES ('block', '" . $bid . "', '" . $theme . "', 1, 0, 'highlight', 1, '<front>', -1)");
+ $insert->values(array(
+ 'module' => 'block',
+ 'delta' => $bid,
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'highlight',
+ 'visibility' => 1,
+ 'pages' => '<front>',
+ 'cache' => -1,
+ ));
}
drupal_set_message('The site mission was migrated to <a href="' . url('admin/structure/block/configure/block/' . $bid) . '">a custom block</a> and set up to only show on the front page in the highlighted content region. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right. If your theme does not have a highlighted content region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
+ $insert->execute();
// Migrate mission to RSS site description.
variable_set('feed_description', $mission);
}
@@ -2121,13 +2170,25 @@ function system_update_7021() {
// Migrate site footer message to a custom block.
if ($footer_message = variable_get('site_footer', '')) {
$bid = db_insert('box')->fields(array('body' => $footer_message, 'info' => 'Footer message', 'format' => $default_format))->execute();
+
+ $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($themes_with_blocks as $theme) {
// Add site footer block for themes, which had blocks.
// Set low weight, so the block comes early (it used to be
// before the other blocks).
- $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('block', '" . $bid . "', '" . $theme . "', 1, -10, 'footer', '', -1)");
+ $insert->values(array(
+ 'module' => 'block',
+ 'delta' => $bid,
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => -10,
+ 'region' => 'footer',
+ 'pages' => '',
+ 'cache' => -1,
+ ));
}
drupal_set_message('The footer message was migrated to <a href="' . url('admin/structure/block/configure/block/' . $bid) . '">a custom block</a> and set up to appear in the footer. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right. If your theme does not have a footer region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
+ $insert->execute();
}
// Remove the variables (even if they were saved empty on the admin interface),
@@ -2139,16 +2200,12 @@ function system_update_7021() {
// Rebuild theme data, so the new 'help' region is identified.
system_get_theme_data();
-
- return $ret;
}
/**
* Add the queue tables.
*/
function system_update_7022() {
- $ret = array();
-
$schema['queue'] = array(
'description' => 'Stores items in queues.',
'fields' => array(
@@ -2209,19 +2266,19 @@ function system_update_7022() {
),
'primary key' => array('consumer_id'),
);
- db_create_table($ret, 'queue', $schema['queue']);
- db_create_table($ret, 'queue_consumer_id', $schema['queue_consumer_id']);
- return $ret;
+ db_create_table('queue', $schema['queue']);
+ db_create_table('queue_consumer_id', $schema['queue_consumer_id']);
}
/**
* Change the PHP for settings permission.
*/
function system_update_7023() {
- $ret = array();
- $ret[] = update_sql("UPDATE {role_permission} SET permission = 'use PHP for settings' WHERE permission = 'use PHP for block visibility'");
- return $ret;
+ db_update('role_permission')
+ ->fields(array('permission' => 'use PHP for settings'))
+ ->condition('permission', 'use PHP for block visibility')
+ ->execute();
}
/**
@@ -2231,28 +2288,22 @@ function system_update_7023() {
* for driver-specific updates yet.
*/
function system_update_7024() {
- $ret = array();
-
if (db_driver() == 'pgsql') {
- $ret[] = update_sql('CREATE OR REPLACE FUNCTION "substring_index"(text, text, integer) RETURNS text AS
+ db_query('CREATE OR REPLACE FUNCTION "substring_index"(text, text, integer) RETURNS text AS
\'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\'
LANGUAGE \'sql\''
);
}
-
- return $ret;
}
/**
* Improve indexes on the {url_alias} table.
*/
function system_update_7025() {
- $ret = array();
- db_drop_index($ret, 'url_alias', 'src_language');
- db_drop_index($ret, 'url_alias', 'dst_language');
- db_add_index($ret, 'url_alias', 'dst_language_pid', array('dst', 'language', 'pid'));
- db_add_index($ret, 'url_alias', 'src_language_pid', array('src', 'language', 'pid'));
- return $ret;
+ db_drop_index('url_alias', 'src_language');
+ db_drop_index('url_alias', 'dst_language');
+ db_add_index('url_alias', 'dst_language_pid', array('dst', 'language', 'pid'));
+ db_add_index('url_alias', 'src_language_pid', array('src', 'language', 'pid'));
}
/**
@@ -2260,38 +2311,34 @@ function system_update_7025() {
*
*/
function system_update_7026() {
- $ret = array();
- db_change_field($ret, 'url_alias', 'src', 'src', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
- db_change_field($ret, 'url_alias', 'dst', 'dst', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
- return $ret;
+ db_change_field('url_alias', 'src', 'src', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
+ db_change_field('url_alias', 'dst', 'dst', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
}
/**
* Enable field type modules.
*/
function system_update_7027() {
- $ret = array();
$module_list = array('text', 'number', 'list', 'options');
- db_delete('system')->condition('type', 'module')->condition('name', $module_list)->execute();
+ db_delete('system')
+ ->condition('type', 'module')
+ ->condition('name', $module_list)
+ ->execute();
drupal_install_modules($module_list);
module_enable($module_list);
- return $ret;
}
/**
* Rename taxonomy tables.
*/
function system_update_7028() {
- $ret = array();
- db_rename_table($ret, 'term_data', 'taxonomy_term_data');
- db_rename_table($ret, 'term_hierarchy', 'taxonomy_term_hierarchy');
- db_rename_table($ret, 'term_node', 'taxonomy_term_node');
- db_rename_table($ret, 'term_relation', 'taxonomy_term_relation');
- db_rename_table($ret, 'term_synonym', 'taxonomy_term_synonym');
- db_rename_table($ret, 'vocabulary', 'taxonomy_vocabulary');
- db_rename_table($ret, 'vocabulary_node_types', 'taxonomy_vocabulary_node_type');
-
- return $ret;
+ db_rename_table('term_data', 'taxonomy_term_data');
+ db_rename_table('term_hierarchy', 'taxonomy_term_hierarchy');
+ db_rename_table('term_node', 'taxonomy_term_node');
+ db_rename_table('term_relation', 'taxonomy_term_relation');
+ db_rename_table('term_synonym', 'taxonomy_term_synonym');
+ db_rename_table('vocabulary', 'taxonomy_vocabulary');
+ db_rename_table('vocabulary_node_types', 'taxonomy_vocabulary_node_type');
}
/**
@@ -2299,62 +2346,51 @@ function system_update_7028() {
* Preserves legacy behavior from Drupal 6.x.
*/
function system_update_7029() {
- $ret = array();
db_insert('role_permission')
->fields(array(
'rid' => DRUPAL_AUTHENTICATED_RID,
'permission' => 'view own unpublished content',
))
->execute();
- return $ret;
}
/**
* Add an index to node_comment_statistics on comment_count.
*/
function system_update_7030() {
- $ret = array();
- db_add_index($ret, 'node_comment_statistics', 'comment_count', array('comment_count'));
- return $ret;
+ db_add_index('node_comment_statistics', 'comment_count', array('comment_count'));
}
/**
* Add a missing index on the {menu_router} table.
*/
function system_update_7031() {
- $ret = array();
- db_add_index($ret, 'menu_router', 'tab_root_weight_title', array(array('tab_root', 64), 'weight', 'title'));
- return $ret;
+ db_add_index('menu_router', 'tab_root_weight_title', array(array('tab_root', 64), 'weight', 'title'));
}
/**
* Alter field hostname to identifier in the {flood} table.
*/
function system_update_7032() {
- $ret = array();
- db_drop_index($ret, 'flood', 'allow');
- db_change_field($ret, 'flood', 'hostname', 'identifier', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
- db_add_index($ret, 'flood', 'allow', array('event', 'identifier', 'timestamp'));
- return $ret;
+ db_drop_index('flood', 'allow');
+ db_change_field('flood', 'hostname', 'identifier', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
+ db_add_index('flood', 'allow', array('event', 'identifier', 'timestamp'));
}
/**
* Move CACHE_AGGRESSIVE to CACHE_NORMAL.
*/
function system_update_7033() {
- $ret = array();
if (variable_get('cache') == 2) {
variable_set('cache', CACHE_NORMAL);
- $ret[] = array('success' => TRUE, 'query' => "Aggressive caching was disabled and replaced with normal caching, please read the page caching section in default.settings.php for more information on how to enable similar functionality.");
+ return t('Aggressive caching was disabled and replaced with normal caching, please read the page caching section in default.settings.php for more information on how to enable similar functionality.');
}
- return $ret;
}
/**
* Migrate the file_downloads setting and create the new {file} table.
*/
function system_update_7034() {
- $ret = array();
$files_directory = variable_get('file_directory_path', NULL);
if (variable_get('file_downloads', 1) == 1) {
// Our default is public, so we don't need to set anything.
@@ -2438,18 +2474,18 @@ function system_update_7034() {
),
'primary key' => array('fid'),
);
- db_create_table($ret, 'file', $schema['file']);
- return $ret;
+
+ db_create_table('file', $schema['file']);
}
/**
* Migrate upload module files to the new {file} table.
*/
function system_update_7035() {
- $ret = array();
if (!db_table_exists('upload')) {
- return $ret;
+ return;
}
+
// The old {files} tables still exists. We migrate core data from upload
// module, but any contrib module using it will need to do its own update.
$result = db_query('SELECT fid, uid, filename, filepath AS uri, filemime, filesize, status, timestamp FROM {files} f INNER JOIN {upload} u ON u.fid = f.fid', array(), array('fetch' => PDO::FETCH_ASSOC));
@@ -2459,7 +2495,7 @@ function system_update_7035() {
$basename = variable_get('file_directory_path', conf_path() . '/files');
$scheme = variable_get('file_default_scheme', 'public') . '://';
$fids = array();
- // TODO: does this function need to run in batch mode?
+ // TODO: does this function need to run in batch mode, or should we use a multi-insert?
foreach ($result as $file) {
$file['uri'] = $scheme . str_replace($basename, '', $file['uri']);
$file['uri'] = file_stream_wrapper_uri_normalize($file['uri']);
@@ -2467,19 +2503,17 @@ function system_update_7035() {
$fids[] = $file['fid'];
}
// TODO: delete the found fids from {files}?
- return $ret;
}
/**
* Split the 'access site in maintenance mode' permission from 'administer site configuration'.
*/
function system_update_7036() {
- $ret = array();
// Get existing roles that can 'administer site configuration'.
$rids = db_query("SELECT rid FROM {role_permission} WHERE permission = :perm", array(':perm' => 'administer site configuration'))->fetchCol();
// None found.
if (empty($rids)) {
- return $ret;
+ return;
}
$insert = db_insert('role_permission')->fields(array('rid', 'permission'));
foreach ($rids as $rid) {
@@ -2493,26 +2527,20 @@ function system_update_7036() {
// Remove obsolete variable 'site_offline_message'.
// @see update_fix_d7_requirements().
variable_del('site_offline_message');
-
- return $ret;
}
/**
* Rename {box} table to {block_custom}.
*/
function system_update_7037() {
- $ret = array();
- db_rename_table($ret, 'box', 'block_custom');
- return $ret;
+ db_rename_table('box', 'block_custom');
}
/**
* Rename action description to label.
*/
function system_update_7038() {
- $ret = array();
- db_change_field($ret, 'actions', 'description', 'label', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0'));
- return $ret;
+ db_change_field('actions', 'description', 'label', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0'));
}
/**
diff --git a/modules/taxonomy/taxonomy.install b/modules/taxonomy/taxonomy.install
index c4c2a542c..5aaaa4ef2 100644
--- a/modules/taxonomy/taxonomy.install
+++ b/modules/taxonomy/taxonomy.install
@@ -293,7 +293,6 @@ function taxonomy_schema() {
* Add vocabulary machine_name column.
*/
function taxonomy_update_7002() {
- $ret = array();
$field = array(
'type' => 'varchar',
'length' => 255,
@@ -302,7 +301,7 @@ function taxonomy_update_7002() {
'description' => 'The vocabulary machine name.',
);
- db_add_field($ret, 'taxonomy_vocabulary', 'machine_name', $field);
+ db_add_field('taxonomy_vocabulary', 'machine_name', $field);
foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
$machine_name = 'vocabulary_' . $vid;
@@ -312,7 +311,6 @@ function taxonomy_update_7002() {
->execute();
field_attach_create_bundle($machine_name);
}
- return $ret;
}
/**
@@ -322,8 +320,5 @@ function taxonomy_update_7002() {
* itself is retained to allow for data to be upgraded.
*/
function taxonomy_update_7003() {
- $ret = array();
- db_drop_field($ret, 'taxonomy_vocabulary', 'relations');
-
- return $ret;
+ db_drop_field('taxonomy_vocabulary', 'relations');
}
diff --git a/modules/tracker/tracker.install b/modules/tracker/tracker.install
index 1ceff152a..7e997a01e 100644
--- a/modules/tracker/tracker.install
+++ b/modules/tracker/tracker.install
@@ -197,16 +197,14 @@ function tracker_update_7000() {
),
);
- $ret = array();
foreach ($schema as $name => $table) {
- db_create_table($ret, $name, $table);
+ db_create_table($name, $table);
}
$max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
if ($max_nid != 0) {
variable_set('tracker_index_nid', $max_nid);
}
- return $ret;
}
/**
diff --git a/modules/trigger/trigger.install b/modules/trigger/trigger.install
index b8553e48c..95fb4fb2e 100644
--- a/modules/trigger/trigger.install
+++ b/modules/trigger/trigger.install
@@ -54,13 +54,15 @@ function trigger_schema() {
* Adds operation names to the hook names and drops the "op" field.
*/
function trigger_update_7000() {
- $ret = array();
$result = db_query("SELECT hook, op, aid FROM {trigger_assignments} WHERE op <> ''");
- while ($row = db_fetch_object($result)) {
- $ret[] = update_sql("UPDATE {trigger_assignments} SET hook = '%s' WHERE hook = '%s' AND op = '%s' AND aid = '%s'", $row->hook . '_' . $row->op, $row->hook, $row->op, $row->aid);
+ foreach ($result as $record) {
+ db_update('trigger_assignments')
+ ->fields(array('hook' => $record->hook . '_' . $record->op))
+ ->condition('hook', $record->hook)
+ ->condition('op', $record->op)
+ ->condition('aid', $record->aid)
+ ->execute();
}
- $ret[] = update_sql("ALTER TABLE {trigger_assignments} DROP op");
-
- return $ret;
+ db_drop_field('trigger_assignments', 'op');
}
diff --git a/modules/upload/upload.install b/modules/upload/upload.install
index 62acef717..87f817f81 100644
--- a/modules/upload/upload.install
+++ b/modules/upload/upload.install
@@ -82,7 +82,6 @@ function upload_schema() {
* Migrate upload module files from {files} to {file}.
*/
function upload_update_7000(&$sandbox) {
- $ret = array();
/*
TODO: Fix the updates. This is broken. See http://drupal.org/node/329301#comment-1404336
@@ -128,8 +127,6 @@ function upload_update_7000(&$sandbox) {
// Indicate our current progress to the batch update system. If there's no
// max value then there's nothing to update and we're finished.
- $ret['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
-
- return $ret;
+ $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
}
diff --git a/modules/user/user.install b/modules/user/user.install
index 889756e96..610d3d566 100644
--- a/modules/user/user.install
+++ b/modules/user/user.install
@@ -255,12 +255,12 @@ function user_schema() {
* lengthy process, and is performed batch-wise.
*/
function user_update_7000(&$sandbox) {
- $ret = array('#finished' => 0);
+ $sandbox['#finished'] = 0;
// Lower than DRUPAL_HASH_COUNT to make the update run at a reasonable speed.
$hash_count_log2 = 11;
// Multi-part update.
if (!isset($sandbox['user_from'])) {
- db_change_field($ret, 'users', 'pass', 'pass', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
+ db_change_field('users', 'pass', 'pass', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
$sandbox['user_from'] = 0;
$sandbox['user_count'] = db_query("SELECT COUNT(uid) FROM {users}")->fetchField();
}
@@ -283,14 +283,13 @@ function user_update_7000(&$sandbox) {
->execute();
}
}
- $ret['#finished'] = $sandbox['user_from']/$sandbox['user_count'];
+ $sandbox['#finished'] = $sandbox['user_from']/$sandbox['user_count'];
$sandbox['user_from'] += $count;
if (!$has_rows) {
- $ret['#finished'] = 1;
- $ret[] = array('success' => TRUE, 'query' => "UPDATE {users} SET pass = 'U' . user_hash_password(pass) WHERE uid > 0");
+ $sandbox['#finished'] = 1;
+ return t('User passwords rehashed to improve security');
}
}
- return $ret;
}
/**
@@ -300,23 +299,20 @@ function user_update_7000(&$sandbox) {
*/
function user_update_7001() {
- $ret = array();
- db_drop_field($ret, 'users', 'threshold');
- db_drop_field($ret, 'users', 'mode');
- db_drop_field($ret, 'users', 'sort');
-
- return $ret;
+ db_drop_field('users', 'threshold');
+ db_drop_field('users', 'mode');
+ db_drop_field('users', 'sort');
}
/**
* Convert user time zones from time zone offsets to time zone names.
*/
function user_update_7002(&$sandbox) {
- $ret = array('#finished' => 0);
+ $sandbox['#finished'] = 0;
// Multi-part update.
if (!isset($sandbox['user_from'])) {
- db_change_field($ret, 'users', 'timezone', 'timezone', array('type' => 'varchar', 'length' => 32, 'not null' => FALSE));
+ db_change_field('users', 'timezone', 'timezone', array('type' => 'varchar', 'length' => 32, 'not null' => FALSE));
$sandbox['user_from'] = 0;
$sandbox['user_count'] = db_query("SELECT COUNT(uid) FROM {users}")->fetchField();
$sandbox['user_not_migrated'] = 0;
@@ -355,25 +351,30 @@ function user_update_7002(&$sandbox) {
}
}
if ($timezone) {
- db_query("UPDATE {users} SET timezone = :timezone WHERE uid = :uid", array(':timezone' => $timezone, ':uid' => $account->uid));
+ db_update('users')
+ ->fields(array('timezone' => $timezone))
+ ->condition('uid', $account->uid)
+ ->execute();
}
else {
$sandbox['user_not_migrated']++;
- db_query("UPDATE {users} SET timezone = NULL WHERE uid = :uid", array(':uid' => $account->uid));
+ db_update('users')
+ ->fields(array('timezone', NULL))
+ ->condition('uid', $account->uid)
+ ->execute();
}
$sandbox['user_from']++;
}
- $ret['#finished'] = $sandbox['user_from'] / $sandbox['user_count'];
+ $sandbox['#finished'] = $sandbox['user_from'] / $sandbox['user_count'];
if ($sandbox['user_from'] == $sandbox['user_count']) {
- $ret[] = array('success' => TRUE, 'query' => "Migrate user time zones.");
if ($sandbox['user_not_migrated'] > 0) {
variable_set('empty_timezone_message', 1);
drupal_set_message('Some user time zones have been emptied and need to be set to the correct values. Use the new ' . l('time zone options', 'admin/config/regional/settings') . ' to choose whether to remind users at login to set the correct time zone.', 'warning');
}
+ return t('Migrated user time zones');
}
}
- return $ret;
}
/**
@@ -384,7 +385,6 @@ function user_update_7002(&$sandbox) {
* which is the same as the 'user_cancel_reassign' method now.
*/
function user_update_7003() {
- $ret = array();
// Set the default account cancellation method.
variable_set('user_cancel_method', 'user_cancel_reassign');
// Re-assign notification setting.
@@ -401,14 +401,12 @@ function user_update_7003() {
variable_set('user_mail_status_canceled_body', $setting);
variable_del('user_mail_status_deleted_body');
}
- return $ret;
}
/**
* Add the user's pictures to the {file} table and make them managed files.
*/
function user_update_7004(&$sandbox) {
- $ret = array();
$picture_field = array(
'type' => 'int',
@@ -422,7 +420,7 @@ function user_update_7004(&$sandbox) {
// update.
if (!db_column_exists('users', 'picture_fid')) {
// Add a new field for the fid.
- db_add_field($ret, 'users', 'picture_fid', $picture_field);
+ db_add_field('users', 'picture_fid', $picture_field);
}
// Initialize batch update information.
@@ -469,16 +467,14 @@ function user_update_7004(&$sandbox) {
// Indicate our current progress to the batch update system. If there's no
// max value then there's nothing to update and we're finished.
- $ret['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
+ $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
// When we're finished, drop the old picture field and rename the new one to
// replace it.
- if (isset($ret['#finished']) && $ret['#finished'] == 1) {
- db_drop_field($ret, 'user', 'picture');
- db_change_field($ret, 'user', 'picture_fid', 'picture', $picture_field);
+ if (isset($sandbox['#finished']) && $sandbox['#finished'] == 1) {
+ db_drop_field('user', 'picture');
+ db_change_field('user', 'picture_fid', 'picture', $picture_field);
}
-
- return $ret;
}
/**