diff options
author | Aryeh Gregor <simetrical@users.mediawiki.org> | 2010-08-13 21:39:51 +0000 |
---|---|---|
committer | Aryeh Gregor <simetrical@users.mediawiki.org> | 2010-08-13 21:39:51 +0000 |
commit | a6aac77d16bb7d5683bc7f67ac96f88e6ab177e3 (patch) | |
tree | b1e41cc9527c76728d535bc841db4a134af214bc /includes/AjaxDispatcher.php | |
parent | 380b6725d5b0c127bd8d62af8904f6787905aca8 (diff) | |
download | mediawikicore-a6aac77d16bb7d5683bc7f67ac96f88e6ab177e3.tar.gz mediawikicore-a6aac77d16bb7d5683bc7f67ac96f88e6ab177e3.zip |
Revert r70960 "AjaxDispatcher, now ~30 lines shorter and not using $_GET or $_POST"
Broke CategoryTree, see code review for the error message.
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/71050
Diffstat (limited to 'includes/AjaxDispatcher.php')
-rw-r--r-- | includes/AjaxDispatcher.php | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index 969efa4790fc..16e530118050 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -18,23 +18,51 @@ require_once( 'AjaxFunctions.php' ); * @ingroup Ajax */ class AjaxDispatcher { + /** The way the request was made, either a 'get' or a 'post' */ + private $mode; + /** Name of the requested handler */ - private $func_name = null; + private $func_name; /** Arguments passed */ - private $args = array(); + private $args; /** Load up our object with user supplied data */ - public function __construct( WebRequest $req ) { + function __construct() { wfProfileIn( __METHOD__ ); - $rs = $req->getVal( 'rs' ); - if( $rs !== null ) { - $this->func_name = $rs; + $this->mode = ""; + + if ( ! empty( $_GET["rs"] ) ) { + $this->mode = "get"; } - $rsargs = $req->getVal( 'rsargs' ); - if( $rsargs !== null ) { - $this->args = $rsargs; + + if ( !empty( $_POST["rs"] ) ) { + $this->mode = "post"; + } + + switch( $this->mode ) { + case 'get': + $this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : ''; + if ( ! empty( $_GET["rsargs"] ) ) { + $this->args = $_GET["rsargs"]; + } else { + $this->args = array(); + } + break; + case 'post': + $this->func_name = isset( $_POST["rs"] ) ? $_POST["rs"] : ''; + if ( ! empty( $_POST["rsargs"] ) ) { + $this->args = $_POST["rsargs"]; + } else { + $this->args = array(); + } + break; + default: + wfProfileOut( __METHOD__ ); + return; + # Or we could throw an exception: + # throw new MWException( __METHOD__ . ' called without any data (mode empty).' ); } wfProfileOut( __METHOD__ ); @@ -48,7 +76,7 @@ class AjaxDispatcher { function performAction() { global $wgAjaxExportList, $wgOut; - if ( is_null( $this->func_name ) ) { + if ( empty( $this->mode ) ) { return; } |