From 7c9094176ddc2cac8192adf3d3d8d084db48c7e9 Mon Sep 17 00:00:00 2001 From: Robert Leverington Date: Wed, 28 May 2008 17:54:12 +0000 Subject: [PATCH] * Revert r35469. * For some reason PHP doesn't always report errors even when error reporting is set to maxmium. * The date\time system needs some sort of work doing to it, there is stuff for it spread everywhere and no definite timezone. * Regardless, an E_STRICT level error does not constitute a major severity and High priority bug. --- RELEASE-NOTES | 2 -- includes/DefaultSettings.php | 2 +- includes/GlobalFunctions.php | 22 ---------------------- includes/Parser.php | 14 ++++++++------ includes/Parser_OldPP.php | 14 ++++++++------ 5 files changed, 17 insertions(+), 37 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 5f0ee3cbaa..6cdbb88810 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -302,8 +302,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN disabling $wgStrictFileExtensions * (bug 14241) Pages can no longer be protected to levels you are not in * (bug 14296) Fix local name of ang: (Anglo-Saxon) -* (bug 7715) Use date_default_timezone_* instead of TZ environment variable if - available * (bug 4871) Hardcoded superscript in time zone preferences moved to message === API changes in 1.13 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 550d7d8d39..992be45fb9 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2444,7 +2444,7 @@ $wgLocaltimezone = null; * this in conjunction with the signature timezone and override the TZ * environment variable like so: * $wgLocaltimezone="Europe/Berlin"; - * date_default_timezone_set( $wgLocaltimezone ); + * putenv("TZ=$wgLocaltimezone"); * $wgLocalTZoffset = date("Z") / 60; * * Leave at NULL to show times in universal time (UTC/GMT). diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index e51fc71193..3294c8f9b0 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -87,28 +87,6 @@ if ( !function_exists( 'array_diff_key' ) ) { } } -if ( !function_exists( 'date_default_timezone_get' ) ) { - /** - * Exists in PHP 5.1.0+ - * Simulates functionality partially. - * @return String: Environment timezone. - */ - function date_default_timezone_get() { - return getenv( 'TZ' ); - } -} -if ( !function_exists( 'date_default_timezone_set' ) ) { - /** - * Exists in PHP 5.1.0+ - * Simulates functionality partially. - * @param String: Timezone to set to. - * @return Boolean: Indication regarding if setting was successful. - */ - function date_default_timezone_set( $setting ) { - return putenv( 'TZ=' . $setting ); - } -} - /** * Like array_diff( $a, $b ) except that it works with two-dimensional arrays. */ diff --git a/includes/Parser.php b/includes/Parser.php index a467f8d004..0b8497f4fb 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2381,10 +2381,11 @@ class Parser # Use the time zone global $wgLocaltimezone; if ( isset( $wgLocaltimezone ) ) { - $oldtz = date_default_timezone_get(); - date_default_timezone_set( $wgLocaltimezone ); + $oldtz = getenv( 'TZ' ); + putenv( 'TZ='.$wgLocaltimezone ); } + wfSuppressWarnings(); // E_STRICT system time bitching $localTimestamp = date( 'YmdHis', $ts ); $localMonth = date( 'm', $ts ); $localMonthName = date( 'n', $ts ); @@ -2395,8 +2396,9 @@ class Parser $localYear = date( 'Y', $ts ); $localHour = date( 'H', $ts ); if ( isset( $wgLocaltimezone ) ) { - date_default_timezone_set( $oldtz ); + putenv( 'TZ='.$oldtz ); } + wfRestoreWarnings(); switch ( $index ) { case 'currentmonth': @@ -3701,11 +3703,11 @@ class Parser $tz = 'UTC'; if ( isset( $wgLocaltimezone ) ) { $unixts = wfTimestamp( TS_UNIX, $ts ); - $oldtz = date_default_timezone_get(); - date_default_timezone_set( $wgLocaltimezone ); + $oldtz = getenv( 'TZ' ); + putenv( 'TZ='.$wgLocaltimezone ); $ts = date( 'YmdHis', $unixts ); $tz = date( 'T', $unixts ); # might vary on DST changeover! - date_default_timezone_set( $oldtz ); + putenv( 'TZ='.$oldtz ); } $d = $wgContLang->timeanddate( $ts, false, false ) . " ($tz)"; diff --git a/includes/Parser_OldPP.php b/includes/Parser_OldPP.php index f2f1b72422..57a981e462 100644 --- a/includes/Parser_OldPP.php +++ b/includes/Parser_OldPP.php @@ -2402,10 +2402,11 @@ class Parser_OldPP # Use the time zone global $wgLocaltimezone; if ( isset( $wgLocaltimezone ) ) { - $oldtz = date_default_timezone_get(); - date_default_timezone_set( $wgLocaltimezone ); + $oldtz = getenv( 'TZ' ); + putenv( 'TZ='.$wgLocaltimezone ); } + wfSuppressWarnings(); // E_STRICT system time bitching $localTimestamp = date( 'YmdHis', $ts ); $localMonth = date( 'm', $ts ); $localMonthName = date( 'n', $ts ); @@ -2416,8 +2417,9 @@ class Parser_OldPP $localYear = date( 'Y', $ts ); $localHour = date( 'H', $ts ); if ( isset( $wgLocaltimezone ) ) { - date_default_timezone_set( $oldtz ); + putenv( 'TZ='.$oldtz ); } + wfRestoreWarnings(); switch ( $index ) { case 'currentmonth': @@ -3779,13 +3781,13 @@ class Parser_OldPP * than the one selected in each user's preferences. */ if ( isset( $wgLocaltimezone ) ) { - $oldtz = date_default_timezone_get(); - date_default_timezone_set( $wgLocaltimezone ); + $oldtz = getenv( 'TZ' ); + putenv( 'TZ='.$wgLocaltimezone ); } $d = $wgContLang->timeanddate( date( 'YmdHis' ), false, false) . ' (' . date( 'T' ) . ')'; if ( isset( $wgLocaltimezone ) ) { - date_default_timezone_set( $oldtz ); + putenv( 'TZ='.$oldtz ); } # Variable replacement -- 2.20.1