summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/update.inc52
-rw-r--r--modules/system/system.install62
2 files changed, 93 insertions, 21 deletions
diff --git a/includes/update.inc b/includes/update.inc
index 92844b21e..81e07ff8a 100644
--- a/includes/update.inc
+++ b/includes/update.inc
@@ -220,6 +220,7 @@ function update_prepare_d7_bootstrap() {
* An associative array. Keys are module names, values an associative array
* mapping the old block deltas to the new block deltas for the module.
* Example:
+ * @code
* $renamed_deltas = array(
* 'mymodule' =>
* array(
@@ -227,8 +228,21 @@ function update_prepare_d7_bootstrap() {
* 1 => 'mymodule-block-2',
* ),
* );
+ * @endcode
+ * @param $moved_deltas
+ * An associative array. Keys are source module names, values an associative
+ * array mapping the (possibly renamed) block name to the new module name.
+ * Example:
+ * @code
+ * $moved_deltas = array(
+ * 'user' =>
+ * array(
+ * 'navigation' => 'system',
+ * ),
+ * );
+ * @endcode
*/
-function update_fix_d7_block_deltas(&$sandbox, $renamed_deltas) {
+function update_fix_d7_block_deltas(&$sandbox, $renamed_deltas, $moved_deltas) {
// Loop through each block and make changes to the block tables.
// Only run this the first time through the batch update.
if (!isset($sandbox['progress'])) {
@@ -239,10 +253,10 @@ function update_fix_d7_block_deltas(&$sandbox, $renamed_deltas) {
foreach ($deltas as $old_delta => $new_delta) {
// Only do the update if the old block actually exists.
$block_exists = db_query("SELECT COUNT(*) FROM {" . $table . "} WHERE module = :module AND delta = :delta", array(
- ':module' => $module,
- ':delta' => $old_delta,
- ))
- ->fetchField();
+ ':module' => $module,
+ ':delta' => $old_delta,
+ ))
+ ->fetchField();
if ($block_exists) {
db_update($table)
->fields(array('delta' => $new_delta))
@@ -252,6 +266,23 @@ function update_fix_d7_block_deltas(&$sandbox, $renamed_deltas) {
}
}
}
+ foreach ($moved_deltas as $old_module => $deltas) {
+ foreach ($deltas as $delta => $new_module) {
+ // Only do the update if the old block actually exists.
+ $block_exists = db_query("SELECT COUNT(*) FROM {" . $table . "} WHERE module = :module AND delta = :delta", array(
+ ':module' => $old_module,
+ ':delta' => $delta,
+ ))
+ ->fetchField();
+ if ($block_exists) {
+ db_update($table)
+ ->fields(array('module' => $new_module))
+ ->condition('module', $old_module)
+ ->condition('delta', $delta)
+ ->execute();
+ }
+ }
+ }
}
// Initialize batch update information.
@@ -281,6 +312,17 @@ function update_fix_d7_block_deltas(&$sandbox, $renamed_deltas) {
}
}
}
+ foreach ($moved_deltas as $old_module => $deltas) {
+ foreach ($deltas as $delta => $new_module) {
+ if (isset($data['block'][$old_module][$delta])) {
+ // Transfer the old block visibility settings to the moved
+ // block, and mark this user for a database update.
+ $data['block'][$new_module][$delta] = $data['block'][$old_module][$delta];
+ unset($data['block'][$old_module][$delta]);
+ $user_needs_update = TRUE;
+ }
+ }
+ }
// Update the current user.
if ($user_needs_update) {
db_update('users')
diff --git a/modules/system/system.install b/modules/system/system.install
index 47b04d1f2..0b691a20d 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -1632,6 +1632,18 @@ function system_update_last_removed() {
}
/**
+ * Implements hook_update_dependencies().
+ */
+function system_update_dependencies() {
+ // Update 7053 adds new blocks, so make sure the block tables are updated.
+ $dependencies['system'][7053] = array(
+ 'block' => 7002,
+ );
+
+ return $dependencies;
+}
+
+/**
* @defgroup updates-6.x-to-7.x System updates from 6.x to 7.x
* @{
*/
@@ -1770,6 +1782,10 @@ function system_update_7004(&$sandbox) {
),
);
+ $moved_deltas = array(
+ 'user' => array('navigation' => 'system'),
+ );
+
// Only run this the first time through the batch update.
if (!isset($sandbox['progress'])) {
// Rename forum module's block variables.
@@ -1785,7 +1801,7 @@ function system_update_7004(&$sandbox) {
}
}
- update_fix_d7_block_deltas($sandbox, $renamed_deltas);
+ update_fix_d7_block_deltas($sandbox, $renamed_deltas, $moved_deltas);
}
@@ -1844,14 +1860,14 @@ function system_update_7008() {
}
/**
- * Rename the variables for primary and secondary links.
- *
+ * Rename the variable for primary links.
*/
function system_update_7009() {
- db_update('variable')
- ->fields(array('name' => 'main_menu_links_source'))
- ->condition('name', 'menu_primary_links_source')
- ->execute();
+ $current_primary = variable_get('menu_primary_links_source');
+ if (isset($current_primary)) {
+ variable_set('menu_main_links_source', $current_primary);
+ variable_del('menu_primary_links_source');
+ }
}
/**
@@ -2400,15 +2416,6 @@ function system_update_7052() {
* Upgrade standard blocks and menus.
*/
function system_update_7053() {
- // Navigation block is now defined in system module.
- if (db_table_exists('block')) {
- db_update('block')
- ->fields(array('module' => 'system'))
- ->condition('module', 'user')
- ->condition('delta', 'navigation')
- ->execute();
- }
-
if (db_table_exists('menu_custom')) {
// Create the same menus as in menu_install().
db_insert('menu_custom')
@@ -2419,6 +2426,29 @@ function system_update_7053() {
->fields(array('menu_name' => 'management', 'title' => 'Management', 'description' => "The <em>Management</em> menu contains links for administrative tasks."))
->execute();
}
+
+ block_flush_caches();
+
+ // Show the new menu blocks along the navigation block.
+ $blocks = db_query("SELECT theme, status, region, weight, visibility, pages FROM {block} WHERE module = 'system' AND delta = 'navigation'");
+ $deltas = db_or()
+ ->condition('delta', 'user-menu')
+ ->condition('delta', 'management');
+
+ foreach ($blocks as $block) {
+ db_update('block')
+ ->fields(array(
+ 'status' => $block->status,
+ 'region' => $block->region,
+ 'weight' => $block->weight,
+ 'visibility' => $block->visibility,
+ 'pages' => $block->pages,
+ ))
+ ->condition('theme', $block->theme)
+ ->condition('module', 'system')
+ ->condition($deltas)
+ ->execute();
+ }
}
/**