Localisation updates from https://translatewiki.net.
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index ae28cb8..657c4d0 100644 (file)
@@ -361,18 +361,18 @@ class WikiPage implements Page, IDBAccessObject {
                        return;
                }
 
-               if ( $from === self::READ_LOCKING ) {
-                       $data = $this->pageDataFromTitle( wfGetDB( DB_MASTER ), $this->mTitle, array( 'FOR UPDATE' ) );
-               } elseif ( $from === self::READ_LATEST ) {
-                       $data = $this->pageDataFromTitle( wfGetDB( DB_MASTER ), $this->mTitle );
-               } elseif ( $from === self::READ_NORMAL ) {
-                       $data = $this->pageDataFromTitle( wfGetDB( DB_SLAVE ), $this->mTitle );
+               if ( is_int( $from ) ) {
+                       list( $index, $opts ) = DBAccessObjectUtils::getDBOptions( $from );
+                       $data = $this->pageDataFromTitle( wfGetDB( $index ), $this->mTitle, $opts );
+
                        if ( !$data
+                               && $index == DB_SLAVE
                                && wfGetLB()->getServerCount() > 1
                                && wfGetLB()->hasOrMadeRecentMasterChanges()
                        ) {
                                $from = self::READ_LATEST;
-                               $data = $this->pageDataFromTitle( wfGetDB( DB_MASTER ), $this->mTitle );
+                               list( $index, $opts ) = DBAccessObjectUtils::getDBOptions( $from );
+                               $data = $this->pageDataFromTitle( wfGetDB( $index ), $this->mTitle, $opts );
                        }
                } else {
                        // No idea from where the caller got this data, assume slave database.
@@ -1199,10 +1199,9 @@ class WikiPage implements Page, IDBAccessObject {
         * Best if all done inside a transaction.
         *
         * @param DatabaseBase $dbw
-        * @return int The newly created page_id key, or false if the title already existed
+        * @return int|bool The newly created page_id key; false if the title already existed
         */
        public function insertOn( $dbw ) {
-
                $page_id = $dbw->nextSequenceValue( 'page_page_id_seq' );
                $dbw->insert( 'page', array(
                        'page_id'           => $page_id,
@@ -1223,9 +1222,11 @@ class WikiPage implements Page, IDBAccessObject {
                        $newid = $dbw->insertId();
                        $this->mId = $newid;
                        $this->mTitle->resetArticleID( $newid );
-               }
 
-               return $affected ? $newid : false;
+                       return $newid;
+               } else {
+                       return false;
+               }
        }
 
        /**
@@ -3224,10 +3225,10 @@ class WikiPage implements Page, IDBAccessObject {
 
                // Purge squid for this page only
                $title->purgeSquid();
-
-               $revid = $revision ? $revision->getId() : null;
                // Clear file cache for this page only
                HTMLFileCache::clearFileCache( $title );
+
+               $revid = $revision ? $revision->getId() : null;
                DeferredUpdates::addCallableUpdate( function() use ( $title, $revid ) {
                        InfoAction::invalidateCache( $title, $revid );
                } );