From 2cc5f4e9723b6b3c39ff98ccd354b3053b4b82d9 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Sun, 15 May 2011 14:57:10 +0000 Subject: [PATCH] Kill the error suppression operator in the Api --- includes/api/ApiParse.php | 3 ++- includes/api/ApiQuery.php | 5 ++--- includes/api/ApiQueryBacklinks.php | 3 ++- includes/api/ApiQueryExternalLinks.php | 7 ++++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 3284ece5f7..49978ec175 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -134,7 +134,8 @@ class ApiParse extends ApiBase { $main = new ApiMain( $req ); $main->execute(); $data = $main->getResultData(); - $redirValues = @$data['query']['redirects']; + $redirValues = isset( $data['query']['redirects'] ) + ? $data['query']['redirects'] : array(); $to = $page; foreach ( (array)$redirValues as $r ) { $to = $r['to']; diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index f62104104f..ded1ea54a1 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -316,9 +316,8 @@ class ApiQuery extends ApiBase { * @param $moduleList Array array(modulename => classname) */ private function instantiateModules( &$modules, $param, $moduleList ) { - $list = @$this->params[$param]; - if ( !is_null ( $list ) ) { - foreach ( $list as $moduleName ) { + if ( isset( $this->params[$param] ) ) { + foreach ( $this->params[$param] as $moduleName ) { $modules[] = new $moduleList[$moduleName] ( $this, $moduleName ); } } diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 6335f6cce1..b4070d6203 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -305,7 +305,8 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { } $hasRedirs = false; - foreach ( (array)@$arr['redirlinks'] as $key => $redir ) { + $redirLinks = isset( $arr['redirlinks'] ) ? $arr['redirlinks'] : array(); + foreach ( (array)$redirLinks as $key => $redir ) { $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName(), $pageID, 'redirlinks' ), $key, $redir ); diff --git a/includes/api/ApiQueryExternalLinks.php b/includes/api/ApiQueryExternalLinks.php index 75120f6397..88d3258305 100644 --- a/includes/api/ApiQueryExternalLinks.php +++ b/includes/api/ApiQueryExternalLinks.php @@ -70,7 +70,8 @@ class ApiQueryExternalLinks extends ApiQueryBase { } $this->addOption( 'LIMIT', $params['limit'] + 1 ); - if ( !is_null( $params['offset'] ) ) { + $offset = isset( $params['offset'] ) ? $params['offset'] : 0; + if ( $offset ) { $this->addOption( 'OFFSET', $params['offset'] ); } @@ -81,14 +82,14 @@ class ApiQueryExternalLinks extends ApiQueryBase { if ( ++$count > $params['limit'] ) { // We've reached the one extra which shows that // there are additional pages to be had. Stop here... - $this->setContinueEnumParameter( 'offset', @$params['offset'] + $params['limit'] ); + $this->setContinueEnumParameter( 'offset', $offset + $params['limit'] ); break; } $entry = array(); ApiResult::setContent( $entry, $row->el_to ); $fit = $this->addPageSubItem( $row->el_from, $entry ); if ( !$fit ) { - $this->setContinueEnumParameter( 'offset', @$params['offset'] + $count - 1 ); + $this->setContinueEnumParameter( 'offset', $offset + $count - 1 ); break; } } -- 2.20.1