diff --git a/include/class.format.php b/include/class.format.php index e6761abfea7a62b8f7b19487f202f10f6e19dad4..28dc209917af48a4f449feaab1683b7fdf0b5a2d 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -513,7 +513,7 @@ class Format { $format = self::getStrftimeFormat($format); // TODO: Properly convert to local time $time = DateTime::createFromFormat('U', $timestamp, new DateTimeZone('UTC')); - $time->setTimeZone(new DateTimeZone($cfg->getTimezone())); + $time->setTimeZone(new DateTimeZone($cfg->getTimezone() ?: date_default_timezone_get())); $timestamp = $time->getTimestamp(); return strftime($format ?: $strftimeFallback, $timestamp); } @@ -546,7 +546,7 @@ class Format { return self::__formatDate($timestamp, $format ?: $cfg->getTimeFormat(), $fromDb, - IntlDateFormatter::NONE, IntlDateFormatter::SHORT, + IDF_NONE, IDF_SHORT, '%x', $timezone ?: $cfg->getTimezone()); } @@ -555,7 +555,7 @@ class Format { return self::__formatDate($timestamp, $format ?: $cfg->getDateFormat(), $fromDb, - IntlDateFormatter::SHORT, IntlDateFormatter::NONE, + IDF_SHORT, IDF_NONE, '%X', $timezone ?: $cfg->getTimezone()); } @@ -564,7 +564,7 @@ class Format { return self::__formatDate($timestamp, $cfg->getDateTimeFormat(), $fromDb, - IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, + IDF_SHORT, IDF_SHORT, '%X %x', $timezone ?: $cfg->getTimezone()); } @@ -573,7 +573,7 @@ class Format { return self::__formatDate($timestamp, $cfg->getDayDateTimeFormat(), $fromDb, - IntlDateFormatter::FULL, IntlDateFormatter::SHORT, + IDF_FULL, IDF_SHORT, '%X %x', $timezone ?: $cfg->getTimezone()); } @@ -760,4 +760,15 @@ class Format { return $text; } } + +if (!class_exists('IntlDateFormatter')) { + define('IDF_NONE', 0); + define('IDF_SHORT', 1); + define('IDF_FULL', 2); +} +else { + define('IDF_NONE', IntlDateFormatter::NONE); + define('IDF_SHORT', IntlDateFormatter::SHORT); + define('IDF_FULL', IntlDateFormatter::FULL); +} ?> diff --git a/include/class.orm.php b/include/class.orm.php index fcbe457545468fa933af42dcdc51384d09a7ad8f..afce3ea1552b7abd441f1da667bb4b5a0f9c2607 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -2076,7 +2076,7 @@ class MysqlExecutor { function execute() { if (!($this->stmt = db_prepare($this->sql))) - throw new Exception('Unable to prepare query: '.db_error() + throw new OrmException('Unable to prepare query: '.db_error() .' '.$this->sql); if (count($this->params)) $this->_bind($this->params); diff --git a/include/class.staff.php b/include/class.staff.php index 9a8ac128b05ca7f6842c0ea361c2bb3f071608c8..a6aecc63e8328d79e66d517e09485ba728b36ce4 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -285,7 +285,7 @@ implements AuthenticatedUser { } function getLanguage() { - return $this->lang; + return (isset($this->lang)) ? $this->lang : false; } function getTimezone() { @@ -430,7 +430,7 @@ implements AuthenticatedUser { } function getExtraAttr($attr=false, $default=null) { - if (!isset($this->_extra)) + if (!isset($this->_extra) && isset($this->extra)) $this->_extra = JsonDataParser::decode($this->extra); return $attr ? (@$this->_extra[$attr] ?: $default) : $this->_extra; diff --git a/include/class.translation.php b/include/class.translation.php index 1c09dbb6aa29a31b63df9ed210a9dd582aa1534e..67037d2c02fb979d2f3006c96a3733f32f8cc30f 100644 --- a/include/class.translation.php +++ b/include/class.translation.php @@ -1030,7 +1030,13 @@ class CustomDataTranslation extends VerySimpleModel { if ($lang) $criteria['lang'] = $lang; - return static::objects()->filter($criteria)->all(); + try { + return static::objects()->filter($criteria)->all(); + } + catch (OrmException $e) { + // Translation table might not exist yet — happens on the upgrader + return array(); + } } } diff --git a/include/upgrader/streams/core/b26f29a6-1ee831c8.patch.sql b/include/upgrader/streams/core/b26f29a6-1ee831c8.patch.sql index fea1624b4ed8c0dc3352b0bd5b1f94815f4235d9..2b9944add5fe0464ae9229f883d25135c491dac8 100644 --- a/include/upgrader/streams/core/b26f29a6-1ee831c8.patch.sql +++ b/include/upgrader/streams/core/b26f29a6-1ee831c8.patch.sql @@ -185,8 +185,10 @@ UPDATE `%TABLE_PREFIX%form_field` A1 JOIN `%TABLE_PREFIX%form` A2 ON(A2.id=A1.fo SET A1.`flags`=3 WHERE A2.`type`='O' AND A1.`name` IN('name'); -set @client_edit = ( - select value from `%TABLE_PREFIX%config` where `key` = 'allow_client_updates'); +-- Coalesce to zero here in case the config option has never been saved +set @client_edit = coalesce( + (select value from `%TABLE_PREFIX%config` where `key` = + 'allow_client_updates'), 0); -- Transfer previous visibility and requirement settings to new flag field UPDATE `%TABLE_PREFIX%form_field` SET `flags` = `flags` |