Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php |
— | — | @@ -83,11 +83,8 @@ |
84 | 84 | * Generates and outputs the result of this query based upon the provided parameters. |
85 | 85 | */ |
86 | 86 | public function execute() { |
87 | | - /* Initialize vars */ |
88 | | - $limit = $prop = $namespace = $titles = $show = $type = $dir = $start = $end = $token = null; |
89 | | - |
90 | 87 | /* Get the parameters of the request. */ |
91 | | - extract($this->extractRequestParams()); |
| 88 | + $params = $this->extractRequestParams(); |
92 | 89 | |
93 | 90 | /* Build our basic query. Namely, something along the lines of: |
94 | 91 | * SELECT * FROM recentchanges WHERE rc_timestamp > $start |
— | — | @@ -97,13 +94,13 @@ |
98 | 95 | $db = $this->getDB(); |
99 | 96 | $this->addTables('recentchanges'); |
100 | 97 | $this->addOption('USE INDEX', array('recentchanges' => 'rc_timestamp')); |
101 | | - $this->addWhereRange('rc_timestamp', $dir, $start, $end); |
102 | | - $this->addWhereFld('rc_namespace', $namespace); |
| 98 | + $this->addWhereRange('rc_timestamp', $params['dir'], $params['start'], $params['end']); |
| 99 | + $this->addWhereFld('rc_namespace', $params['namespace']); |
103 | 100 | $this->addWhereFld('rc_deleted', 0); |
104 | | - if($titles) |
| 101 | + if($params['titles']) |
105 | 102 | { |
106 | 103 | $lb = new LinkBatch; |
107 | | - foreach($titles as $t) |
| 104 | + foreach($params['titles'] as $t) |
108 | 105 | { |
109 | 106 | $obj = Title::newFromText($t); |
110 | 107 | $lb->addObj($obj); |
— | — | @@ -120,11 +117,11 @@ |
121 | 118 | $this->addWhere($where); |
122 | 119 | } |
123 | 120 | |
124 | | - if(!is_null($type)) |
125 | | - $this->addWhereFld('rc_type', $this->parseRCType($type)); |
| 121 | + if(!is_null($params['type'])) |
| 122 | + $this->addWhereFld('rc_type', $this->parseRCType($params['type'])); |
126 | 123 | |
127 | | - if (!is_null($show)) { |
128 | | - $show = array_flip($show); |
| 124 | + if (!is_null($params['show'])) { |
| 125 | + $show = array_flip($params['show']); |
129 | 126 | |
130 | 127 | /* Check for conflicting parameters. */ |
131 | 128 | if ((isset ($show['minor']) && isset ($show['!minor'])) |
— | — | @@ -167,8 +164,8 @@ |
168 | 165 | )); |
169 | 166 | |
170 | 167 | /* Determine what properties we need to display. */ |
171 | | - if (!is_null($prop)) { |
172 | | - $prop = array_flip($prop); |
| 168 | + if (!is_null($params['prop'])) { |
| 169 | + $prop = array_flip($params['prop']); |
173 | 170 | |
174 | 171 | /* Set up internal members based upon params. */ |
175 | 172 | $this->fld_comment = isset ($prop['comment']); |
— | — | @@ -210,10 +207,8 @@ |
211 | 208 | $this->addFields('page_is_redirect'); |
212 | 209 | } |
213 | 210 | } |
214 | | - $this->token = $token; |
215 | | - /* Specify the limit for our query. It's $limit+1 because we (possibly) need to |
216 | | - * generate a "continue" parameter, to allow paging. */ |
217 | | - $this->addOption('LIMIT', $limit +1); |
| 211 | + $this->token = $params['token']; |
| 212 | + $this->addOption('LIMIT', $params['limit'] +1); |
218 | 213 | |
219 | 214 | $data = array (); |
220 | 215 | $count = 0; |
— | — | @@ -224,7 +219,7 @@ |
225 | 220 | |
226 | 221 | /* Iterate through the rows, adding data extracted from them to our query result. */ |
227 | 222 | while ($row = $db->fetchObject($res)) { |
228 | | - if (++ $count > $limit) { |
| 223 | + if (++ $count > $params['limit']) { |
229 | 224 | // We've reached the one extra which shows that there are additional pages to be had. Stop here... |
230 | 225 | $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->rc_timestamp)); |
231 | 226 | break; |
Index: trunk/phase3/includes/api/ApiQueryBacklinks.php |
— | — | @@ -60,7 +60,6 @@ |
61 | 61 | ); |
62 | 62 | |
63 | 63 | public function __construct($query, $moduleName) { |
64 | | - $code = $prefix = $linktbl = null; |
65 | 64 | extract($this->backlinksSettings[$moduleName]); |
66 | 65 | |
67 | 66 | parent :: __construct($query, $moduleName, $code); |
Index: trunk/phase3/includes/api/ApiRollback.php |
— | — | @@ -70,16 +70,13 @@ |
71 | 71 | // We don't care about multiple errors, just report one of them |
72 | 72 | $this->dieUsageMsg(current($retval)); |
73 | 73 | |
74 | | - $current = $target = $summary = NULL; |
75 | | - extract($details); |
76 | | - |
77 | 74 | $info = array( |
78 | 75 | 'title' => $titleObj->getPrefixedText(), |
79 | | - 'pageid' => $current->getPage(), |
80 | | - 'summary' => $summary, |
| 76 | + 'pageid' => $details['current']->getPage(), |
| 77 | + 'summary' => $details['summary'], |
81 | 78 | 'revid' => $titleObj->getLatestRevID(), |
82 | | - 'old_revid' => $current->getID(), |
83 | | - 'last_revid' => $target->getID() |
| 79 | + 'old_revid' => $details['current']->getID(), |
| 80 | + 'last_revid' => $details['target']->getID() |
84 | 81 | ); |
85 | 82 | |
86 | 83 | $this->getResult()->addValue(null, $this->getModuleName(), $info); |
Index: trunk/phase3/includes/api/ApiExpandTemplates.php |
— | — | @@ -43,23 +43,22 @@ |
44 | 44 | |
45 | 45 | public function execute() { |
46 | 46 | // Get parameters |
47 | | - extract( $this->extractRequestParams() ); |
48 | | - $retval = ''; |
| 47 | + $params = $this->extractRequestParams(); |
49 | 48 | |
50 | 49 | //Create title for parser |
51 | | - $title_obj = Title :: newFromText( $title ); |
| 50 | + $title_obj = Title :: newFromText( $params['title'] ); |
52 | 51 | if(!$title_obj) |
53 | | - $title_obj = Title :: newFromText( "API" ); // Default title is "API". For example, ExpandTemplates uses "ExpendTemplates" for it |
| 52 | + $title_obj = Title :: newFromText( "API" ); // default |
54 | 53 | |
55 | 54 | $result = $this->getResult(); |
56 | 55 | |
57 | 56 | // Parse text |
58 | 57 | global $wgParser; |
59 | 58 | $options = new ParserOptions(); |
60 | | - if ( $generatexml ) |
| 59 | + if ( $params['generatexml'] ) |
61 | 60 | { |
62 | 61 | $wgParser->startExternalParse( $title_obj, $options, OT_PREPROCESS ); |
63 | | - $dom = $wgParser->preprocessToDom( $text ); |
| 62 | + $dom = $wgParser->preprocessToDom( $params['text'] ); |
64 | 63 | if ( is_callable( array( $dom, 'saveXML' ) ) ) { |
65 | 64 | $xml = $dom->saveXML(); |
66 | 65 | } else { |
— | — | @@ -67,9 +66,9 @@ |
68 | 67 | } |
69 | 68 | $xml_result = array(); |
70 | 69 | $result->setContent( $xml_result, $xml ); |
71 | | - $result->addValue( null, 'parsetree', $xml_result); |
| 70 | + $result->addValue( null, 'parsetree', $xml_result); |
72 | 71 | } |
73 | | - $retval = $wgParser->preprocess( $text, $title_obj, $options ); |
| 72 | + $retval = $wgParser->preprocess( $params['text'], $title_obj, $options ); |
74 | 73 | |
75 | 74 | // Return result |
76 | 75 | $retval_array = array(); |
Index: trunk/phase3/includes/api/ApiLogin.php |
— | — | @@ -52,15 +52,14 @@ |
53 | 53 | * @access public |
54 | 54 | */ |
55 | 55 | public function execute() { |
56 | | - $name = $password = $domain = null; |
57 | | - extract($this->extractRequestParams()); |
| 56 | + $params = $this->extractRequestParams(); |
58 | 57 | |
59 | 58 | $result = array (); |
60 | 59 | |
61 | | - $params = new FauxRequest(array ( |
62 | | - 'wpName' => $name, |
63 | | - 'wpPassword' => $password, |
64 | | - 'wpDomain' => $domain, |
| 60 | + $req = new FauxRequest(array ( |
| 61 | + 'wpName' => $params['name'], |
| 62 | + 'wpPassword' => $params['password'], |
| 63 | + 'wpDomain' => $params['domain'], |
65 | 64 | 'wpRemember' => '' |
66 | 65 | )); |
67 | 66 | |
— | — | @@ -69,7 +68,7 @@ |
70 | 69 | wfSetupSession(); |
71 | 70 | } |
72 | 71 | |
73 | | - $loginForm = new LoginForm($params); |
| 72 | + $loginForm = new LoginForm($req); |
74 | 73 | switch ($authRes = $loginForm->authenticateUserData()) { |
75 | 74 | case LoginForm :: SUCCESS : |
76 | 75 | global $wgUser, $wgCookiePrefix; |
Index: trunk/phase3/includes/api/ApiPageSet.php |
— | — | @@ -228,19 +228,18 @@ |
229 | 229 | */ |
230 | 230 | public function execute() { |
231 | 231 | $this->profileIn(); |
232 | | - $titles = $pageids = $revids = null; |
233 | | - extract($this->extractRequestParams()); |
| 232 | + $params = $this->extractRequestParams(); |
234 | 233 | |
235 | 234 | // Only one of the titles/pageids/revids is allowed at the same time |
236 | 235 | $dataSource = null; |
237 | | - if (isset ($titles)) |
| 236 | + if (isset ($params['titles'])) |
238 | 237 | $dataSource = 'titles'; |
239 | | - if (isset ($pageids)) { |
| 238 | + if (isset ($params['pageids'])) { |
240 | 239 | if (isset ($dataSource)) |
241 | 240 | $this->dieUsage("Cannot use 'pageids' at the same time as '$dataSource'", 'multisource'); |
242 | 241 | $dataSource = 'pageids'; |
243 | 242 | } |
244 | | - if (isset ($revids)) { |
| 243 | + if (isset ($params['revids'])) { |
245 | 244 | if (isset ($dataSource)) |
246 | 245 | $this->dieUsage("Cannot use 'revids' at the same time as '$dataSource'", 'multisource'); |
247 | 246 | $dataSource = 'revids'; |
— | — | @@ -248,17 +247,17 @@ |
249 | 248 | |
250 | 249 | switch ($dataSource) { |
251 | 250 | case 'titles' : |
252 | | - $this->initFromTitles($titles); |
| 251 | + $this->initFromTitles($params['titles']); |
253 | 252 | break; |
254 | 253 | case 'pageids' : |
255 | | - $this->initFromPageIds($pageids); |
| 254 | + $this->initFromPageIds($params['pageids']); |
256 | 255 | break; |
257 | 256 | case 'revids' : |
258 | 257 | if($this->mResolveRedirects) |
259 | 258 | $this->setWarning('Redirect resolution cannot be used together with the revids= parameter. '. |
260 | 259 | 'Any redirects the revids= point to have not been resolved.'); |
261 | 260 | $this->mResolveRedirects = false; |
262 | | - $this->initFromRevIDs($revids); |
| 261 | + $this->initFromRevIDs($params['revids']); |
263 | 262 | break; |
264 | 263 | default : |
265 | 264 | // Do nothing - some queries do not need any of the data sources. |
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php |
— | — | @@ -59,12 +59,11 @@ |
60 | 60 | if (!$wgUser->isLoggedIn()) |
61 | 61 | $this->dieUsage('You must be logged-in to have a watchlist', 'notloggedin'); |
62 | 62 | |
63 | | - $allrev = $start = $end = $namespace = $dir = $limit = $prop = $show = null; |
64 | | - extract($this->extractRequestParams()); |
| 63 | + $params = $this->extractRequestParams(); |
65 | 64 | |
66 | | - if (!is_null($prop) && is_null($resultPageSet)) { |
| 65 | + if (!is_null($params['prop']) && is_null($resultPageSet)) { |
67 | 66 | |
68 | | - $prop = array_flip($prop); |
| 67 | + $prop = array_flip($params['prop']); |
69 | 68 | |
70 | 69 | $this->fld_ids = isset($prop['ids']); |
71 | 70 | $this->fld_title = isset($prop['title']); |
— | — | @@ -100,7 +99,7 @@ |
101 | 100 | $this->addFieldsIf('rc_old_len', $this->fld_sizes); |
102 | 101 | $this->addFieldsIf('rc_new_len', $this->fld_sizes); |
103 | 102 | } |
104 | | - elseif ($allrev) { |
| 103 | + elseif ($params['allrev']) { |
105 | 104 | $this->addFields(array ( |
106 | 105 | 'rc_this_oldid', |
107 | 106 | 'rc_namespace', |
— | — | @@ -131,12 +130,12 @@ |
132 | 131 | 'rc_deleted' => 0, |
133 | 132 | )); |
134 | 133 | |
135 | | - $this->addWhereRange('rc_timestamp', $dir, $start, $end); |
136 | | - $this->addWhereFld('wl_namespace', $namespace); |
137 | | - $this->addWhereIf('rc_this_oldid=page_latest', !$allrev); |
| 134 | + $this->addWhereRange('rc_timestamp', $params['dir'], $params['start'], $params['end']); |
| 135 | + $this->addWhereFld('wl_namespace', $params['namespace']); |
| 136 | + $this->addWhereIf('rc_this_oldid=page_latest', !$params['allrev']); |
138 | 137 | |
139 | | - if (!is_null($show)) { |
140 | | - $show = array_flip($show); |
| 138 | + if (!is_null($params['show'])) { |
| 139 | + $show = array_flip($params['show']); |
141 | 140 | |
142 | 141 | /* Check for conflicting parameters. */ |
143 | 142 | if ((isset ($show['minor']) && isset ($show['!minor'])) |
— | — | @@ -165,9 +164,9 @@ |
166 | 165 | |
167 | 166 | |
168 | 167 | # This is an index optimization for mysql, as done in the Special:Watchlist page |
169 | | - $this->addWhereIf("rc_timestamp > ''", !isset ($start) && !isset ($end) && $wgDBtype == 'mysql'); |
| 168 | + $this->addWhereIf("rc_timestamp > ''", !isset ($params['start']) && !isset ($params['end']) && $wgDBtype == 'mysql'); |
170 | 169 | |
171 | | - $this->addOption('LIMIT', $limit +1); |
| 170 | + $this->addOption('LIMIT', $params['limit'] +1); |
172 | 171 | |
173 | 172 | $data = array (); |
174 | 173 | $count = 0; |
— | — | @@ -175,7 +174,7 @@ |
176 | 175 | |
177 | 176 | $db = $this->getDB(); |
178 | 177 | while ($row = $db->fetchObject($res)) { |
179 | | - if (++ $count > $limit) { |
| 178 | + if (++ $count > $params['limit']) { |
180 | 179 | // We've reached the one extra which shows that there are additional pages to be had. Stop here... |
181 | 180 | $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->rc_timestamp)); |
182 | 181 | break; |
— | — | @@ -186,7 +185,7 @@ |
187 | 186 | if ($vals) |
188 | 187 | $data[] = $vals; |
189 | 188 | } else { |
190 | | - if ($allrev) { |
| 189 | + if ($params['allrev']) { |
191 | 190 | $data[] = intval($row->rc_this_oldid); |
192 | 191 | } else { |
193 | 192 | $data[] = intval($row->rc_cur_id); |
— | — | @@ -200,7 +199,7 @@ |
201 | 200 | $this->getResult()->setIndexedTagName($data, 'item'); |
202 | 201 | $this->getResult()->addValue('query', $this->getModuleName(), $data); |
203 | 202 | } |
204 | | - elseif ($allrev) { |
| 203 | + elseif ($params['allrev']) { |
205 | 204 | $resultPageSet->populateFromRevisionIDs($data); |
206 | 205 | } else { |
207 | 206 | $resultPageSet->populateFromPageIDs($data); |
Index: trunk/phase3/includes/api/ApiQueryRevisions.php |
— | — | @@ -74,14 +74,16 @@ |
75 | 75 | } |
76 | 76 | |
77 | 77 | public function execute() { |
78 | | - $limit = $startid = $endid = $start = $end = $dir = $prop = $user = $excludeuser = $expandtemplates = $generatexml = $section = $token = null; |
79 | | - extract($this->extractRequestParams(false)); |
| 78 | + $params = $this->extractRequestParams(false); |
80 | 79 | |
81 | 80 | // If any of those parameters are used, work in 'enumeration' mode. |
82 | 81 | // Enum mode can only be used when exactly one page is provided. |
83 | 82 | // Enumerating revisions on multiple pages make it extremely |
84 | 83 | // difficult to manage continuations and require additional SQL indexes |
85 | | - $enumRevMode = (!is_null($user) || !is_null($excludeuser) || !is_null($limit) || !is_null($startid) || !is_null($endid) || $dir === 'newer' || !is_null($start) || !is_null($end)); |
| 84 | + $enumRevMode = (!is_null($params['user']) || !is_null($params['excludeuser']) || |
| 85 | + !is_null($params['limit']) || !is_null($params['startid']) || |
| 86 | + !is_null($params['endid']) || $params['dir'] === 'newer' || |
| 87 | + !is_null($params['start']) || !is_null($params['end'])); |
86 | 88 | |
87 | 89 | |
88 | 90 | $pageSet = $this->getPageSet(); |
— | — | @@ -103,7 +105,7 @@ |
104 | 106 | $this->addTables( 'page' ); |
105 | 107 | $this->addWhere('page_id = rev_page'); |
106 | 108 | |
107 | | - $prop = array_flip($prop); |
| 109 | + $prop = array_flip($params['prop']); |
108 | 110 | |
109 | 111 | // Optional fields |
110 | 112 | $this->fld_ids = isset ($prop['ids']); |
— | — | @@ -113,7 +115,7 @@ |
114 | 116 | $this->fld_comment = isset ($prop['comment']); |
115 | 117 | $this->fld_size = isset ($prop['size']); |
116 | 118 | $this->fld_user = isset ($prop['user']); |
117 | | - $this->token = $token; |
| 119 | + $this->token = $params['token']; |
118 | 120 | |
119 | 121 | if ( !is_null($this->token) || $pageCount > 0) { |
120 | 122 | $this->addFields( Revision::selectPageFields() ); |
— | — | @@ -136,16 +138,17 @@ |
137 | 139 | |
138 | 140 | $this->fld_content = true; |
139 | 141 | |
140 | | - $this->expandTemplates = $expandtemplates; |
141 | | - $this->generateXML = $generatexml; |
142 | | - if(isset($section)) |
143 | | - $this->section = $section; |
| 142 | + $this->expandTemplates = $params['expandtemplates']; |
| 143 | + $this->generateXML = $params['generatexml']; |
| 144 | + if(isset($params['section'])) |
| 145 | + $this->section = $params['section']; |
144 | 146 | else |
145 | 147 | $this->section = false; |
146 | 148 | } |
147 | 149 | |
148 | 150 | $userMax = ( $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1 ); |
149 | 151 | $botMax = ( $this->fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2 ); |
| 152 | + $limit = $params['limit']; |
150 | 153 | if( $limit == 'max' ) { |
151 | 154 | $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
152 | 155 | $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit ); |
— | — | @@ -154,13 +157,13 @@ |
155 | 158 | if ($enumRevMode) { |
156 | 159 | |
157 | 160 | // This is mostly to prevent parameter errors (and optimize SQL?) |
158 | | - if (!is_null($startid) && !is_null($start)) |
| 161 | + if (!is_null($params['startid']) && !is_null($params['start'])) |
159 | 162 | $this->dieUsage('start and startid cannot be used together', 'badparams'); |
160 | 163 | |
161 | | - if (!is_null($endid) && !is_null($end)) |
| 164 | + if (!is_null($params['endid']) && !is_null($params['end'])) |
162 | 165 | $this->dieUsage('end and endid cannot be used together', 'badparams'); |
163 | 166 | |
164 | | - if(!is_null($user) && !is_null( $excludeuser)) |
| 167 | + if(!is_null($params['user']) && !is_null($params['excludeuser'])) |
165 | 168 | $this->dieUsage('user and excludeuser cannot be used together', 'badparams'); |
166 | 169 | |
167 | 170 | // This code makes an assumption that sorting by rev_id and rev_timestamp produces |
— | — | @@ -170,10 +173,12 @@ |
171 | 174 | // one row with the same timestamp for the same page. |
172 | 175 | // The order needs to be the same as start parameter to avoid SQL filesort. |
173 | 176 | |
174 | | - if (is_null($startid) && is_null($endid)) |
175 | | - $this->addWhereRange('rev_timestamp', $dir, $start, $end); |
| 177 | + if (is_null($params['startid']) && is_null($params['endid'])) |
| 178 | + $this->addWhereRange('rev_timestamp', $params['dir'], |
| 179 | + $params['start'], $params['end']); |
176 | 180 | else |
177 | | - $this->addWhereRange('rev_id', $dir, $startid, $endid); |
| 181 | + $this->addWhereRange('rev_id', $params['dir'], |
| 182 | + $params['startid'], $params['endid']); |
178 | 183 | |
179 | 184 | // must manually initialize unset limit |
180 | 185 | if (is_null($limit)) |
— | — | @@ -183,10 +188,11 @@ |
184 | 189 | // There is only one ID, use it |
185 | 190 | $this->addWhereFld('rev_page', current(array_keys($pageSet->getGoodTitles()))); |
186 | 191 | |
187 | | - if(!is_null($user)) { |
188 | | - $this->addWhereFld('rev_user_text', $user); |
189 | | - } elseif (!is_null( $excludeuser)) { |
190 | | - $this->addWhere('rev_user_text != ' . $this->getDB()->addQuotes($excludeuser)); |
| 192 | + if(!is_null($params['user'])) { |
| 193 | + $this->addWhereFld('rev_user_text', $params['user']); |
| 194 | + } elseif (!is_null( $params['excludeuser'])) { |
| 195 | + $this->addWhere('rev_user_text != ' . |
| 196 | + $this->getDB()->addQuotes($params['excludeuser'])); |
191 | 197 | } |
192 | 198 | } |
193 | 199 | elseif ($revCount > 0) { |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -369,7 +369,6 @@ |
370 | 370 | /** |
371 | 371 | * Using getAllowedParams(), makes an array of the values provided by the user, |
372 | 372 | * with key being the name of the variable, and value - validated value from user or default. |
373 | | - * This method can be used to generate local variables using extract(). |
374 | 373 | * limit=max will not be parsed if $parseMaxLimit is set to false; use this |
375 | 374 | * when the max limit is not definite, e.g. when getting revisions. |
376 | 375 | */ |