aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-06-26 01:37:30 +0200
committerNils Adermann <naderman@naderman.de>2011-06-26 01:37:30 +0200
commit0e067ec3c272a74fae4744b787bef83504d8e9c4 (patch)
treee129098da6072d2f5a8dfc767c885ddf2f052af4
parent29df4b5c60aed818949865b31ac696978e7f8965 (diff)
parentfc5a68c2cf290aba2918c538d05a34daba6e35e4 (diff)
downloadforums-0e067ec3c272a74fae4744b787bef83504d8e9c4.tar
forums-0e067ec3c272a74fae4744b787bef83504d8e9c4.tar.gz
forums-0e067ec3c272a74fae4744b787bef83504d8e9c4.tar.bz2
forums-0e067ec3c272a74fae4744b787bef83504d8e9c4.tar.xz
forums-0e067ec3c272a74fae4744b787bef83504d8e9c4.zip
Merge branch 'prep-release-3.0.9' into develop-olympus
* prep-release-3.0.9: [ticket/7729] Prevent date/time functions from throwing E_WARNING on PHP 5.3.
-rw-r--r--phpBB/includes/startup.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php
index be46c17ba6..ca9665da29 100644
--- a/phpBB/includes/startup.php
+++ b/phpBB/includes/startup.php
@@ -118,5 +118,33 @@ else
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
}
+// Prevent date/time functions from throwing E_WARNING on PHP 5.3 by setting a default timezone
+if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get'))
+{
+ // For PHP 5.1.0 the date/time functions have been rewritten
+ // and setting a timezone is required prior to calling any date/time function.
+
+ // Since PHP 5.2.0 calls to date/time functions without having a timezone set
+ // result in E_STRICT errors being thrown.
+ // Note: We already exclude E_STRICT errors
+ // (to be exact: they are not included in E_ALL in PHP 5.2)
+
+ // In PHP 5.3.0 the error level has been raised to E_WARNING which causes problems
+ // because we show E_WARNING errors and do not set a default timezone.
+ // This is because we have our own timezone handling and work in UTC only anyway.
+
+ // So what we basically want to do is set our timezone to UTC,
+ // but we don't know what other scripts (such as bridges) are involved,
+ // so we check whether a timezone is already set by calling date_default_timezone_get().
+
+ // Unfortunately, date_default_timezone_get() itself might throw E_WARNING
+ // if no timezone has been set, so we have to keep it quiet with @.
+
+ // date_default_timezone_get() tries to guess the correct timezone first
+ // and then falls back to UTC when everything fails.
+ // We just set the timezone to whatever date_default_timezone_get() returns.
+ date_default_timezone_set(@date_default_timezone_get());
+}
+
$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];