summaryrefslogtreecommitdiff
path: root/modules/system/system.install
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-13 06:15:39 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-13 06:15:39 +0000
commitc78283e81bb60fd6c4574ad65d2b854dca524a98 (patch)
tree04462912485cb4551b8a047743ca7661c55172ef /modules/system/system.install
parentb80bbba9af60c3b1be50901a26c1cf786e0cc6ef (diff)
downloadbrdo-c78283e81bb60fd6c4574ad65d2b854dca524a98.tar.gz
brdo-c78283e81bb60fd6c4574ad65d2b854dca524a98.tar.bz2
#606730 by hunmonk: Provide a helper function for block delta updates.
Diffstat (limited to 'modules/system/system.install')
-rw-r--r--modules/system/system.install66
1 files changed, 4 insertions, 62 deletions
diff --git a/modules/system/system.install b/modules/system/system.install
index b6c02d4e5..eeb81c0f0 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -1758,29 +1758,9 @@ function system_update_7004(&$sandbox) {
'3' => 'online',
),
);
- // Loop through each block and make changes to the core block tables.
+
// Only run this the first time through the batch update.
if (!isset($sandbox['progress'])) {
- $block_tables = array('blocks', 'blocks_roles');
- foreach ($block_tables as $table) {
- foreach ($renamed_deltas as $module => $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();
- if ($block_exists) {
- db_update($table)
- ->fields(array('delta' => $new_delta))
- ->condition('module', $module)
- ->condition('delta', $old_delta)
- ->execute();
- }
- }
- }
- }
// Rename forum module's block variables.
$forum_block_num_0 = variable_get('forum_block_num_0');
if (isset($forum_block_num_0)) {
@@ -1792,48 +1772,10 @@ function system_update_7004(&$sandbox) {
variable_set('forum_block_num_new', $forum_block_num_1);
variable_del('forum_block_num_1');
}
- // Initialize batch update information.
- $sandbox['progress'] = 0;
- $sandbox['last_user_processed'] = -1;
- $sandbox['max'] = db_query("SELECT COUNT(*) FROM {users} WHERE data IS NOT NULL")->fetchField();
- }
- // Now do the batch update of the user-specific block visibility settings.
- $limit = 100;
- $result = db_select('users', 'u')
- ->fields('u', array('uid', 'data'))
- ->condition('uid', $sandbox['last_user_processed'], '>')
- ->where('data IS NOT NULL')
- ->range(0, $limit)
- ->execute();
- foreach ($result as $row) {
- $data = unserialize($row->data);
- $user_needs_update = FALSE;
- foreach ($renamed_deltas as $module => $deltas) {
- foreach ($deltas as $old_delta => $new_delta) {
- if (isset($data['block'][$module][$old_delta])) {
- // Transfer the old block visibility settings to the newly-renamed
- // block, and mark this user for a database update.
- $data['block'][$module][$new_delta] = $data['block'][$module][$old_delta];
- unset($data['block'][$module][$old_delta]);
- $user_needs_update = TRUE;
- }
- }
- }
- // Update the current user.
- if ($user_needs_update) {
- db_update('users')
- ->fields(array('data' => serialize($data)))
- ->condition('uid', $row->uid)
- ->execute();
- }
- // Update our progress information for the batch update.
- $sandbox['progress']++;
- $sandbox['last_user_processed'] = $row->uid;
- }
- // Indicate our current progress to the batch update system.
- if ($sandbox['progress'] < $sandbox['max']) {
- $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max'];
}
+
+ update_fix_d7_block_deltas($sandbox, $renamed_deltas);
+
}
/**