r88191 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88190‎ | r88191 | r88192 >
Date:14:57, 15 May 2011
Author:btongminh
Status:ok
Tags:
Comment:
Kill the error suppression operator in the Api
Modified paths:
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBacklinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryExternalLinks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiParse.php
@@ -134,7 +134,8 @@
135135 $main = new ApiMain( $req );
136136 $main->execute();
137137 $data = $main->getResultData();
138 - $redirValues = @$data['query']['redirects'];
 138+ $redirValues = isset( $data['query']['redirects'] )
 139+ ? $data['query']['redirects'] : array();
139140 $to = $page;
140141 foreach ( (array)$redirValues as $r ) {
141142 $to = $r['to'];
Index: trunk/phase3/includes/api/ApiQueryBacklinks.php
@@ -305,7 +305,8 @@
306306 }
307307
308308 $hasRedirs = false;
309 - foreach ( (array)@$arr['redirlinks'] as $key => $redir ) {
 309+ $redirLinks = isset( $arr['redirlinks'] ) ? $arr['redirlinks'] : array();
 310+ foreach ( (array)$redirLinks as $key => $redir ) {
310311 $fit = $this->getResult()->addValue(
311312 array( 'query', $this->getModuleName(), $pageID, 'redirlinks' ),
312313 $key, $redir );
Index: trunk/phase3/includes/api/ApiQuery.php
@@ -316,9 +316,8 @@
317317 * @param $moduleList Array array(modulename => classname)
318318 */
319319 private function instantiateModules( &$modules, $param, $moduleList ) {
320 - $list = @$this->params[$param];
321 - if ( !is_null ( $list ) ) {
322 - foreach ( $list as $moduleName ) {
 320+ if ( isset( $this->params[$param] ) ) {
 321+ foreach ( $this->params[$param] as $moduleName ) {
323322 $modules[] = new $moduleList[$moduleName] ( $this, $moduleName );
324323 }
325324 }
Index: trunk/phase3/includes/api/ApiQueryExternalLinks.php
@@ -70,7 +70,8 @@
7171 }
7272
7373 $this->addOption( 'LIMIT', $params['limit'] + 1 );
74 - if ( !is_null( $params['offset'] ) ) {
 74+ $offset = isset( $params['offset'] ) ? $params['offset'] : 0;
 75+ if ( $offset ) {
7576 $this->addOption( 'OFFSET', $params['offset'] );
7677 }
7778
@@ -81,14 +82,14 @@
8283 if ( ++$count > $params['limit'] ) {
8384 // We've reached the one extra which shows that
8485 // there are additional pages to be had. Stop here...
85 - $this->setContinueEnumParameter( 'offset', @$params['offset'] + $params['limit'] );
 86+ $this->setContinueEnumParameter( 'offset', $offset + $params['limit'] );
8687 break;
8788 }
8889 $entry = array();
8990 ApiResult::setContent( $entry, $row->el_to );
9091 $fit = $this->addPageSubItem( $row->el_from, $entry );
9192 if ( !$fit ) {
92 - $this->setContinueEnumParameter( 'offset', @$params['offset'] + $count - 1 );
 93+ $this->setContinueEnumParameter( 'offset', $offset + $count - 1 );
9394 break;
9495 }
9596 }

Status & tagging log