r113389 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113388‎ | r113389 | r113390 >
Date:19:42, 8 March 2012
Author:aaron
Status:reverted
Tags:gerritmigration, i18ndeploy, i18nreview 
Comment:
* Renamed misleading onUserCan fuction to onGetUserPermissionsErrors as it hooks on 'getUserPermissionsErrors'.
* Cleaned up inconsistent checking of 'edit' permissions to determing 'review' permissions. It is now checked for automatic review checks and not just manual review attempts.
* (bug 33385) Narrowed down "review right requires edit right" to just checking edit restrictions, which better aligns with the original point of the check, which is to handle "edit wars" and "review wars". This should work better with the Translate extension.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php
@@ -295,7 +295,7 @@
296296 /**
297297 * Check page move and patrol permissions for FlaggedRevs
298298 */
299 - public static function onUserCan( Title $title, $user, $action, &$result ) {
 299+ public static function onGetUserPermissionsErrors( Title $title, $user, $action, &$result ) {
300300 if ( $result === false ) {
301301 return true; // nothing to do
302302 }
@@ -336,6 +336,20 @@
337337 $result = false;
338338 return false;
339339 }
 340+ # Respect page protection to handle cases of "review wars".
 341+ # If a page is restricted from editing such that a user cannot
 342+ # edit it, then said user should not be able to review it.
 343+ foreach ( $title->getRestrictions( 'edit' ) as $right ) {
 344+ // Backwards compatibility, rewrite sysop -> protect
 345+ $right = ( $right === 'sysop' ) ? 'protect' : $right;
 346+ if ( $right != '' && !$user->isAllowed( $right ) ) {
 347+ // 'editprotected' bypasses this restriction
 348+ if ( !$user->isAllowed( 'editprotected' ) ) {
 349+ $result = false;
 350+ return false;
 351+ }
 352+ }
 353+ }
340354 }
341355 return true;
342356 }
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php
@@ -228,10 +228,7 @@
229229
230230 public function isAllowed() {
231231 // Basic permission check
232 - return ( $this->page
233 - && $this->page->userCan( 'review' )
234 - && $this->page->userCan( 'edit' )
235 - );
 232+ return ( $this->page && $this->page->userCan( 'review' ) );
236233 }
237234
238235 // implicit dims for binary flag case
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php
@@ -211,7 +211,7 @@
212212
213213 # ######## Other #########
214214 # Determine what pages can be moved and patrolled
215 - $wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::onUserCan';
 215+ $wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::onGetUserPermissionsErrors';
216216 # Implicit autoreview rights group
217217 $wgHooks['AutopromoteCondition'][] = 'FlaggedRevsHooks::checkAutoPromoteCond';
218218 $wgHooks['UserLoadAfterLoadFromSession'][] = 'FlaggedRevsHooks::setSessionKey';

Follow-up revisions

RevisionCommit summaryAuthorDate
r114402Revert r112773, r112941, r112942, r113389: unreviewed revisions in FlaggedRevs....catrope20:30, 21 March 2012

Status & tagging log