* Added ParserOutput::(get|set)Timestamp() and the $mTimestamp member; avoid messing with isset()
# Ensure that UI elements requiring revision ID have
# the correct version information.
$wgOut->setRevisionId( $this->mPage->getLatest() );
- $outputDone = true;
# Preload timestamp to avoid a DB hit
- if ( isset( $this->mParserOutput->mTimestamp ) ) {
- $this->mPage->setTimestamp( $this->mParserOutput->mTimestamp );
- }
+ $wgOut->setRevisionTimestamp( $this->mParserOutput->getTimestamp() );
+ $this->mPage->setTimestamp( $this->mParserOutput->getTimestamp() );
+ $outputDone = true;
}
}
break;
# Ensure that UI elements requiring revision ID have
# the correct version information.
$wgOut->setRevisionId( $this->getRevIdFetched() );
+ # Preload timestamp to avoid a DB hit
+ $wgOut->setRevisionTimestamp( $this->getTimestamp() );
# Pages containing custom CSS or JavaScript get special treatment
if ( $this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) {
/// should be private. To include the variable {{REVISIONID}}
var $mRevisionId = null;
+ private $mRevisionTimestamp = null;
var $mFileVersion = null;
return $this->mRevisionId;
}
+ /**
+ * Set the timestamp of the revision which will be displayed. This is used
+ * to avoid a extra DB call in Skin::lastModified().
+ *
+ * @param $revid Mixed: string, or null
+ * @return Mixed: previous value
+ */
+ public function setRevisionTimestamp( $timestmap ) {
+ return wfSetVar( $this->mRevisionTimestamp, $timestmap );
+ }
+
+ /**
+ * Get the timestamp of displayed revision.
+ * This will be null if not filled by setRevisionTimestamp().
+ *
+ * @return String or null
+ */
+ public function getRevisionTimestamp() {
+ return $this->mRevisionTimestamp;
+ }
+
/**
* Set the displayed file version
*
/**
* Get the timestamp of the latest revision, formatted in user language
*
- * @param $page WikiPage object. Used if we're working with the current revision
* @return String
*/
- protected function lastModified( $page ) {
- if ( !$this->isRevisionCurrent() ) {
+ protected function lastModified() {
+ $timestamp = $this->getOutput()->getRevisionTimestamp();
+
+ # No cached timestamp, load it from the database
+ if ( $timestamp === null ) {
$timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
- } else {
- $timestamp = $page->getTimestamp();
}
if ( $timestamp ) {
if ( $wgMaxCredits != 0 ) {
$tpl->set( 'credits', Action::factory( 'credits', $page, $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
} else {
- $tpl->set( 'lastmod', $this->lastModified( $page ) );
+ $tpl->set( 'lastmod', $this->lastModified() );
}
}
$tpl->set( 'copyright', $this->getCopyright() );
if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
$this->loadNewText();
$out->setRevisionId( $this->mNewid );
+ $out->setRevisionTimestamp( $this->mNewRev->getTimestamp() );
$out->setArticleFlag( true );
if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) {
$popts->optionsHash( $optionsKey->mUsedOptions, $article->getTitle() ) );
// Save the timestamp so that we don't have to load the revision row on view
- $parserOutput->mTimestamp = $article->getTimestamp();
+ $parserOutput->setTimestamp( $article->getTimestamp() );
$parserOutput->mText .= "\n<!-- Saved in parser cache with key $parserOutputKey and timestamp $now -->\n";
wfDebug( "Saved in parser cache with key $parserOutputKey and timestamp $now\n" );
$mSections = array(), # Table of contents
$mEditSectionTokens = false, # prefix/suffix markers if edit sections were output as tokens
$mProperties = array(), # Name/value pairs to be cached in the DB
- $mTOCHTML = ''; # HTML of the TOC
- private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
+ $mTOCHTML = '', # HTML of the TOC
+ $mTimestamp; # Timestamp of the revision
+ private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
function getWarnings() { return array_keys( $this->mWarnings ); }
function getIndexPolicy() { return $this->mIndexPolicy; }
function getTOCHTML() { return $this->mTOCHTML; }
+ function getTimestamp() { return $this->mTimestamp; }
function setText( $text ) { return wfSetVar( $this->mText, $text ); }
function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks, $ll ); }
function setEditSectionTokens( $t ) { return wfSetVar( $this->mEditSectionTokens, $t ); }
function setIndexPolicy( $policy ) { return wfSetVar( $this->mIndexPolicy, $policy ); }
function setTOCHTML( $tochtml ) { return wfSetVar( $this->mTOCHTML, $tochtml ); }
+ function setTimestamp( $timestamp ) { return wfSetVar( $this->mTimestamp, $timestamp ); }
function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; }
function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; }