r66598 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66597‎ | r66598 | r66599 >
Date:01:36, 18 May 2010
Author:aaron
Status:ok
Tags:
Comment:
* Removed API call to setWasPosted()
* Fixed and refactored PageStabilityForm title handling
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/api/ApiStabilize.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php
@@ -13,7 +13,7 @@
1414 abstract class PageStabilityForm
1515 {
1616 /* Form parameters which can be user given */
17 - protected $target = null; # Target page text
 17+ protected $page = false; # Target page obj
1818 protected $watchThis = null; # Watch checkbox
1919 protected $reviewThis = null; # Auto-review option...
2020 protected $reason = ''; # Custom/extra reason
@@ -23,19 +23,17 @@
2424 protected $override = -1; # Default version
2525 protected $autoreview = ''; # Autoreview restrictions...
2626
27 - protected $page = false; # Target page obj (of $target)
2827 protected $oldConfig = array(); # Old page config
2928 protected $oldExpiry = ''; # Old page config expiry (GMT)
3029
3130 protected $inputLock = 0; # Disallow bad submissions
3231
33 - public function getTarget() {
34 - return $this->target;
 32+ public function getPage() {
 33+ return $this->page;
3534 }
3635
37 - public function setTarget( $value ) {
38 - $this->trySet( $this->target, $value );
39 - $this->page = Title::newFromURL( $this->target );
 36+ public function setPage( Title $value ) {
 37+ $this->trySet( $this->page, $value );
4038 }
4139
4240 public function getWatchThis() {
@@ -165,7 +163,6 @@
166164 * @return mixed (true on success, error string on failure)
167165 */
168166 protected function checkTarget() {
169 - $this->page = Title::newFromURL( $this->target );
170167 if ( is_null( $this->page ) ) {
171168 return 'stabilize_page_invalid';
172169 } elseif ( !$this->page->exists() ) {
@@ -185,17 +182,6 @@
186183 }
187184
188185 /*
189 - * Gets the target page Obj
190 - * @return mixed (Title or null)
191 - */
192 - public function getPage() {
193 - if ( !$this->inputLock ) {
194 - throw new MWException( __CLASS__ . " input fields not set yet.\n");
195 - }
196 - return $this->page;
197 - }
198 -
199 - /*
200186 * Gets the current config expiry in GMT (or 'infinite')
201187 * @return string
202188 */
Index: trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php
@@ -35,11 +35,16 @@
3636 # Set page title
3737 $this->setHeaders();
3838 $this->sk = $wgUser->getSkin();
39 -
 39+
4040 $this->form = new PageStabilityGeneralForm();
4141 $form = $this->form; // convenience
4242 # Target page
43 - $form->setTarget( $wgRequest->getVal( 'page', $par ) );
 43+ $title = Title::newFromURL( $wgRequest->getVal( 'page', $par ) );
 44+ if ( !$title ) {
 45+ $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
 46+ return;
 47+ }
 48+ $form->setPage( $title );
4449 # Watch checkbox
4550 $form->setWatchThis( (bool)$wgRequest->getCheck( 'wpWatchthis' ) );
4651 # Get auto-review option...
@@ -57,11 +62,6 @@
5863 $form->setAutoreview( $wgRequest->getVal( 'mwProtect-level-autoreview' ) );
5964
6065 $status = $form->ready(); // params all set
61 - if ( $status === 'stabilize_page_invalid' ) {
62 - $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
63 - return;
64 - }
65 - $title = $form->getPage(); // convenience
6666 if ( $status === 'stabilize_page_notexists' ) {
6767 $wgOut->addWikiText(
6868 wfMsg( 'stabilization-notexists', $title->getPrefixedText() ) );
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -2225,7 +2225,7 @@
22262226 return true; // user cannot change anything
22272227 }
22282228 $form = new PageStabilityProtectForm();
2229 - $form->setTarget( $article->getTitle() ); // target page
 2229+ $form->setPage( $article->getTitle() ); // target page
22302230 $permission = $wgRequest->getVal( 'mwStabilityLevel' );
22312231 if ( $permission == "none" ) {
22322232 $permission = ''; // 'none' => ''
Index: trunk/extensions/FlaggedRevs/api/ApiStabilize.php
@@ -51,7 +51,7 @@
5252 ? new PageStabilityProtectForm()
5353 : new PageStabilityGeneralForm();
5454
55 - $form->setTarget( $title ); # Our target page
 55+ $form->setPage( $title ); # Our target page
5656 $form->setWatchThis( $params['watch'] ); # Watch this page
5757 $form->setReason( $params['reason'] ); # Reason
5858 $form->setReasonSelection( 'other' ); # Reason dropdown
@@ -75,7 +75,6 @@
7676 $restriction = ''; // 'none' => ''
7777 }
7878 $form->setAutoreview( $restriction ); # Autoreview restriction
79 - $form->setWasPosted( true ); // already validated
8079 $form->ready();
8180
8281 $status = $form->submit(); // true/error message key

Status & tagging log