Replace use of &$this
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index f760cd1..232f6cc 100644 (file)
@@ -323,7 +323,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                $row = $dbr->selectRow( 'page', $fields, $conditions, __METHOD__, $options );
 
-               Hooks::run( 'ArticlePageDataAfter', [ &$this, &$row ] );
+               Hooks::run( 'ArticlePageDataAfter', [ &$wikiPage, &$row ] );
 
                return $row;
        }
@@ -2088,8 +2088,12 @@ class WikiPage implements Page, IDBAccessObject {
                                );
                        } else {
                                // Try to avoid a second parse if {{REVISIONID}} is used
-                               $edit->popts->setSpeculativeRevIdCallback( function () {
-                                       return 1 + (int)wfGetDB( DB_MASTER )->selectField(
+                               $dbIndex = ( $this->mDataLoadedFrom & self::READ_LATEST ) === self::READ_LATEST
+                                       ? DB_MASTER // use the best possible guess
+                                       : DB_REPLICA; // T154554
+
+                               $edit->popts->setSpeculativeRevIdCallback( function () use ( $dbIndex ) {
+                                       return 1 + (int)wfGetDB( $dbIndex )->selectField(
                                                'revision',
                                                'MAX(rev_id)',
                                                [],
@@ -3648,4 +3652,15 @@ class WikiPage implements Page, IDBAccessObject {
        public function getSourceURL() {
                return $this->getTitle()->getCanonicalURL();
        }
+
+       /*
+        * @param WANObjectCache $cache
+        * @return string[]
+        * @since 1.28
+        */
+       public function getMutableCacheKeys( WANObjectCache $cache ) {
+               $linkCache = MediaWikiServices::getInstance()->getLinkCache();
+
+               return $linkCache->getMutableCacheKeys( $cache, $this->getTitle()->getTitleValue() );
+       }
 }