Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/218658

Change subject: API: Add some BCarray into ApiQuerySiteinfo
......................................................................

API: Add some BCarray into ApiQuerySiteinfo

The main change is that siprop=namespaces will output an array instead
of a numerically-keyed object with formatversion=2.

Various other properties also got the same treatment, but in those cases
the intention was always array and possible non-array output was due to
array_unique or odd indexes in config variables.

Bug: T102645
Change-Id: I486131ac0d6763c3fe40fa45bcee472fe1b46fd6
---
M RELEASE-NOTES-1.26
M includes/api/ApiQuerySiteinfo.php
2 files changed, 16 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/58/218658/1

diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26
index 3cc1d26..db560c6 100644
--- a/RELEASE-NOTES-1.26
+++ b/RELEASE-NOTES-1.26
@@ -41,6 +41,10 @@
   to be set. If they are both set, the value of rootpage= will be ignored.
 * prop=revision output in enum mode is now sorted by timestamp rather than
   revision ID. This usually won't make any difference.
+* (T102645) Namespace list from meta=siteinfo&siprop=namespaces is now an array
+  with formatversion=2.
+* Various other output from meta=siteinfo will now always be arrays instead of
+  sometimes being numerically-indexed objects with formatversion=2.
 
 === Action API internal changes in 1.26 ===
 
diff --git a/includes/api/ApiQuerySiteinfo.php 
b/includes/api/ApiQuerySiteinfo.php
index 1dc9985..a112cf0 100644
--- a/includes/api/ApiQuerySiteinfo.php
+++ b/includes/api/ApiQuerySiteinfo.php
@@ -297,6 +297,7 @@
                        }
                }
 
+               ApiResult::setArrayType( $data, 'BCarray' );
                ApiResult::setIndexedTagName( $data, 'ns' );
 
                return $this->getResult()->addValue( 'query', $property, $data 
);
@@ -511,6 +512,7 @@
                                        $groups = array_intersect( 
$rights[$group], $allGroups );
                                        if ( $groups ) {
                                                $arr[$type] = $groups;
+                                               ApiResult::setArrayType( 
$arr[$type], 'BCarray' );
                                                ApiResult::setIndexedTagName( 
$arr[$type], 'group' );
                                        }
                                }
@@ -682,6 +684,11 @@
                        'semiprotectedlevels' => $config->get( 
'SemiprotectedRestrictionLevels' ),
                );
 
+               ApiResult::setArrayType( $data['types'], 'BCarray' );
+               ApiResult::setArrayType( $data['levels'], 'BCarray' );
+               ApiResult::setArrayType( $data['cascadinglevels'], 'BCarray' );
+               ApiResult::setArrayType( $data['semiprotectedlevels'], 
'BCarray' );
+
                ApiResult::setIndexedTagName( $data['types'], 'type' );
                ApiResult::setIndexedTagName( $data['levels'], 'level' );
                ApiResult::setIndexedTagName( $data['cascadinglevels'], 'level' 
);
@@ -741,6 +748,7 @@
                global $wgParser;
                $wgParser->firstCallInit();
                $tags = array_map( array( $this, 'formatParserTags' ), 
$wgParser->getTags() );
+               ApiResult::setArrayType( $tags, 'BCarray' );
                ApiResult::setIndexedTagName( $tags, 't' );
 
                return $this->getResult()->addValue( 'query', $property, $tags 
);
@@ -750,6 +758,7 @@
                global $wgParser;
                $wgParser->firstCallInit();
                $hooks = $wgParser->getFunctionHooks();
+               ApiResult::setArrayType( $hooks, 'BCarray' );
                ApiResult::setIndexedTagName( $hooks, 'h' );
 
                return $this->getResult()->addValue( 'query', $property, $hooks 
);
@@ -757,6 +766,7 @@
 
        public function appendVariables( $property ) {
                $variables = MagicWord::getVariableIDs();
+               ApiResult::setArrayType( $variables, 'BCarray' );
                ApiResult::setIndexedTagName( $variables, 'v' );
 
                return $this->getResult()->addValue( 'query', $property, 
$variables );
@@ -765,6 +775,7 @@
        public function appendProtocols( $property ) {
                // Make a copy of the global so we don't try to set the 
_element key of it - bug 45130
                $protocols = array_values( $this->getConfig()->get( 
'UrlProtocols' ) );
+               ApiResult::setArrayType( $protocols, 'BCarray' );
                ApiResult::setIndexedTagName( $protocols, 'p' );
 
                return $this->getResult()->addValue( 'query', $property, 
$protocols );
@@ -792,6 +803,7 @@
                                'subscribers' => array_map( array( 
'SpecialVersion', 'arrayToString' ), $subscribers ),
                        );
 
+                       ApiResult::setArrayType( $arr['subscribers'], 'BCarray' 
);
                        ApiResult::setIndexedTagName( $arr['subscribers'], 's' 
);
                        $data[] = $arr;
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/218658
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I486131ac0d6763c3fe40fa45bcee472fe1b46fd6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to