r66633 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66632‎ | r66633 | r66634 >
Date:23:44, 18 May 2010
Author:aaron
Status:deferred
Tags:
Comment:
* Stability form double-checks permissions
* Improved form error strings
* Other minor cleanups
Modified paths:
  • /trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/language/Stabilization.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/language/Stabilization.i18n.php
@@ -46,10 +46,11 @@
4747 'stabilize_page_notexists' => 'The target page does not exist.',
4848 'stabilize_page_unreviewable' => 'The target page is not in reviewable namespace.',
4949 'stabilize_invalid_precedence' => 'Invalid version precedence.',
50 - 'stabilize_invalid_autoreview' => 'Invalid autoreview restriction',
 50+ 'stabilize_invalid_autoreview' => 'Invalid autoreview restriction.',
5151 'stabilize_invalid_level' => 'Invalid protection level.',
5252 'stabilize_expiry_invalid' => 'Invalid expiration date.',
5353 'stabilize_expiry_old' => 'This expiration time has already passed.',
 54+ 'stabilize_denied' => 'Permission denied.',
5455 'stabilize-expiring' => 'expires $1 (UTC)',
5556 'stabilization-review' => 'Mark the current revision checked',
5657 );
Index: trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php
@@ -9,7 +9,7 @@
1010 *
1111 * Usage: (a) set ALL form params before doing anything else
1212 * (b) call ready() when all params are set
13 - * (c) check isAllowed() before calling submit() as needed
 13+ * (c) call preloadSettings() or submit() as needed
1414 */
1515 abstract class PageStabilityForm
1616 {
@@ -26,9 +26,15 @@
2727
2828 protected $oldConfig = array(); # Old page config
2929 protected $oldExpiry = ''; # Old page config expiry (GMT)
30 -
3130 protected $inputLock = 0; # Disallow bad submissions
3231
 32+ protected $skin = null;
 33+
 34+ public function __construct() {
 35+ global $wgUser;
 36+ $this->skin = $wgUser->getSkin();
 37+ }
 38+
3339 public function getPage() {
3440 return $this->page;
3541 }
@@ -210,7 +216,6 @@
211217
212218 /**
213219 * Submit the form parameters for the page config to the DB.
214 - * Note: caller is responsible for basic permission checks.
215220 *
216221 * @return mixed (true on success, error string on failure)
217222 */
@@ -223,6 +228,10 @@
224229 if ( $status !== true ) {
225230 return $status; // cannot submit - broken params
226231 }
 232+ # Double-check permissions
 233+ if ( !$this->isAllowed() ) {
 234+ return 'stablize_denied';
 235+ }
227236 # Are we are going back to site defaults?
228237 $reset = $this->newConfigIsReset();
229238 # Parse and cleanup the expiry time given...
@@ -444,9 +453,12 @@
445454 return 'stabilize_invalid_precedence'; // invalid precedence value
446455 }
447456 // Check autoreview restriction setting
448 - if ( !FlaggedRevs::userCanSetAutoreviewLevel( $this->autoreview ) ) {
 457+ if ( !in_array( $this->autoreview, FlaggedRevs::getRestrictionLevels() ) ) {
449458 return 'stabilize_invalid_autoreview'; // invalid value
450459 }
 460+ if ( !FlaggedRevs::userCanSetAutoreviewLevel( $this->autoreview ) ) {
 461+ return 'stabilize_denied'; // invalid value
 462+ }
451463 return true;
452464 }
453465
@@ -543,10 +555,6 @@
544556 $this->loadExpiry();
545557 # Autoreview only when protecting currently unprotected pages
546558 $this->reviewThis = ( FlaggedRevs::getProtectionLevel( $this->oldConfig ) == 'none' );
547 - # Check autoreview restriction setting
548 - if ( !FlaggedRevs::userCanSetAutoreviewLevel( $this->autoreview ) ) {
549 - return 'stabilize_invalid_level'; // invalid value
550 - }
551559 # Autoreview restriction => use stable
552560 # No autoreview restriction => site default
553561 $this->override = ( $this->autoreview != '' )
@@ -560,6 +568,10 @@
561569 if ( FlaggedRevs::getProtectionLevel( $newConfig ) == 'invalid' ) {
562570 return 'stabilize_invalid_level'; // double-check configuration
563571 }
 572+ # Check autoreview restriction setting
 573+ if ( !FlaggedRevs::userCanSetAutoreviewLevel( $this->autoreview ) ) {
 574+ return 'stabilize_denied'; // invalid value
 575+ }
564576 return true;
565577 }
566578
Index: trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php
@@ -8,9 +8,12 @@
99 class Stabilization extends UnlistedSpecialPage
1010 {
1111 protected $form = null;
 12+ protected $skin;
1213
1314 public function __construct() {
 15+ global $wgUser;
1416 parent::__construct( 'Stabilization', 'stablesettings' );
 17+ $this->skin = $wgUser->getSkin();
1518 }
1619
1720 public function execute( $par ) {
@@ -34,7 +37,6 @@
3538 }
3639 # Set page title
3740 $this->setHeaders();
38 - $this->sk = $wgUser->getSkin();
3941
4042 $this->form = new PageStabilityGeneralForm();
4143 $form = $this->form; // convenience
@@ -238,7 +240,7 @@
239241 "<label for='wpReviewthis'>{$reviewLabel}</label>" .
240242 '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' .
241243 Xml::check( 'wpWatchthis', $watchChecked, $watchAttribs ) .
242 - "<label for='wpWatchthis'" . $this->sk->tooltipAndAccesskey( 'watch' ) .
 244+ "<label for='wpWatchthis'" . $this->skin->tooltipAndAccesskey( 'watch' ) .
243245 ">{$watchLabel}</label>" .
244246 '</td>
245247 </tr>
@@ -320,4 +322,4 @@
321323 ? array()
322324 : array( 'disabled' => 'disabled' );
323325 }
324 -}
 326+}
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r66652* Refactored review form class...aaron19:53, 19 May 2010

Status & tagging log