Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php |
— | — | @@ -269,6 +269,8 @@ |
270 | 270 | |
271 | 271 | $titles = array(); |
272 | 272 | |
| 273 | + $result = $this->getResult(); |
| 274 | + |
273 | 275 | /* Iterate through the rows, adding data extracted from them to our query result. */ |
274 | 276 | foreach ( $res as $row ) { |
275 | 277 | if ( ++ $count > $params['limit'] ) { |
— | — | @@ -285,7 +287,7 @@ |
286 | 288 | if ( !$vals ) { |
287 | 289 | continue; |
288 | 290 | } |
289 | | - $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals ); |
| 291 | + $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals ); |
290 | 292 | if ( !$fit ) { |
291 | 293 | $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) ); |
292 | 294 | break; |
— | — | @@ -297,7 +299,7 @@ |
298 | 300 | |
299 | 301 | if ( is_null( $resultPageSet ) ) { |
300 | 302 | /* Format the result */ |
301 | | - $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' ); |
| 303 | + $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' ); |
302 | 304 | } else { |
303 | 305 | $resultPageSet->populateFromTitles( $titles ); |
304 | 306 | } |
Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php |
— | — | @@ -347,6 +347,7 @@ |
348 | 348 | global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf; |
349 | 349 | |
350 | 350 | $data = array(); |
| 351 | + $result = $this->getResult(); |
351 | 352 | foreach ( $wgGroupPermissions as $group => $permissions ) { |
352 | 353 | $arr = array( |
353 | 354 | 'name' => $group, |
— | — | @@ -375,16 +376,16 @@ |
376 | 377 | foreach ( $groupArr as $type => $rights ) { |
377 | 378 | if ( isset( $rights[$group] ) ) { |
378 | 379 | $arr[$type] = $rights[$group]; |
379 | | - $this->getResult()->setIndexedTagName( $arr[$type], 'group' ); |
| 380 | + $result->setIndexedTagName( $arr[$type], 'group' ); |
380 | 381 | } |
381 | 382 | } |
382 | 383 | |
383 | | - $this->getResult()->setIndexedTagName( $arr['rights'], 'permission' ); |
| 384 | + $result->setIndexedTagName( $arr['rights'], 'permission' ); |
384 | 385 | $data[] = $arr; |
385 | 386 | } |
386 | 387 | |
387 | | - $this->getResult()->setIndexedTagName( $data, 'group' ); |
388 | | - return $this->getResult()->addValue( 'query', $property, $data ); |
| 388 | + $result->setIndexedTagName( $data, 'group' ); |
| 389 | + return $result->addValue( 'query', $property, $data ); |
389 | 390 | } |
390 | 391 | |
391 | 392 | protected function appendFileExtensions( $property ) { |
Index: trunk/phase3/includes/api/ApiMove.php |
— | — | @@ -107,15 +107,18 @@ |
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
| 111 | + $result = $this->getResult(); |
| 112 | + |
111 | 113 | // Move subpages |
112 | 114 | if ( $params['movesubpages'] ) { |
113 | 115 | $r['subpages'] = $this->moveSubpages( $fromTitle, $toTitle, |
114 | 116 | $params['reason'], $params['noredirect'] ); |
115 | | - $this->getResult()->setIndexedTagName( $r['subpages'], 'subpage' ); |
| 117 | + $result->setIndexedTagName( $r['subpages'], 'subpage' ); |
| 118 | + |
116 | 119 | if ( $params['movetalk'] ) { |
117 | 120 | $r['subpages-talk'] = $this->moveSubpages( $fromTalk, $toTalk, |
118 | 121 | $params['reason'], $params['noredirect'] ); |
119 | | - $this->getResult()->setIndexedTagName( $r['subpages-talk'], 'subpage' ); |
| 122 | + $result->setIndexedTagName( $r['subpages-talk'], 'subpage' ); |
120 | 123 | } |
121 | 124 | } |
122 | 125 | |
— | — | @@ -132,7 +135,7 @@ |
133 | 136 | $this->setWatch( $watch, $fromTitle, 'watchmoves' ); |
134 | 137 | $this->setWatch( $watch, $toTitle, 'watchmoves' ); |
135 | 138 | |
136 | | - $this->getResult()->addValue( null, $this->getModuleName(), $r ); |
| 139 | + $result->addValue( null, $this->getModuleName(), $r ); |
137 | 140 | } |
138 | 141 | |
139 | 142 | /** |
Index: trunk/phase3/includes/api/ApiParse.php |
— | — | @@ -77,6 +77,9 @@ |
78 | 78 | |
79 | 79 | $redirValues = null; |
80 | 80 | |
| 81 | + // Return result |
| 82 | + $result = $this->getResult(); |
| 83 | + |
81 | 84 | if ( !is_null( $oldid ) || !is_null( $pageid ) || !is_null( $page ) ) { |
82 | 85 | if ( !is_null( $oldid ) ) { |
83 | 86 | // Don't use the parser cache |
— | — | @@ -178,19 +181,17 @@ |
179 | 182 | if ( $params['onlypst'] ) { |
180 | 183 | // Build a result and bail out |
181 | 184 | $result_array['text'] = array(); |
182 | | - $this->getResult()->setContent( $result_array['text'], $this->pstText ); |
| 185 | + $result->setContent( $result_array['text'], $this->pstText ); |
183 | 186 | if ( isset( $prop['wikitext'] ) ) { |
184 | 187 | $result_array['wikitext'] = array(); |
185 | | - $this->getResult()->setContent( $result_array['wikitext'], $this->text ); |
| 188 | + $result->setContent( $result_array['wikitext'], $this->text ); |
186 | 189 | } |
187 | | - $this->getResult()->addValue( null, $this->getModuleName(), $result_array ); |
| 190 | + $result->addValue( null, $this->getModuleName(), $result_array ); |
188 | 191 | return; |
189 | 192 | } |
190 | 193 | $p_result = $wgParser->parse( $params['pst'] ? $this->pstText : $this->text, $titleObj, $popts ); |
191 | 194 | } |
192 | 195 | |
193 | | - // Return result |
194 | | - $result = $this->getResult(); |
195 | 196 | $result_array = array(); |
196 | 197 | |
197 | 198 | $result_array['title'] = $titleObj->getPrefixedText(); |
Index: trunk/phase3/includes/api/ApiProtect.php |
— | — | @@ -130,8 +130,9 @@ |
131 | 131 | $res['cascade'] = ''; |
132 | 132 | } |
133 | 133 | $res['protections'] = $resultProtections; |
134 | | - $this->getResult()->setIndexedTagName( $res['protections'], 'protection' ); |
135 | | - $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
| 134 | + $result = $this->getResult(); |
| 135 | + $result->setIndexedTagName( $res['protections'], 'protection' ); |
| 136 | + $result->addValue( null, $this->getModuleName(), $res ); |
136 | 137 | } |
137 | 138 | |
138 | 139 | public function mustBePosted() { |
Index: trunk/phase3/includes/api/ApiPurge.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | $article = Article::newFromTitle( $title, $context ); |
74 | 74 | $article->doPurge(); // Directly purge and skip the UI part of purge(). |
75 | 75 | $r['purged'] = ''; |
76 | | - |
| 76 | + |
77 | 77 | if( $forceLinkUpdate ) { |
78 | 78 | if ( !$wgUser->pingLimiter() ) { |
79 | 79 | global $wgParser, $wgEnableParserCache; |
— | — | @@ -94,11 +94,12 @@ |
95 | 95 | $forceLinkUpdate = false; |
96 | 96 | } |
97 | 97 | } |
98 | | - |
| 98 | + |
99 | 99 | $result[] = $r; |
100 | 100 | } |
101 | | - $this->getResult()->setIndexedTagName( $result, 'page' ); |
102 | | - $this->getResult()->addValue( null, $this->getModuleName(), $result ); |
| 101 | + $apiResult = $this->getResult(); |
| 102 | + $apiResult->setIndexedTagName( $result, 'page' ); |
| 103 | + $apiResult->addValue( null, $this->getModuleName(), $result ); |
103 | 104 | } |
104 | 105 | |
105 | 106 | public function isWriteMode() { |
Index: trunk/phase3/includes/api/ApiQueryBacklinks.php |
— | — | @@ -231,9 +231,12 @@ |
232 | 232 | $this->redirect = isset( $this->params['redirect'] ) && $this->params['redirect']; |
233 | 233 | $userMax = ( $this->redirect ? ApiBase::LIMIT_BIG1 / 2 : ApiBase::LIMIT_BIG1 ); |
234 | 234 | $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2 / 2 : ApiBase::LIMIT_BIG2 ); |
| 235 | + |
| 236 | + $result = $this->getResult(); |
| 237 | + |
235 | 238 | if ( $this->params['limit'] == 'max' ) { |
236 | 239 | $this->params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
237 | | - $this->getResult()->setParsedLimit( $this->getModuleName(), $this->params['limit'] ); |
| 240 | + $result->setParsedLimit( $this->getModuleName(), $this->params['limit'] ); |
238 | 241 | } |
239 | 242 | |
240 | 243 | $this->processContinue(); |
— | — | @@ -290,13 +293,13 @@ |
291 | 294 | } |
292 | 295 | if ( is_null( $resultPageSet ) ) { |
293 | 296 | // Try to add the result data in one go and pray that it fits |
294 | | - $fit = $this->getResult()->addValue( 'query', $this->getModuleName(), array_values( $this->resultArr ) ); |
| 297 | + $fit = $result->addValue( 'query', $this->getModuleName(), array_values( $this->resultArr ) ); |
295 | 298 | if ( !$fit ) { |
296 | 299 | // It didn't fit. Add elements one by one until the |
297 | 300 | // result is full. |
298 | 301 | foreach ( $this->resultArr as $pageID => $arr ) { |
299 | 302 | // Add the basic entry without redirlinks first |
300 | | - $fit = $this->getResult()->addValue( |
| 303 | + $fit = $result->addValue( |
301 | 304 | array( 'query', $this->getModuleName() ), |
302 | 305 | null, array_diff_key( $arr, array( 'redirlinks' => '' ) ) ); |
303 | 306 | if ( !$fit ) { |
— | — | @@ -307,7 +310,7 @@ |
308 | 311 | $hasRedirs = false; |
309 | 312 | $redirLinks = isset( $arr['redirlinks'] ) ? $arr['redirlinks'] : array(); |
310 | 313 | foreach ( (array)$redirLinks as $key => $redir ) { |
311 | | - $fit = $this->getResult()->addValue( |
| 314 | + $fit = $result->addValue( |
312 | 315 | array( 'query', $this->getModuleName(), $pageID, 'redirlinks' ), |
313 | 316 | $key, $redir ); |
314 | 317 | if ( !$fit ) { |
— | — | @@ -317,7 +320,7 @@ |
318 | 321 | $hasRedirs = true; |
319 | 322 | } |
320 | 323 | if ( $hasRedirs ) { |
321 | | - $this->getResult()->setIndexedTagName_internal( |
| 324 | + $result->setIndexedTagName_internal( |
322 | 325 | array( 'query', $this->getModuleName(), $pageID, 'redirlinks' ), |
323 | 326 | $this->bl_code ); |
324 | 327 | } |
— | — | @@ -327,7 +330,7 @@ |
328 | 331 | } |
329 | 332 | } |
330 | 333 | |
331 | | - $this->getResult()->setIndexedTagName_internal( |
| 334 | + $result->setIndexedTagName_internal( |
332 | 335 | array( 'query', $this->getModuleName() ), |
333 | 336 | $this->bl_code |
334 | 337 | ); |
Index: trunk/phase3/includes/api/ApiQueryBase.php |
— | — | @@ -352,9 +352,10 @@ |
353 | 353 | protected function setContinueEnumParameter( $paramName, $paramValue ) { |
354 | 354 | $paramName = $this->encodeParamName( $paramName ); |
355 | 355 | $msg = array( $paramName => $paramValue ); |
356 | | - $this->getResult()->disableSizeCheck(); |
357 | | - $this->getResult()->addValue( 'query-continue', $this->getModuleName(), $msg ); |
358 | | - $this->getResult()->enableSizeCheck(); |
| 356 | + $result = $this->getResult(); |
| 357 | + $result->disableSizeCheck(); |
| 358 | + $result->addValue( 'query-continue', $this->getModuleName(), $msg ); |
| 359 | + $result->enableSizeCheck(); |
359 | 360 | } |
360 | 361 | |
361 | 362 | /** |
Index: trunk/phase3/includes/api/ApiImport.php |
— | — | @@ -88,8 +88,9 @@ |
89 | 89 | } |
90 | 90 | |
91 | 91 | $resultData = $reporter->getData(); |
92 | | - $this->getResult()->setIndexedTagName( $resultData, 'page' ); |
93 | | - $this->getResult()->addValue( null, $this->getModuleName(), $resultData ); |
| 92 | + $result = $this->getResult(); |
| 93 | + $result->setIndexedTagName( $resultData, 'page' ); |
| 94 | + $result->addValue( null, $this->getModuleName(), $resultData ); |
94 | 95 | } |
95 | 96 | |
96 | 97 | public function mustBePosted() { |
Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php |
— | — | @@ -129,11 +129,11 @@ |
130 | 130 | 'by the previous query', '_badcontinue' |
131 | 131 | ); |
132 | 132 | } |
133 | | - |
| 133 | + |
134 | 134 | // Remove the types to skip from $queryTypes |
135 | 135 | $contTypeIndex = array_search( $cont[0], $queryTypes ); |
136 | 136 | $queryTypes = array_slice( $queryTypes, $contTypeIndex ); |
137 | | - |
| 137 | + |
138 | 138 | // Add a WHERE clause for sortkey and from |
139 | 139 | // pack( "H*", $foo ) is used to convert hex back to binary |
140 | 140 | $escSortkey = $this->getDB()->addQuotes( pack( "H*", $cont[1] ) ); |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | $contWhere = "cl_sortkey $op $escSortkey OR " . |
145 | 145 | "(cl_sortkey = $escSortkey AND " . |
146 | 146 | "cl_from $op= $from)"; |
147 | | - |
| 147 | + |
148 | 148 | } else { |
149 | 149 | // The below produces ORDER BY cl_sortkey, cl_from, possibly with DESC added to each of them |
150 | 150 | $this->addWhereRange( 'cl_sortkey', |
— | — | @@ -189,6 +189,8 @@ |
190 | 190 | $res = $this->select( __METHOD__ ); |
191 | 191 | $rows = iterator_to_array( $res ); |
192 | 192 | } |
| 193 | + |
| 194 | + $result = $this->getResult(); |
193 | 195 | $count = 0; |
194 | 196 | foreach ( $rows as $row ) { |
195 | 197 | if ( ++ $count > $limit ) { |
— | — | @@ -234,7 +236,7 @@ |
235 | 237 | if ( $fld_timestamp ) { |
236 | 238 | $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp ); |
237 | 239 | } |
238 | | - $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), |
| 240 | + $fit = $result->addValue( array( 'query', $this->getModuleName() ), |
239 | 241 | null, $vals ); |
240 | 242 | if ( !$fit ) { |
241 | 243 | if ( $params['sort'] == 'timestamp' ) { |
— | — | @@ -253,7 +255,7 @@ |
254 | 256 | } |
255 | 257 | |
256 | 258 | if ( is_null( $resultPageSet ) ) { |
257 | | - $this->getResult()->setIndexedTagName_internal( |
| 259 | + $result->setIndexedTagName_internal( |
258 | 260 | array( 'query', $this->getModuleName() ), 'cm' ); |
259 | 261 | } |
260 | 262 | } |
Index: trunk/phase3/includes/api/ApiQuerySearch.php |
— | — | @@ -97,16 +97,17 @@ |
98 | 98 | $this->dieUsage( "{$what} search is disabled", "search-{$what}-disabled" ); |
99 | 99 | } |
100 | 100 | |
| 101 | + $result = $this->getResult(); |
101 | 102 | // Add search meta data to result |
102 | 103 | if ( isset( $searchInfo['totalhits'] ) ) { |
103 | 104 | $totalhits = $matches->getTotalHits(); |
104 | 105 | if ( $totalhits !== null ) { |
105 | | - $this->getResult()->addValue( array( 'query', 'searchinfo' ), |
| 106 | + $result->addValue( array( 'query', 'searchinfo' ), |
106 | 107 | 'totalhits', $totalhits ); |
107 | 108 | } |
108 | 109 | } |
109 | 110 | if ( isset( $searchInfo['suggestion'] ) && $matches->hasSuggestion() ) { |
110 | | - $this->getResult()->addValue( array( 'query', 'searchinfo' ), |
| 111 | + $result->addValue( array( 'query', 'searchinfo' ), |
111 | 112 | 'suggestion', $matches->getSuggestionQuery() ); |
112 | 113 | } |
113 | 114 | |
— | — | @@ -171,7 +172,7 @@ |
172 | 173 | } |
173 | 174 | |
174 | 175 | // Add item to results and see whether it fits |
175 | | - $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), |
| 176 | + $fit = $result->addValue( array( 'query', $this->getModuleName() ), |
176 | 177 | null, $vals ); |
177 | 178 | if ( !$fit ) { |
178 | 179 | $this->setContinueEnumParameter( 'offset', $params['offset'] + $count - 1 ); |
— | — | @@ -185,7 +186,7 @@ |
186 | 187 | } |
187 | 188 | |
188 | 189 | if ( is_null( $resultPageSet ) ) { |
189 | | - $this->getResult()->setIndexedTagName_internal( array( |
| 190 | + $result->setIndexedTagName_internal( array( |
190 | 191 | 'query', $this->getModuleName() |
191 | 192 | ), 'p' ); |
192 | 193 | } else { |
Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -473,6 +473,7 @@ |
474 | 474 | * @return string |
475 | 475 | */ |
476 | 476 | protected function substituteResultWithError( $e ) { |
| 477 | + $result = $this->getResult(); |
477 | 478 | // Printer may not be initialized if the extractRequestParams() fails for the main module |
478 | 479 | if ( !isset ( $this->mPrinter ) ) { |
479 | 480 | // The printer has not been created yet. Try to manually get formatter value. |
— | — | @@ -483,7 +484,7 @@ |
484 | 485 | |
485 | 486 | $this->mPrinter = $this->createPrinterByName( $value ); |
486 | 487 | if ( $this->mPrinter->getNeedsRawData() ) { |
487 | | - $this->getResult()->setRawMode(); |
| 488 | + $result->setRawMode(); |
488 | 489 | } |
489 | 490 | } |
490 | 491 | |
— | — | @@ -512,16 +513,16 @@ |
513 | 514 | ApiResult::setContent( $errMessage, $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : '' ); |
514 | 515 | } |
515 | 516 | |
516 | | - $this->getResult()->reset(); |
517 | | - $this->getResult()->disableSizeCheck(); |
| 517 | + $result->reset(); |
| 518 | + $result->disableSizeCheck(); |
518 | 519 | // Re-add the id |
519 | 520 | $requestid = $this->getParameter( 'requestid' ); |
520 | 521 | if ( !is_null( $requestid ) ) { |
521 | | - $this->getResult()->addValue( null, 'requestid', $requestid ); |
| 522 | + $result->addValue( null, 'requestid', $requestid ); |
522 | 523 | } |
523 | 524 | // servedby is especially useful when debugging errors |
524 | | - $this->getResult()->addValue( null, 'servedby', wfHostName() ); |
525 | | - $this->getResult()->addValue( null, 'error', $errMessage ); |
| 525 | + $result->addValue( null, 'servedby', wfHostName() ); |
| 526 | + $result->addValue( null, 'error', $errMessage ); |
526 | 527 | |
527 | 528 | return $errMessage['code']; |
528 | 529 | } |
— | — | @@ -532,13 +533,14 @@ |
533 | 534 | */ |
534 | 535 | protected function setupExecuteAction() { |
535 | 536 | // First add the id to the top element |
| 537 | + $result = $this->getResult(); |
536 | 538 | $requestid = $this->getParameter( 'requestid' ); |
537 | 539 | if ( !is_null( $requestid ) ) { |
538 | | - $this->getResult()->addValue( null, 'requestid', $requestid ); |
| 540 | + $result->addValue( null, 'requestid', $requestid ); |
539 | 541 | } |
540 | 542 | $servedby = $this->getParameter( 'servedby' ); |
541 | 543 | if ( $servedby ) { |
542 | | - $this->getResult()->addValue( null, 'servedby', wfHostName() ); |
| 544 | + $result->addValue( null, 'servedby', wfHostName() ); |
543 | 545 | } |
544 | 546 | |
545 | 547 | $params = $this->extractRequestParams(); |