From 25bbe741f45b753f0a4b1102060e9b1e6daf8b43 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 20 Jun 2011 13:00:31 -0700 Subject: [PATCH] Provide a default non-NULL timezone in the PhabricatorUser class Summary: Without this, user creation throws an exception when trying to insert NULL into a non-NULL field. Test Plan: Created a new user. Reviewed By: fratrik Reviewers: fratrik, toulouse, aran, jungejason, tuomaspelkonen CC: aran, fratrik Differential Revision: 480 --- resources/sql/patches/045.timezone.sql | 2 +- src/applications/people/storage/user/PhabricatorUser.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/resources/sql/patches/045.timezone.sql b/resources/sql/patches/045.timezone.sql index 49c402b25b..a7e317407a 100644 --- a/resources/sql/patches/045.timezone.sql +++ b/resources/sql/patches/045.timezone.sql @@ -1,2 +1,2 @@ ALTER TABLE phabricator_user.user - ADD timezoneIdentifier varchar(255) NOT NULL DEFAULT "America/Los_Angeles"; \ No newline at end of file + ADD timezoneIdentifier varchar(255) NOT NULL; diff --git a/src/applications/people/storage/user/PhabricatorUser.php b/src/applications/people/storage/user/PhabricatorUser.php index c5cbe0a121..5c087df013 100644 --- a/src/applications/people/storage/user/PhabricatorUser.php +++ b/src/applications/people/storage/user/PhabricatorUser.php @@ -27,7 +27,7 @@ class PhabricatorUser extends PhabricatorUserDAO { protected $passwordSalt; protected $passwordHash; protected $profileImagePHID; - protected $timezoneIdentifier; + protected $timezoneIdentifier = ''; protected $consoleEnabled = 0; protected $consoleVisible = 0; @@ -298,4 +298,11 @@ class PhabricatorUser extends PhabricatorUserDAO { return $preferences; } + public function getTimezoneIdentifier() { + // If the user hasn't set one, guess the server's time. + return nonempty( + $this->timezoneIdentifier, + date_default_timezone_get()); + } + }