SECURITY: rate-limit and prevent blocked users from changing email
[lhc/web/wiklou.git] / includes / page / PageArchive.php
index 0ef038f..8b42020 100644 (file)
@@ -255,11 +255,7 @@ class PageArchive {
                );
 
                if ( $row ) {
-                       return Revision::newFromArchiveRow(
-                               $row,
-                               [ 'title' => $this->title ],
-                               $this->title
-                       );
+                       return Revision::newFromArchiveRow( $row, [ 'title' => $this->title ] );
                }
 
                return null;
@@ -319,19 +315,13 @@ class PageArchive {
        }
 
        /**
-        * Get the text from an archive row containing ar_text, ar_flags and ar_text_id
+        * Get the text from an archive row containing ar_text_id
         *
+        * @deprecated since 1.31
         * @param object $row Database row
         * @return string
         */
        public function getTextFromRow( $row ) {
-               if ( is_null( $row->ar_text_id ) ) {
-                       // An old row from MediaWiki 1.4 or previous.
-                       // Text is embedded in this row in classic compression format.
-                       return Revision::getRevisionText( $row, 'ar_' );
-               }
-
-               // New-style: keyed to the text storage backend.
                $dbr = wfGetDB( DB_REPLICA );
                $text = $dbr->selectRow( 'text',
                        [ 'old_text', 'old_flags' ],
@@ -351,15 +341,18 @@ class PageArchive {
         */
        public function getLastRevisionText() {
                $dbr = wfGetDB( DB_REPLICA );
-               $row = $dbr->selectRow( 'archive',
-                       [ 'ar_text', 'ar_flags', 'ar_text_id' ],
+               $row = $dbr->selectRow(
+                       [ 'archive', 'text' ],
+                       [ 'old_text', 'old_flags' ],
                        [ 'ar_namespace' => $this->title->getNamespace(),
                                'ar_title' => $this->title->getDBkey() ],
                        __METHOD__,
-                       [ 'ORDER BY' => 'ar_timestamp DESC' ] );
+                       [ 'ORDER BY' => 'ar_timestamp DESC, ar_id DESC' ],
+                       [ 'text' => [ 'JOIN', 'old_id = ar_text_id' ] ]
+               );
 
                if ( $row ) {
-                       return $this->getTextFromRow( $row );
+                       return Revision::getRevisionText( $row );
                }
 
                return null;
@@ -608,12 +601,10 @@ class PageArchive {
                        $oldPageId = (int)$latestRestorableRow->ar_page_id; // pass this to ArticleUndelete hook
 
                        // grab the content to check consistency with global state before restoring the page.
-                       $revision = Revision::newFromArchiveRow(
-                               $latestRestorableRow,
+                       $revision = Revision::newFromArchiveRow( $latestRestorableRow,
                                [
                                        'title' => $article->getTitle(), // used to derive default content model
-                               ],
-                               $article->getTitle()
+                               ]
                        );
                        $user = User::newFromName( $revision->getUserText( Revision::RAW ), false );
                        $content = $revision->getContent( Revision::RAW );
@@ -676,15 +667,12 @@ class PageArchive {
                                }
                                // Insert one revision at a time...maintaining deletion status
                                // unless we are specifically removing all restrictions...
-                               $revision = Revision::newFromArchiveRow(
-                                       $row,
+                               $revision = Revision::newFromArchiveRow( $row,
                                        [
                                                'page' => $pageId,
                                                'title' => $this->title,
                                                'deleted' => $unsuppress ? 0 : $row->ar_deleted
-                                       ],
-                                       $this->title
-                               );
+                                       ] );
 
                                // This will also copy the revision to ip_changes if it was an IP edit.
                                $revision->insertOn( $dbw );