Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / api / ApiQueryIWBacklinks.php
index 2fe4bd9..6e2fb67 100644 (file)
@@ -51,7 +51,14 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                $params = $this->extractRequestParams();
 
                if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'prefix' ) );
+                       $this->dieWithError(
+                               [
+                                       'apierror-invalidparammix-mustusewith',
+                                       $this->encodeParamName( 'title' ),
+                                       $this->encodeParamName( 'prefix' ),
+                               ],
+                               'invalidparammix'
+                       );
                }
 
                if ( !is_null( $params['continue'] ) ) {
@@ -76,11 +83,11 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                $iwprefix = isset( $prop['iwprefix'] );
                $iwtitle = isset( $prop['iwtitle'] );
 
-               $this->addTables( array( 'iwlinks', 'page' ) );
+               $this->addTables( [ 'iwlinks', 'page' ] );
                $this->addWhere( 'iwl_from = page_id' );
 
-               $this->addFields( array( 'page_id', 'page_title', 'page_namespace', 'page_is_redirect',
-                       'iwl_from', 'iwl_prefix', 'iwl_title' ) );
+               $this->addFields( [ 'page_id', 'page_title', 'page_namespace', 'page_is_redirect',
+                       'iwl_from', 'iwl_prefix', 'iwl_title' ] );
 
                $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' );
                if ( isset( $params['prefix'] ) ) {
@@ -89,24 +96,24 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                                $this->addWhereFld( 'iwl_title', $params['title'] );
                                $this->addOption( 'ORDER BY', 'iwl_from' . $sort );
                        } else {
-                               $this->addOption( 'ORDER BY', array(
+                               $this->addOption( 'ORDER BY', [
                                        'iwl_title' . $sort,
                                        'iwl_from' . $sort
-                               ) );
+                               ] );
                        }
                } else {
-                       $this->addOption( 'ORDER BY', array(
+                       $this->addOption( 'ORDER BY', [
                                'iwl_prefix' . $sort,
                                'iwl_title' . $sort,
                                'iwl_from' . $sort
-                       ) );
+                       ] );
                }
 
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
 
                $res = $this->select( __METHOD__ );
 
-               $pages = array();
+               $pages = [];
 
                $count = 0;
                $result = $this->getResult();
@@ -126,7 +133,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                        if ( !is_null( $resultPageSet ) ) {
                                $pages[] = Title::newFromRow( $row );
                        } else {
-                               $entry = array( 'pageid' => $row->page_id );
+                               $entry = [ 'pageid' => $row->page_id ];
 
                                $title = Title::makeTitle( $row->page_namespace, $row->page_title );
                                ApiQueryBase::addTitleInfo( $entry, $title );
@@ -143,7 +150,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                                        $entry['iwtitle'] = $row->iwl_title;
                                }
 
-                               $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $entry );
+                               $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $entry );
                                if ( !$fit ) {
                                        $this->setContinueEnumParameter(
                                                'continue',
@@ -155,7 +162,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                }
 
                if ( is_null( $resultPageSet ) ) {
-                       $result->addIndexedTagName( array( 'query', $this->getModuleName() ), 'iw' );
+                       $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'iw' );
                } else {
                        $resultPageSet->populateFromTitles( $pages );
                }
@@ -166,45 +173,45 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
        }
 
        public function getAllowedParams() {
-               return array(
+               return [
                        'prefix' => null,
                        'title' => null,
-                       'continue' => array(
+                       'continue' => [
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
-                       ),
-                       'limit' => array(
+                       ],
+                       'limit' => [
                                ApiBase::PARAM_DFLT => 10,
                                ApiBase::PARAM_TYPE => 'limit',
                                ApiBase::PARAM_MIN => 1,
                                ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
                                ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
-                       ),
-                       'prop' => array(
+                       ],
+                       'prop' => [
                                ApiBase::PARAM_ISMULTI => true,
                                ApiBase::PARAM_DFLT => '',
-                               ApiBase::PARAM_TYPE => array(
+                               ApiBase::PARAM_TYPE => [
                                        'iwprefix',
                                        'iwtitle',
-                               ),
-                               ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
-                       ),
-                       'dir' => array(
+                               ],
+                               ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
+                       ],
+                       'dir' => [
                                ApiBase::PARAM_DFLT => 'ascending',
-                               ApiBase::PARAM_TYPE => array(
+                               ApiBase::PARAM_TYPE => [
                                        'ascending',
                                        'descending'
-                               )
-                       ),
-               );
+                               ]
+                       ],
+               ];
        }
 
        protected function getExamplesMessages() {
-               return array(
+               return [
                        'action=query&list=iwbacklinks&iwbltitle=Test&iwblprefix=wikibooks'
                                => 'apihelp-query+iwbacklinks-example-simple',
                        'action=query&generator=iwbacklinks&giwbltitle=Test&giwblprefix=wikibooks&prop=info'
                                => 'apihelp-query+iwbacklinks-example-generator',
-               );
+               ];
        }
 
        public function getHelpUrls() {