summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-02-03 18:16:23 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-02-03 18:16:23 +0000
commitec407ec945da8b7afee5c20f16cac6c041db1e25 (patch)
tree7fc94e0c97a2a7c3a69fd8527a2b939cf6bb70ef /modules/system
parent59c9219fb7b91a9d159709fd04e81969a610c8cd (diff)
downloadbrdo-ec407ec945da8b7afee5c20f16cac6c041db1e25.tar.gz
brdo-ec407ec945da8b7afee5c20f16cac6c041db1e25.tar.bz2
#211182 by Damien Tournoud, David_Rothstein, clemens.tolboom, scor, hunmonk, et al: Allow updates to specify dependencies to ensure they run in a predictable order.
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/system.api.php45
-rw-r--r--modules/system/system.install202
2 files changed, 50 insertions, 197 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index c18058c4d..65ab9725c 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -2233,6 +2233,51 @@ function hook_update_N(&$sandbox) {
}
/**
+ * Return an array of information about module update dependencies.
+ *
+ * This can be used to indicate update functions from other modules that your
+ * module's update functions depend on, or vice versa. It is used by the update
+ * system to determine the appropriate order in which updates should be run, as
+ * well as to search for missing dependencies.
+ *
+ * Implementations of this hook should be placed in a mymodule.install file in
+ * the same directory as mymodule.module.
+ *
+ * @return
+ * A multidimensional array containing information about the module update
+ * dependencies. The first two levels of keys represent the module and update
+ * number (respectively) for which information is being returned, and the
+ * value is an array of information about that update's dependencies. Within
+ * this array, each key represents a module, and each value represents the
+ * number of an update function within that module. In the event that your
+ * update function depends on more than one update from a particular module,
+ * you should always list the highest numbered one here (since updates within
+ * a given module always run in numerical order).
+ *
+ * @see update_resolve_dependencies()
+ * @see hook_update_N()
+ */
+function hook_update_dependencies() {
+ // Indicate that the mymodule_update_7000() function provided by this module
+ // must run after the another_module_update_7002() function provided by the
+ // 'another_module' module.
+ $dependencies['mymodule'][7000] = array(
+ 'another_module' => 7002,
+ );
+ // Indicate that the mymodule_update_7001() function provided by this module
+ // must run before the yet_another_module_update_7004() function provided by
+ // the 'yet_another_module' module. (Note that declaring dependencies in this
+ // direction should be done only in rare situations, since it can lead to the
+ // following problem: If a site has already run the yet_another_module
+ // module's database updates before it updates its codebase to pick up the
+ // newest mymodule code, then the dependency declared here will be ignored.)
+ $dependencies['yet_another_module'][7004] = array(
+ 'mymodule' => 7001,
+ );
+ return $dependencies;
+}
+
+/**
* Return a number which is no longer available as hook_update_N().
*
* If you remove some update functions from your mymodule.install file, you
diff --git a/modules/system/system.install b/modules/system/system.install
index 5d1f63bf6..162c6b90d 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -1882,15 +1882,7 @@ function system_update_7011() {
$insert->execute();
}
-/**
- * Rename {blocks} table to {block}, {blocks_roles} to {block_role} and
- * {boxes} to {box}.
- */
-function system_update_7012() {
- db_rename_table('blocks', 'block');
- db_rename_table('blocks_roles', 'block_role');
- db_rename_table('boxes', 'box');
-}
+// system_update_7012() moved to block_update_7002().
/**
* Convert default time zone offset to default time zone name.
@@ -2028,175 +2020,9 @@ function system_update_7020() {
}
/**
- * Add new blocks to new regions, migrate custom variables to blocks.
- */
-function system_update_7021() {
- // 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.
- $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.
- $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.
- 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();
-
- $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.
- $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/manage/block/' . $bid . '/configure') . '">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. 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.
- $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/manage/block/' . $bid . '/configure') . '">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. 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.
- $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/manage/block/' . $bid . '/configure') . '">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. 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);
- }
-
- // 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).
- $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/manage/block/' . $bid . '/configure') . '">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. 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),
- // to avoid keeping clutter in the variables table.
- variable_del('contact_form_information');
- variable_del('user_registration_help');
- variable_del('site_mission');
- variable_del('site_footer');
-
- // Rebuild theme data, so the new 'help' region is identified.
- system_rebuild_theme_data();
-}
-
-/**
- * Add the queue tables.
- */
-function system_update_7022() {
- // Moved to update_fix_d7_requirements().
-}
-
-/**
* Change the PHP for settings permission.
*/
-function system_update_7023() {
+function system_update_7021() {
db_update('role_permission')
->fields(array('permission' => 'use PHP for settings'))
->condition('permission', 'use PHP for block visibility')
@@ -2245,18 +2071,7 @@ function system_update_7027() {
module_enable($module_list, FALSE);
}
-/**
- * Rename taxonomy tables.
- */
-function system_update_7028() {
- 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');
-}
+// system_update_7028() moved to taxonomy_update_7001().
/**
* Add new 'view own unpublished content' permission for authenticated users.
@@ -2404,7 +2219,7 @@ function system_update_7035() {
// 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));
+ $result = db_query('SELECT f.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));
// We will convert filepaths to uri using the default schmeme
// and stripping off the existing file directory path.
@@ -2446,16 +2261,9 @@ function system_update_7036() {
}
/**
- * Rename {box} table to {block_custom}.
- */
-function system_update_7037() {
- db_rename_table('box', 'block_custom');
-}
-
-/**
* Rename action description to label.
*/
-function system_update_7038() {
+function system_update_7037() {
db_change_field('actions', 'description', 'label', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0'));
}