aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-06-20 00:50:33 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-06-20 00:52:37 +0200
commit902a79bfdabb2c459f2385cff80b5fa38099d2f7 (patch)
tree6cf5522a6064ccad335da702f9142c6ec159fd4e /phpBB
parenta5628cbdc85a197f32bd14890938dabd23bb6ef6 (diff)
downloadforums-902a79bfdabb2c459f2385cff80b5fa38099d2f7.tar
forums-902a79bfdabb2c459f2385cff80b5fa38099d2f7.tar.gz
forums-902a79bfdabb2c459f2385cff80b5fa38099d2f7.tar.bz2
forums-902a79bfdabb2c459f2385cff80b5fa38099d2f7.tar.xz
forums-902a79bfdabb2c459f2385cff80b5fa38099d2f7.zip
[feature/new-tz-handling] Readd Database updater changes from Oleg
The change here converts user_timezone to vchar and computes timezone identifiers from the offsets. It uses database-specific functions for building SQL conditionals and concatenations which need to be implemented, probably in a separate ticket. As a result the current code is not functional. The changes are tricky since we need to drop user_dst column from users table, but we need it during the data migration process to properly calculate effective timezones for all users. PHPBB3-9558
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/install/database_update.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index b6f7f82785..dd2d04d3a6 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -2588,6 +2588,33 @@ function change_database_data(&$no_updates, $version)
$config->set('assets_version', '1');
}
+ // If the column exists, we did not yet update the users timezone
+ if ($db_tools->sql_column_exists(USERS_TABLE, 'user_dst'))
+ {
+ // Update timezones
+ // user_dst is 0 if not in dst and 1 if in dst;
+ // this happens to be exactly the correction that should be added to the timezone offset
+ // to obtain dst offset.
+ // Parenthesize here because we operate on this value later.
+ $active_offset = '(user_timezone + user_dst)';
+
+ // Now we have a tricky problem of forcing the plus sign into the expression.
+ // Build it via a conditional since there cannot be a portable printf equivalent in databases.
+ // Note that active offset is not an absolute value here - it is an expression that will
+ // be evaluated by the database during query execution.
+ // We don't print - (minus) here because it will come from active offset.
+ $sign = $db->sql_conditional("$active_offset < 0", '', '+');
+
+ // Use database-specific escaping because strings are quoted differently by different databases.
+ $new_value = $db->sql_concatenate($db->sql_escape('GMT'), $sign, $active_offset);
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_timezone = ' . $new_value;
+ _sql($sql, $errored, $error_ary);
+
+ // After we have calculated the timezones we can delete user_dst column from user table.
+ $db_tools->sql_column_remove(USERS_TABLE, 'user_dst');
+ }
+
break;
}
}