Index: trunk/phase3/includes/diff/DifferenceEngine.php |
— | — | @@ -499,6 +499,7 @@ |
500 | 500 | if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) ) ) { |
501 | 501 | $this->loadNewText(); |
502 | 502 | $out->setRevisionId( $this->mNewid ); |
| 503 | + $out->setRevisionTimestamp( $this->mNewRev->getTimestamp() ); |
503 | 504 | $out->setArticleFlag( true ); |
504 | 505 | |
505 | 506 | if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) { |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -497,11 +497,10 @@ |
498 | 498 | # Ensure that UI elements requiring revision ID have |
499 | 499 | # the correct version information. |
500 | 500 | $wgOut->setRevisionId( $this->mPage->getLatest() ); |
| 501 | + # Preload timestamp to avoid a DB hit |
| 502 | + $wgOut->setRevisionTimestamp( $this->mParserOutput->getTimestamp() ); |
| 503 | + $this->mPage->setTimestamp( $this->mParserOutput->getTimestamp() ); |
501 | 504 | $outputDone = true; |
502 | | - # Preload timestamp to avoid a DB hit |
503 | | - if ( isset( $this->mParserOutput->mTimestamp ) ) { |
504 | | - $this->mPage->setTimestamp( $this->mParserOutput->mTimestamp ); |
505 | | - } |
506 | 505 | } |
507 | 506 | } |
508 | 507 | break; |
— | — | @@ -523,6 +522,8 @@ |
524 | 523 | # Ensure that UI elements requiring revision ID have |
525 | 524 | # the correct version information. |
526 | 525 | $wgOut->setRevisionId( $this->getRevIdFetched() ); |
| 526 | + # Preload timestamp to avoid a DB hit |
| 527 | + $wgOut->setRevisionTimestamp( $this->getTimestamp() ); |
527 | 528 | |
528 | 529 | # Pages containing custom CSS or JavaScript get special treatment |
529 | 530 | if ( $this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) { |
Index: trunk/phase3/includes/parser/ParserOutput.php |
— | — | @@ -138,8 +138,9 @@ |
139 | 139 | $mSections = array(), # Table of contents |
140 | 140 | $mEditSectionTokens = false, # prefix/suffix markers if edit sections were output as tokens |
141 | 141 | $mProperties = array(), # Name/value pairs to be cached in the DB |
142 | | - $mTOCHTML = ''; # HTML of the TOC |
143 | | - private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change. |
| 142 | + $mTOCHTML = '', # HTML of the TOC |
| 143 | + $mTimestamp; # Timestamp of the revision |
| 144 | + private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change. |
144 | 145 | private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys) |
145 | 146 | |
146 | 147 | const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#'; |
— | — | @@ -205,6 +206,7 @@ |
206 | 207 | function getWarnings() { return array_keys( $this->mWarnings ); } |
207 | 208 | function getIndexPolicy() { return $this->mIndexPolicy; } |
208 | 209 | function getTOCHTML() { return $this->mTOCHTML; } |
| 210 | + function getTimestamp() { return $this->mTimestamp; } |
209 | 211 | |
210 | 212 | function setText( $text ) { return wfSetVar( $this->mText, $text ); } |
211 | 213 | function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks, $ll ); } |
— | — | @@ -215,6 +217,7 @@ |
216 | 218 | function setEditSectionTokens( $t ) { return wfSetVar( $this->mEditSectionTokens, $t ); } |
217 | 219 | function setIndexPolicy( $policy ) { return wfSetVar( $this->mIndexPolicy, $policy ); } |
218 | 220 | function setTOCHTML( $tochtml ) { return wfSetVar( $this->mTOCHTML, $tochtml ); } |
| 221 | + function setTimestamp( $timestamp ) { return wfSetVar( $this->mTimestamp, $timestamp ); } |
219 | 222 | |
220 | 223 | function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; } |
221 | 224 | function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; } |
Index: trunk/phase3/includes/parser/ParserCache.php |
— | — | @@ -220,7 +220,7 @@ |
221 | 221 | $popts->optionsHash( $optionsKey->mUsedOptions, $article->getTitle() ) ); |
222 | 222 | |
223 | 223 | // Save the timestamp so that we don't have to load the revision row on view |
224 | | - $parserOutput->mTimestamp = $article->getTimestamp(); |
| 224 | + $parserOutput->setTimestamp( $article->getTimestamp() ); |
225 | 225 | |
226 | 226 | $parserOutput->mText .= "\n<!-- Saved in parser cache with key $parserOutputKey and timestamp $now -->\n"; |
227 | 227 | wfDebug( "Saved in parser cache with key $parserOutputKey and timestamp $now\n" ); |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -197,6 +197,7 @@ |
198 | 198 | |
199 | 199 | /// should be private. To include the variable {{REVISIONID}} |
200 | 200 | var $mRevisionId = null; |
| 201 | + private $mRevisionTimestamp = null; |
201 | 202 | |
202 | 203 | var $mFileVersion = null; |
203 | 204 | |
— | — | @@ -1340,6 +1341,27 @@ |
1341 | 1342 | } |
1342 | 1343 | |
1343 | 1344 | /** |
| 1345 | + * Set the timestamp of the revision which will be displayed. This is used |
| 1346 | + * to avoid a extra DB call in Skin::lastModified(). |
| 1347 | + * |
| 1348 | + * @param $revid Mixed: string, or null |
| 1349 | + * @return Mixed: previous value |
| 1350 | + */ |
| 1351 | + public function setRevisionTimestamp( $timestmap ) { |
| 1352 | + return wfSetVar( $this->mRevisionTimestamp, $timestmap ); |
| 1353 | + } |
| 1354 | + |
| 1355 | + /** |
| 1356 | + * Get the timestamp of displayed revision. |
| 1357 | + * This will be null if not filled by setRevisionTimestamp(). |
| 1358 | + * |
| 1359 | + * @return String or null |
| 1360 | + */ |
| 1361 | + public function getRevisionTimestamp() { |
| 1362 | + return $this->mRevisionTimestamp; |
| 1363 | + } |
| 1364 | + |
| 1365 | + /** |
1344 | 1366 | * Set the displayed file version |
1345 | 1367 | * |
1346 | 1368 | * @param $file File|false |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -353,7 +353,7 @@ |
354 | 354 | if ( $wgMaxCredits != 0 ) { |
355 | 355 | $tpl->set( 'credits', Action::factory( 'credits', $page, $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) ); |
356 | 356 | } else { |
357 | | - $tpl->set( 'lastmod', $this->lastModified( $page ) ); |
| 357 | + $tpl->set( 'lastmod', $this->lastModified() ); |
358 | 358 | } |
359 | 359 | } |
360 | 360 | $tpl->set( 'copyright', $this->getCopyright() ); |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -828,14 +828,14 @@ |
829 | 829 | /** |
830 | 830 | * Get the timestamp of the latest revision, formatted in user language |
831 | 831 | * |
832 | | - * @param $page WikiPage object. Used if we're working with the current revision |
833 | 832 | * @return String |
834 | 833 | */ |
835 | | - protected function lastModified( $page ) { |
836 | | - if ( !$this->isRevisionCurrent() ) { |
| 834 | + protected function lastModified() { |
| 835 | + $timestamp = $this->getOutput()->getRevisionTimestamp(); |
| 836 | + |
| 837 | + # No cached timestamp, load it from the database |
| 838 | + if ( $timestamp === null ) { |
837 | 839 | $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() ); |
838 | | - } else { |
839 | | - $timestamp = $page->getTimestamp(); |
840 | 840 | } |
841 | 841 | |
842 | 842 | if ( $timestamp ) { |