Test ApiQuerySiteinfo
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index 4b408fc..90435c5 100644 (file)
@@ -54,8 +54,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        $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'] );
@@ -112,7 +111,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        $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
@@ -145,7 +144,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $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();
@@ -229,12 +228,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
                $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' );
@@ -377,13 +370,13 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        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();
@@ -663,13 +656,13 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        $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 );
@@ -790,7 +783,12 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        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' );
 
@@ -835,10 +833,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                return $this->getResult()->addValue( 'query', $property, $config );
        }
 
-       private function formatParserTags( $item ) {
-               return "<{$item}>";
-       }
-
        public function appendSubscribedHooks( $property ) {
                $hooks = $this->getConfig()->get( 'Hooks' );
                $myWgHooks = $hooks;