Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/256685
Change subject: Cast numeric cat names back to string in api output
......................................................................
Cast numeric cat names back to string in api output
This could be considered a breaking change even
though it unifies behaviour.
Change-Id: Ib6bc7386f689cc6c2812e9e9406f18b20caa8fee
---
M includes/OutputPage.php
M includes/api/ApiExpandTemplates.php
M includes/api/ApiParse.php
3 files changed, 5 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/85/256685/1
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index c35204d..00143c7 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -1354,6 +1354,8 @@
array( &$this, $categories, &$this->mCategoryLinks ) )
) {
foreach ( $categories as $category => $type ) {
+ // array keys will cast numeric category names
to ints, so cast back to string
+ $category = (string)$category;
$origcategory = $category;
$title = Title::makeTitleSafe( NS_CATEGORY,
$category );
if ( !$title ) {
diff --git a/includes/api/ApiExpandTemplates.php
b/includes/api/ApiExpandTemplates.php
index 8a63070..72adaf8 100644
--- a/includes/api/ApiExpandTemplates.php
+++ b/includes/api/ApiExpandTemplates.php
@@ -115,7 +115,7 @@
foreach ( $categories as
$category => $sortkey ) {
$entry = array();
$entry['sortkey'] =
$sortkey;
-
ApiResult::setContentValue( $entry, 'category', $category );
+
ApiResult::setContentValue( $entry, 'category', (string)$category );
$categories_result[] =
$entry;
}
ApiResult::setIndexedTagName(
$categories_result, 'category' );
diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index 9de5a02..5754c23 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -634,7 +634,8 @@
foreach ( $links as $link => $sortkey ) {
$entry = array();
$entry['sortkey'] = $sortkey;
- ApiResult::setContentValue( $entry, 'category', $link );
+ // array keys will cast numeric category names to ints,
so cast back to string
+ ApiResult::setContentValue( $entry, 'category',
(string)$link );
if ( !isset( $hiddencats[$link] ) ) {
$entry['missing'] = true;
} elseif ( $hiddencats[$link] ) {
--
To view, visit https://gerrit.wikimedia.org/r/256685
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib6bc7386f689cc6c2812e9e9406f18b20caa8fee
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits