aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/db/migration/data
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-10-04 12:10:27 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2013-10-04 12:10:27 -0500
commit9653276ebcd1a5c24302cb8d06f905f90e158e45 (patch)
treec9d3905e62636e9270dd4febf7b7b1d5fb96fe2a /phpBB/phpbb/db/migration/data
parentee89ede59faab3809cc61b7773a99f3e24376fb8 (diff)
downloadforums-9653276ebcd1a5c24302cb8d06f905f90e158e45.tar
forums-9653276ebcd1a5c24302cb8d06f905f90e158e45.tar.gz
forums-9653276ebcd1a5c24302cb8d06f905f90e158e45.tar.bz2
forums-9653276ebcd1a5c24302cb8d06f905f90e158e45.tar.xz
forums-9653276ebcd1a5c24302cb8d06f905f90e158e45.zip
[ticket/11881] Better split the timezone conversion into chunks; add test
PHPBB3-11881
Diffstat (limited to 'phpBB/phpbb/db/migration/data')
-rw-r--r--phpBB/phpbb/db/migration/data/v310/timezone.php32
1 files changed, 20 insertions, 12 deletions
diff --git a/phpBB/phpbb/db/migration/data/v310/timezone.php b/phpBB/phpbb/db/migration/data/v310/timezone.php
index 8443f7b492..13e2a5ceb6 100644
--- a/phpBB/phpbb/db/migration/data/v310/timezone.php
+++ b/phpBB/phpbb/db/migration/data/v310/timezone.php
@@ -42,28 +42,36 @@ class timezone extends \phpbb\db\migration\migration
public function update_timezones($start)
{
$start = (int) $start;
- $limit = 1;
- $converted_timezones = 0;
+ $limit = 5000;
+ $converted = 0;
- // Update user timezones
- $sql = 'SELECT user_dst, user_timezone
+ $update_blocks = array();
+
+ $sql = 'SELECT user_id, user_timezone, user_dst
FROM ' . $this->table_prefix . 'users
- GROUP BY user_timezone, user_dst';
+ ORDER BY user_id ASC';
$result = $this->db->sql_query_limit($sql, $limit, $start);
-
while ($row = $this->db->sql_fetchrow($result))
{
- $converted_timezones++;
+ $converted++;
+
+ $update_blocks[$row['user_timezone'] . ':' . $row['user_dst']][] = (int) $row['user_id'];
+ }
+ $this->db->sql_freeresult($result);
+
+ // Update blocks of users who share the same timezone/dst
+ foreach ($update_blocks as $timezone => $user_ids)
+ {
+ $timezone = explode(':', $timezone);
+ $converted_timezone = $this->convert_phpbb30_timezone($timezone[0], $timezone[1]);
$sql = 'UPDATE ' . $this->table_prefix . "users
- SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "'
- WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "'
- AND user_dst = " . (int) $row['user_dst'];
+ SET user_timezone = '" . $this->db->sql_escape($converted_timezone) . "'
+ WHERE " . $this->db->sql_in_set('user_id', $user_ids);
$this->sql_query($sql);
}
- $this->db->sql_freeresult($result);
- if ($converted_timezones == $limit)
+ if ($converted == $limit)
{
// There are still more to convert
return $start + $limit;