Cen.temp has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/329649 )

Change subject: Remove reliance on baseRevId and altBaseRevId for 
FlaggablePageView
......................................................................

Remove reliance on baseRevId and altBaseRevId for FlaggablePageView

This checks if there are pending changes instead of relying on
baseRevIds / altBaseRevIds to predict whether the edit will be
autoreviewed. This information is already fetched for the
"review this edit" form for reviewers, and it won't
significantly affect response time for non-reviewers.
They were already no longer needed to check if the edit should
be autoreviewed post-save, they are now completely unused, so
are removed altogether.

Change-Id: Ife46a74b0652c39cf65b70b9777853f583fee70c
---
M frontend/FlaggablePageView.php
1 file changed, 6 insertions(+), 82 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlaggedRevs 
refs/changes/49/329649/1

diff --git a/frontend/FlaggablePageView.php b/frontend/FlaggablePageView.php
index 64941ec..174e1af 100755
--- a/frontend/FlaggablePageView.php
+++ b/frontend/FlaggablePageView.php
@@ -1855,18 +1855,10 @@
                }
                if ( $title->quickUserCan( 'autoreview' ) ) {
                        if ( FlaggedRevs::autoReviewNewPages() && 
!$this->article->exists() ) {
-                               return true; // edit will be autoreviewed
+                               return true; // new page, edit will be 
autoreviewed
                        }
-                       if ( !isset( $editPage->fr_baseFRev ) ) {
-                               $baseRevId = self::getBaseRevId( $editPage, 
$this->getRequest() );
-                               $baseRevId2 = self::getAltBaseRevId( $editPage, 
$this->getRequest() );
-                               $editPage->fr_baseFRev = 
FlaggedRevision::newFromTitle( $title, $baseRevId );
-                               if ( !$editPage->fr_baseFRev && $baseRevId2 ) {
-                                       $editPage->fr_baseFRev = 
FlaggedRevision::newFromTitle( $title, $baseRevId2 );
-                               }
-                       }
-                       if ( $editPage->fr_baseFRev ) {
-                               return true; // edit will be autoreviewed
+                       if ( $this->article->getStable() && 
!$this->article->revsArePending() ) {
+                               return true; // edit to a page with no pending 
changes, edit will be autoreviewed
                        }
                }
                return false; // edit won't be autoreviewed
@@ -1886,7 +1878,7 @@
                } elseif ( $this->editWillBeAutoreviewed( $editPage ) ) {
                        return true; // edit will be auto-reviewed
                }
-               if ( self::getBaseRevId( $editPage, $request ) == 
$this->article->getLatest() ) {
+               if ( !$editPage->getArticle()->getOldID() ) {
                        # For pages with either no stable version, or an 
outdated one, let
                        # the user decide if he/she wants it reviewed on the 
spot. One might
                        # do this if he/she just saw the diff-to-stable and 
*then* decided to edit.
@@ -1921,81 +1913,13 @@
        }
 
        /**
-        * (a) Add a hidden field that has the rev ID the text is based off.
-        * (b) If an edit was undone, add a hidden field that has the rev ID of 
that edit.
-        * Needed for autoreview and user stats (for autopromote).
-        * Note: baseRevId trusted for Reviewers - text checked for others.
+        * If an edit was undone, add a hidden field that has the rev ID of 
that edit.
+        * Needed for user stats (for autopromote).
         */
        public function addRevisionIDField( EditPage $editPage, OutputPage $out 
) {
-               $out->addHTML( "\n" . Html::hidden( 'baseRevId',
-                       self::getBaseRevId( $editPage, $this->getRequest() ) ) 
);
-               $out->addHTML( "\n" . Html::hidden( 'altBaseRevId',
-                       self::getAltBaseRevId( $editPage, $this->getRequest() ) 
) );
                $out->addHTML( "\n" . Html::hidden( 'undidRev',
                        empty( $editPage->undidRev ) ? 0 : $editPage->undidRev )
                );
        }
 
-       /**
-        * Guess the rev ID the text of this form is based off
-        * Note: baseRevId trusted for Reviewers - check text for others.
-        * @param EditPage $editPage
-        * @param WebRequest $request
-        * @return int
-        */
-       protected static function getBaseRevId( EditPage $editPage, WebRequest 
$request ) {
-               if ( $editPage->isConflict ) {
-                       return 0; // throw away these values (bug 33481)
-               }
-               if ( !isset( $editPage->fr_baseRevId ) ) {
-                       $article = $editPage->getArticle(); // convenience
-                       $latestId = $article->getLatest(); // current rev
-                       # Undoing edits...
-                       if ( $request->getIntOrNull( 'undo' ) ) {
-                               $revId = $latestId; // current rev is the base 
rev
-                       # Other edits...
-                       } else {
-                               # If we are editing via oldid=X, then use that 
rev ID.
-                               # Otherwise, check if the client specified the 
ID (bug 23098).
-                               $revId = $article->getOldID() ?
-                                       $article->getOldID() :
-                                       $request->getInt( 'baseRevId' ); // 
e.g. "show changes"/"preview"
-                       }
-                       # Zero oldid => draft revision
-                       $editPage->fr_baseRevId = $revId ?: $latestId;
-               }
-               return $editPage->fr_baseRevId;
-       }
-
-       /**
-        * Guess the alternative rev ID the text of this form is based off.
-        * When undoing the top X edits, the base can be though of as either
-        * the current or the edit X edits prior to the latest.
-        * Note: baseRevId trusted for Reviewers - check text for others.
-        * @param EditPage $editPage
-        * @param WebRequest $request
-        * @return int
-        */
-       protected static function getAltBaseRevId( EditPage $editPage, 
WebRequest $request ) {
-               if ( $editPage->isConflict ) {
-                       return 0; // throw away these values (bug 33481)
-               }
-               if ( !isset( $editPage->fr_altBaseRevId ) ) {
-                       $article = $editPage->getArticle(); // convenience
-                       $latestId = $article->getLatest(); // current rev
-                       $undo = $request->getIntOrNull( 'undo' );
-                       # Undoing consecutive top edits...
-                       if ( $undo && $undo === $latestId ) {
-                               # Treat this like a revert to a base revision.
-                               # We are undoing all edits *after* some rev ID 
(undoafter).
-                               # If undoafter is not given, then it is the 
previous rev ID.
-                               $revId = $request->getInt( 'undoafter',
-                                       
$article->getTitle()->getPreviousRevisionID( $latestId ) );
-                       } else {
-                               $revId = $request->getInt( 'altBaseRevId' );
-                       }
-                       $editPage->fr_altBaseRevId = $revId;
-               }
-               return $editPage->fr_altBaseRevId;
-       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/329649
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ife46a74b0652c39cf65b70b9777853f583fee70c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlaggedRevs
Gerrit-Branch: master
Gerrit-Owner: Cen.temp <cenarium.t...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to