Last modified: 2009-01-17 17:03:45 UTC
As the page is parsed, the time() can be accessed over and over. This can lead to inconsistency of time-based template names, and other errors. The fix is simple, a per parse $mRunTime. (I also grouped a few of the variable access functions in one place as I was trying to figure out the existing code, so they were easier to find, and added some missing function header block comments for them.) --- Parser.php Fri Jul 14 01:28:01 2006 +++ xParser.php Sat Jul 15 10:42:19 2006 @@ -117,9 +117,10 @@ # Temporary # These are variables reset at least once per parse regardless of $clearState var $mOptions, // ParserOptions object - $mTitle, // Title context, used for self-link rendering and similar things $mOutputType, // Output type, one of the OT_xxx constants - $mRevisionId; // ID to display in {{REVISIONID}} tags + $mRevisionId, // ID to display in {{REVISIONID}} tags + $mRunTime, // constant time() used for parse + $mTitle; // Title context, used for self-link rendering and similar things /**#@-*/ @@ -210,6 +211,7 @@ 'titles' => array() ); $this->mRevisionId = null; + $this->mRunTime = time(); /** * Prefix for temporary replacement strings for the multipass parser. @@ -231,6 +233,26 @@ } /** + * Accessors for Temporary variables. + * + * @public + */ + function getRunTime() { return $this->mRunTime; } + function &getTitle() { return $this->mTitle; } + + /** + * Accessors for Temporary Options variables. + * + * @public + */ + function getOptions() { return $this->mOptions; } + + function getFunctionLang() { + global $wgLang, $wgContLang; + return $this->mOptions->getInterfaceMessage() ? $wgLang : $wgContLang; + } + + /** * Accessor for mUniqPrefix. * * @public @@ -273,6 +295,7 @@ $this->mRevisionId = $revid; } $this->mOutputType = OT_HTML; + $this->mRunTime = time(); //$text = $this->strip( $text, $this->mStripState ); // VOODOO MAGIC FIX! Sometimes the above segfaults in PHP5. @@ -368,14 +391,6 @@ return dechex(mt_rand(0, 0x7fffffff)) . dechex(mt_rand(0, 0x7fffffff)); } - function &getTitle() { return $this->mTitle; } - function getOptions() { return $this->mOptions; } - - function getFunctionLang() { - global $wgLang, $wgContLang; - return $this->mOptions->getInterfaceMessage() ? $wgLang : $wgContLang; - } - /** * Replaces all occurrences of HTML-style comments and the given tags * in the text with a random marker and returns teh next text. The output @@ -2213,7 +2228,7 @@ if ( isset( $varCache[$index] ) ) return $varCache[$index]; - $ts = time(); + $ts = $this->$mRunTime(); wfRunHooks( 'ParserGetVariableValueTs', array( &$this, &$ts ) ); switch ( $index ) {
Created attachment 2088 [details] same as in original description, hopefully with everything intact
As of 1.14, I only see two harmless instances of time() in the "scary" template fetch code