r46632 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46631‎ | r46632 | r46633 >
Date:03:43, 31 January 2009
Author:aaron
Status:deferred
Tags:
Comment:
* maybeMakeEditReviewed cleanup:
** Move up title check
** Be careful with edit merges and the checkbox
** Show name in history when checkboxed is used (bug 17245)
* Remove unused $patrol param
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -986,7 +986,7 @@
987987 * LinksUpdate was already called via edit operations, so the page
988988 * fields will be up to date. This updates the stable version.
989989 */
990 - public static function autoReviewEdit( $article, $user, $text, $rev, $flags, $patrol = true ) {
 990+ public static function autoReviewEdit( $article, $user, $text, $rev, $flags, $auto=true ) {
991991 global $wgMemc;
992992 wfProfileIn( __METHOD__ );
993993 # Default tags to level 1 for each dimension
@@ -1067,13 +1067,9 @@
10681068 'fr_img_timestamp' => $fileData ? $fileData['timestamp'] : null,
10691069 'fr_img_sha1' => $fileData ? $fileData['sha1'] : null
10701070 ) );
1071 - $flaggedRevision->insertOn( $tmpset, $imgset, true );
1072 - # Mark as patrolled
1073 - if( $patrol ) {
1074 - RevisionReview::updateRecentChanges( $title, $rev->getId() );
1075 - }
 1071+ $flaggedRevision->insertOn( $tmpset, $imgset, $auto );
10761072 # Update the article review log
1077 - RevisionReview::updateLog( $title, $flags, array(), '', $rev->getId(), $oldSvId, true, true );
 1073+ RevisionReview::updateLog( $title, $flags, array(), '', $rev->getId(), $oldSvId, true, $auto );
10781074
10791075 # If we know that this is now the new stable version
10801076 # (which it probably is), save it to the cache...
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -666,38 +666,47 @@
667667 */
668668 public static function maybeMakeEditReviewed( $article, $rev, $baseRevId = false, $user = null ) {
669669 global $wgFlaggedRevsAutoReview, $wgFlaggedRevsAutoReviewNew, $wgRequest;
670 - # Get the user
671 - $user = is_null($user) ? User::newFromId( $rev->getUser() ) : $user;
672 - $checked = $wgRequest->getCheck('wpReviewEdit') && $user->isAllowed('review');
673 - if( $checked ) {
674 - # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit...
675 - FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, null, false );
 670+ # Must be in reviewable namespace
 671+ $title = $article->getTitle();
 672+ if( !$rev || !FlaggedRevs::isPageReviewable( $title ) ) {
676673 return true;
677674 }
 675+ $title->resetArticleID( $rev->getPage() ); // Avoid extra DB hit and lag issues
 676+ # Get what was just the current revision ID
 677+ $prevRevId = $rev->getParentId();
 678+ $prevTimestamp = $flags = null;
 679+ # Get edit timestamp. Existance already valided by EditPage.php. If
 680+ # not present, then it the rev shouldn't be saved, like null edits.
 681+ $editTimestamp = $wgRequest->getVal('wpEdittime');
 682+ # Get the user who made the edit
 683+ $user = is_null($user) ? User::newFromId( $rev->getUser() ) : $user;
 684+ # Is the page checked off to be reviewed?
 685+ if( $wgRequest->getCheck('wpReviewEdit') && $user->isAllowed('review') ) {
 686+ if( $prevRevId ) {
 687+ $prevTimestamp = Revision::getTimestampFromId( $title, $prevRevId ); // use PK
 688+ }
 689+ # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit.
 690+ # Don't do so if an edit was auto-merged in between though...
 691+ if( !$editTimestamp || !$prevTimestamp || $prevTimestamp == $editTimestamp ) {
 692+ FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags, false );
 693+ return true;
 694+ }
 695+ }
678696 # Auto-reviewing must be enabled
679697 if( !$wgFlaggedRevsAutoReview ) return true;
680698 # User must have the required permissions
681 - if( !$user->isAllowed('autoreview') && !$user->isAllowed('bot') )
 699+ if( !$user->isAllowed('autoreview') && !$user->isAllowed('bot') ) {
682700 return true;
 701+ }
683702 # If $baseRevId passed in, this is a null edit
684703 $isNullEdit = $baseRevId ? true : false;
685 - # Must be in reviewable namespace
686 - $title = $article->getTitle();
687 - if( !FlaggedRevs::isPageReviewable( $title ) ) {
688 - return true;
689 - }
690704 $frev = null;
691705 $reviewableNewPage = false;
692 - # Avoid extra DB hit and lag issues
693 - $title->resetArticleID( $rev->getPage() );
694 - # Get what was just the current revision ID
695 - $prevRevId = $rev->getParentId();
696706 # Get the revision ID the incoming one was based off...
697707 if( !$baseRevId && $prevRevId ) {
698 - $prevTimestamp = Revision::getTimestampFromId( $title, $prevRevId ); // use PK
699 - # Get edit timestamp. Existance already valided by EditPage.php. If
700 - # not present, then it shouldn't be, like null edits.
701 - $editTimestamp = $wgRequest->getVal('wpEdittime');
 708+ if( is_null($prevTimestamp) ) { // may already be set
 709+ $prevTimestamp = Revision::getTimestampFromId( $title, $prevRevId ); // use PK
 710+ }
702711 # The user just made an edit. The one before that should have
703712 # been the current version. If not reflected in wpEdittime, an
704713 # edit may have been auto-merged in between, in that case, discard
@@ -729,11 +738,9 @@
730739 # Assume basic flagging level unless this is a null edit
731740 if( $isNullEdit ) {
732741 $flags = $frev->getTags();
733 - } else {
734 - $flags = null;
735742 }
736743 # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit...
737 - FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags, false );
 744+ FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags );
738745 }
739746 return true;
740747 }

Status & tagging log