From 8fc22c7ec62065b4086ce6f44baaa3dd93639cc6 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 2 Dec 2006 23:56:25 +0000 Subject: [PATCH] * (bug 8117) {{REVISIONTIMESTAMP}} showed weird default if $wgLocalTZoffset set; now uses current time for previews and if timestamp can't be loaded from DB * {{REVISIONTIMESTAMP}} now uses site local timezone instead of user timezone to ensure consistent behavior * {{REVISIONTIMESTAMP}} and friends should now work on non-MySQL backends --- RELEASE-NOTES | 6 ++++++ includes/Parser.php | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fd42dd68b8..f464313a5c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -237,6 +237,12 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN broken proxies that mangle such characters in form submissions * (bug 7461) Allow overwriting pages using importTextFile.php * (bug 7946) importTextFile.php doesn't perform pre-save transform +* (bug 8117) {{REVISIONTIMESTAMP}} showed weird default if $wgLocalTZoffset set; + now uses current time for previews and if timestamp can't be loaded from DB +* {{REVISIONTIMESTAMP}} now uses site local timezone instead of user timezone + to ensure consistent behavior +* {{REVISIONTIMESTAMP}} and friends should now work on non-MySQL backends + == Languages updated == diff --git a/includes/Parser.php b/includes/Parser.php index ef298a3cec..4cf48e8eb9 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -4528,7 +4528,7 @@ class Parser /** * Get the timestamp associated with the current revision, adjusted for - * the user's current timestamp + * the default server-local timestamp */ function getRevisionTimestamp() { if ( is_null( $this->mRevisionTimestamp ) ) { @@ -4537,8 +4537,21 @@ class Parser $dbr =& wfGetDB( DB_SLAVE ); $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', array( 'rev_id' => $this->mRevisionId ), __METHOD__ ); - $this->mRevisionTimestamp = $wgContLang->userAdjust( $timestamp ); - + + // Normalize timestamp to internal MW format for timezone processing. + // This has the added side-effect of replacing a null value with + // the current time, which gives us more sensible behavior for + // previews. + $timestamp = wfTimestamp( TS_MW, $timestamp ); + + // The cryptic '' timezone parameter tells to use the site-default + // timezone offset instead of the user settings. + // + // Since this value will be saved into the parser cache, served + // to other users, and potentially even used inside links and such, + // it needs to be consistent for all visitors. + $this->mRevisionTimestamp = $wgContLang->userAdjust( $timestamp, '' ); + wfProfileOut( __METHOD__ ); } return $this->mRevisionTimestamp; -- 2.20.1