r29934 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r29933‎ | r29934 | r29935 >
Date:20:43, 18 January 2008
Author:catrope
Status:old
Tags:
Comment:
API: Making a bunch of state-changing modules require POST requests.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiBlock.php (modified) (history)
  • /trunk/phase3/includes/api/ApiDelete.php (modified) (history)
  • /trunk/phase3/includes/api/ApiLogin.php (modified) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)
  • /trunk/phase3/includes/api/ApiMove.php (modified) (history)
  • /trunk/phase3/includes/api/ApiProtect.php (modified) (history)
  • /trunk/phase3/includes/api/ApiRollback.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUnblock.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUndelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiMove.php
@@ -110,6 +110,8 @@
111111 $this->getResult()->addValue(null, $this->getModuleName(), $r);
112112 }
113113
 114+ public function mustBePosted() { return true; }
 115+
114116 protected function getAllowedParams() {
115117 return array (
116118 'from' => null,
Index: trunk/phase3/includes/api/ApiLogin.php
@@ -217,6 +217,8 @@
218218 private function getMemCacheKey() {
219219 return wfMemcKey( 'apilogin', 'badlogin', 'ip', wfGetIP() );
220220 }
 221+
 222+ public function mustBePosted() { return true; }
221223
222224 protected function getAllowedParams() {
223225 return array (
Index: trunk/phase3/includes/api/ApiProtect.php
@@ -109,6 +109,8 @@
110110 $this->getResult()->addValue(null, $this->getModuleName(), $res);
111111 }
112112
 113+ public function mustBePosted() { return true; }
 114+
113115 protected function getAllowedParams() {
114116 return array (
115117 'title' => null,
Index: trunk/phase3/includes/api/ApiMain.php
@@ -320,8 +320,11 @@
321321 return;
322322 }
323323 }
324 -
 324+
325325 if (!$this->mInternalMode) {
 326+ // Ignore mustBePosted() for internal calls
 327+ if($module->mustBePosted() && !$this->mRequest->wasPosted())
 328+ $this->dieUsage("The {$this->mAction} module requires a POST request", 'mustbeposted');
326329
327330 // See if custom printer is used
328331 $this->mPrinter = $module->getCustomPrinter();
Index: trunk/phase3/includes/api/ApiRollback.php
@@ -86,6 +86,8 @@
8787 $this->getResult()->addValue(null, $this->getModuleName(), $info);
8888 }
8989
 90+ public function mustBePosted() { return true; }
 91+
9092 protected function getAllowedParams() {
9193 return array (
9294 'title' => null,
Index: trunk/phase3/includes/api/ApiBlock.php
@@ -113,6 +113,8 @@
114114 $this->getResult()->addValue(null, $this->getModuleName(), $res);
115115 }
116116
 117+ public function mustBePosted() { return true; }
 118+
117119 protected function getAllowedParams() {
118120 return array (
119121 'user' => null,
Index: trunk/phase3/includes/api/ApiDelete.php
@@ -118,6 +118,8 @@
119119 return array(array('cannotdelete', $article->mTitle->getPrefixedText()));
120120 }
121121
 122+ public function mustBePosted() { return true; }
 123+
122124 protected function getAllowedParams() {
123125 return array (
124126 'title' => null,
Index: trunk/phase3/includes/api/ApiUndelete.php
@@ -81,6 +81,8 @@
8282 $this->getResult()->addValue(null, $this->getModuleName(), $info);
8383 }
8484
 85+ public function mustBePosted() { return true; }
 86+
8587 protected function getAllowedParams() {
8688 return array (
8789 'title' => null,
Index: trunk/phase3/includes/api/ApiBase.php
@@ -652,6 +652,13 @@
653653 public function isEditMode() {
654654 return false;
655655 }
 656+
 657+ /**
 658+ * Indicates whether this module must be called with a POST request
 659+ */
 660+ public function mustBePosted() {
 661+ return false;
 662+ }
656663
657664
658665 /**
Index: trunk/phase3/includes/api/ApiUnblock.php
@@ -82,6 +82,8 @@
8383 $res['reason'] = $reason;
8484 $this->getResult()->addValue(null, $this->getModuleName(), $res);
8585 }
 86+
 87+ public function mustBePosted() { return true; }
8688
8789 protected function getAllowedParams() {
8890 return array (
Index: trunk/phase3/RELEASE-NOTES
@@ -441,6 +441,7 @@
442442 * Added cascade flag to prop=info&inprop=protections
443443 * Added wlshow parameter to list=watchlist, similar to rcshow (list=recentchanges)
444444 * Added support for image thumbnailing to prop=imageinfo
 445+* action={login,block,delete,move,protect,rollback,unblock,undelete} now must be POSTed
445446
446447 === Languages updated in 1.12 ===
447448

Status & tagging log