Merge "Test ApiQuerySiteinfo"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 2 Aug 2018 02:44:38 +0000 (02:44 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 2 Aug 2018 02:44:38 +0000 (02:44 +0000)
1  2 
includes/api/ApiQuerySiteinfo.php

@@@ -54,8 -54,7 +54,7 @@@ class ApiQuerySiteinfo extends ApiQuery
                                        $fit = $this->appendMagicWords( $p );
                                        break;
                                case 'interwikimap':
-                                       $filteriw = $params['filteriw'] ?? false;
-                                       $fit = $this->appendInterwikiMap( $p, $filteriw );
+                                       $fit = $this->appendInterwikiMap( $p, $params['filteriw'] );
                                        break;
                                case 'dbrepllag':
                                        $fit = $this->appendDbReplLagInfo( $p, $params['showalldb'] );
                                        $fit = $this->appendUploadDialog( $p );
                                        break;
                                default:
-                                       ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
+                                       ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" ); // @codeCoverageIgnore
                        }
                        if ( !$fit ) {
                                // Abuse siprop as a query-continue parameter
                $data['phpversion'] = PHP_VERSION;
                $data['phpsapi'] = PHP_SAPI;
                if ( defined( 'HHVM_VERSION' ) ) {
-                       $data['hhvmversion'] = HHVM_VERSION;
+                       $data['hhvmversion'] = HHVM_VERSION; // @codeCoverageIgnore
                }
                $data['dbtype'] = $config->get( 'DBtype' );
                $data['dbversion'] = $this->getDB()->getServerVersion();
  
                $tz = $config->get( 'Localtimezone' );
                $offset = $config->get( 'LocalTZoffset' );
-               if ( is_null( $tz ) ) {
-                       $tz = 'UTC';
-                       $offset = 0;
-               } elseif ( is_null( $offset ) ) {
-                       $offset = 0;
-               }
                $data['timezone'] = $tz;
                $data['timeoffset'] = intval( $offset );
                $data['articlepath'] = $config->get( 'ArticlePath' );
        }
  
        protected function appendInterwikiMap( $property, $filter ) {
-               $local = null;
                if ( $filter === 'local' ) {
                        $local = 1;
                } elseif ( $filter === '!local' ) {
                        $local = 0;
-               } elseif ( $filter ) {
-                       ApiBase::dieDebug( __METHOD__, "Unknown filter=$filter" );
+               } else {
+                       // $filter === null
+                       $local = null;
                }
  
                $params = $this->extractRequestParams();
                        $url = $config->get( 'RightsUrl' );
                }
                $text = $config->get( 'RightsText' );
-               if ( !$text && $title ) {
+               if ( $title && !strlen( $text ) ) {
                        $text = $title->getPrefixedText();
                }
  
                $data = [
-                       'url' => $url ?: '',
-                       'text' => $text ?: ''
+                       'url' => strlen( $url ) ? $url : '',
+                       'text' => strlen( $text ) ? $text : '',
                ];
  
                return $this->getResult()->addValue( 'query', $property, $data );
        public function appendExtensionTags( $property ) {
                global $wgParser;
                $wgParser->firstCallInit();
-               $tags = array_map( [ $this, 'formatParserTags' ], $wgParser->getTags() );
+               $tags = array_map(
+                       function ( $item ) {
+                               return "<$item>";
+                       },
+                       $wgParser->getTags()
+               );
                ApiResult::setArrayType( $tags, 'BCarray' );
                ApiResult::setIndexedTagName( $tags, 't' );
  
        }
  
        public function appendVariables( $property ) {
 -              $variables = MagicWord::getVariableIDs();
 +              $variables = MediaWikiServices::getInstance()->getMagicWordFactory()->getVariableIDs();
                ApiResult::setArrayType( $variables, 'BCarray' );
                ApiResult::setIndexedTagName( $variables, 'v' );
  
                return $this->getResult()->addValue( 'query', $property, $config );
        }
  
-       private function formatParserTags( $item ) {
-               return "<{$item}>";
-       }
        public function appendSubscribedHooks( $property ) {
                $hooks = $this->getConfig()->get( 'Hooks' );
                $myWgHooks = $hooks;