aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--RELEASE-NOTES-1.257
-rw-r--r--includes/api/ApiBlock.php28
-rw-r--r--includes/api/ApiContinuationManager.php2
-rw-r--r--includes/api/ApiEditPage.php4
-rw-r--r--includes/api/ApiExpandTemplates.php21
-rw-r--r--includes/api/ApiImageRotate.php4
-rw-r--r--includes/api/ApiImport.php2
-rw-r--r--includes/api/ApiManageTags.php4
-rw-r--r--includes/api/ApiMove.php22
-rw-r--r--includes/api/ApiOpenSearch.php1
-rw-r--r--includes/api/ApiPageSet.php2
-rw-r--r--includes/api/ApiParamInfo.php16
-rw-r--r--includes/api/ApiParse.php91
-rw-r--r--includes/api/ApiProtect.php2
-rw-r--r--includes/api/ApiPurge.php4
-rw-r--r--includes/api/ApiQuery.php18
-rw-r--r--includes/api/ApiQueryAllCategories.php4
-rw-r--r--includes/api/ApiQueryAllLinks.php4
-rw-r--r--includes/api/ApiQueryAllMessages.php6
-rw-r--r--includes/api/ApiQueryAllUsers.php2
-rw-r--r--includes/api/ApiQueryBacklinks.php4
-rw-r--r--includes/api/ApiQueryBacklinksprop.php4
-rw-r--r--includes/api/ApiQueryBlocks.php32
-rw-r--r--includes/api/ApiQueryCategories.php4
-rw-r--r--includes/api/ApiQueryCategoryInfo.php4
-rw-r--r--includes/api/ApiQueryCategoryMembers.php4
-rw-r--r--includes/api/ApiQueryDeletedrevs.php14
-rw-r--r--includes/api/ApiQueryDuplicateFiles.php6
-rw-r--r--includes/api/ApiQueryExtLinksUsage.php4
-rw-r--r--includes/api/ApiQueryFileRepoInfo.php2
-rw-r--r--includes/api/ApiQueryFilearchive.php8
-rw-r--r--includes/api/ApiQueryIWBacklinks.php2
-rw-r--r--includes/api/ApiQueryImageInfo.php12
-rw-r--r--includes/api/ApiQueryInfo.php18
-rw-r--r--includes/api/ApiQueryLangBacklinks.php2
-rw-r--r--includes/api/ApiQueryLogEvents.php17
-rw-r--r--includes/api/ApiQueryPageProps.php1
-rw-r--r--includes/api/ApiQueryPagesWithProp.php4
-rw-r--r--includes/api/ApiQueryPrefixSearch.php2
-rw-r--r--includes/api/ApiQueryQueryPage.php4
-rw-r--r--includes/api/ApiQueryRecentChanges.php42
-rw-r--r--includes/api/ApiQueryRevisionsBase.php28
-rw-r--r--includes/api/ApiQuerySiteinfo.php79
-rw-r--r--includes/api/ApiQueryTags.php10
-rw-r--r--includes/api/ApiQueryTokens.php4
-rw-r--r--includes/api/ApiQueryUserContributions.php24
-rw-r--r--includes/api/ApiQueryUserInfo.php17
-rw-r--r--includes/api/ApiQueryUsers.php15
-rw-r--r--includes/api/ApiQueryWatchlist.php33
-rw-r--r--includes/api/ApiResult.php6
-rw-r--r--includes/api/ApiSetNotificationTimestamp.php14
-rw-r--r--includes/api/ApiTokens.php4
-rw-r--r--includes/api/ApiWatch.php4
-rw-r--r--tests/phpunit/includes/api/ApiContinuationManagerTest.php2
-rw-r--r--tests/phpunit/includes/api/ApiErrorFormatterTest.php8
-rw-r--r--tests/phpunit/includes/api/ApiResultTest.php50
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatTestBase.php1
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryContinue2Test.php2
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryContinueTest.php16
59 files changed, 345 insertions, 406 deletions
diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25
index 13b01d944683..530a80445cf7 100644
--- a/RELEASE-NOTES-1.25
+++ b/RELEASE-NOTES-1.25
@@ -268,6 +268,9 @@ production.
as comma-separated lists.
* merge events use new-style formatting.
* delete/event and delete/revision events use new-style formatting.
+* The root node and various other nodes will now always be an object in formats
+ such as json that distinguish between arrays and objects.
+ * Except for action=opensearch where the spec requires an array.
=== Action API internal changes in 1.25 ===
* ApiHelp has been rewritten to support i18n and paginated HTML output.
@@ -316,6 +319,10 @@ production.
metadata isn't set.
* (T35235) LogFormatter subclasses are now responsible for formatting log event
parameters for the API.
+* Many modules have changed result data formats. While this shouldn't affect
+ clients not using the experimental formatversion=2015, code using
+ ApiResult::getResultData() and not using ApiResult::transformForBC() may need
+ updating.
* The following methods have been deprecated and may be removed in a future
release:
* ApiBase::getDescription
diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php
index 72aee321185b..26b5f0e56c58 100644
--- a/includes/api/ApiBlock.php
+++ b/includes/api/ApiBlock.php
@@ -113,27 +113,13 @@ class ApiBlock extends ApiBase {
}
$res['reason'] = $params['reason'];
- if ( $params['anononly'] ) {
- $res['anononly'] = '';
- }
- if ( $params['nocreate'] ) {
- $res['nocreate'] = '';
- }
- if ( $params['autoblock'] ) {
- $res['autoblock'] = '';
- }
- if ( $params['noemail'] ) {
- $res['noemail'] = '';
- }
- if ( $params['hidename'] ) {
- $res['hidename'] = '';
- }
- if ( $params['allowusertalk'] ) {
- $res['allowusertalk'] = '';
- }
- if ( $params['watchuser'] ) {
- $res['watchuser'] = '';
- }
+ $res['anononly'] = $params['anononly'];
+ $res['nocreate'] = $params['nocreate'];
+ $res['autoblock'] = $params['autoblock'];
+ $res['noemail'] = $params['noemail'];
+ $res['hidename'] = $params['hidename'];
+ $res['allowusertalk'] = $params['allowusertalk'];
+ $res['watchuser'] = $params['watchuser'];
$this->getResult()->addValue( null, $this->getModuleName(), $res );
}
diff --git a/includes/api/ApiContinuationManager.php b/includes/api/ApiContinuationManager.php
index dea1cf408ef0..354f4e7de101 100644
--- a/includes/api/ApiContinuationManager.php
+++ b/includes/api/ApiContinuationManager.php
@@ -231,7 +231,7 @@ class ApiContinuationManager {
ApiResult::ADD_ON_TOP | ApiResult::NO_SIZE_CHECK );
}
if ( $batchcomplete ) {
- $result->addValue( null, 'batchcomplete', '',
+ $result->addValue( null, 'batchcomplete', true,
ApiResult::ADD_ON_TOP | ApiResult::NO_SIZE_CHECK );
}
}
diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php
index 601c64cd26b4..0dee147d06ff 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -490,7 +490,7 @@ class ApiEditPage extends ApiBase {
$this->dieStatus( $status );
case EditPage::AS_SUCCESS_NEW_ARTICLE:
- $r['new'] = '';
+ $r['new'] = true;
// fall-through
case EditPage::AS_SUCCESS_UPDATE:
@@ -500,7 +500,7 @@ class ApiEditPage extends ApiBase {
$r['contentmodel'] = $titleObj->getContentModel();
$newRevId = $articleObject->getLatest();
if ( $newRevId == $oldRevId ) {
- $r['nochange'] = '';
+ $r['nochange'] = true;
} else {
$r['oldrevid'] = intval( $oldRevId );
$r['newrevid'] = intval( $newRevId );
diff --git a/includes/api/ApiExpandTemplates.php b/includes/api/ApiExpandTemplates.php
index 5c7717f9192c..6d064eb230f6 100644
--- a/includes/api/ApiExpandTemplates.php
+++ b/includes/api/ApiExpandTemplates.php
@@ -96,9 +96,8 @@ class ApiExpandTemplates extends ApiBase {
$retval['parsetree'] = $xml;
} else {
// the old way
- $xml_result = array();
- ApiResult::setContentValue( $xml_result, 'xml', $xml );
- $result->addValue( null, 'parsetree', $xml_result );
+ $result->addValue( null, 'parsetree', $xml );
+ $result->addValue( null, ApiResult::META_BC_SUBELEMENTS, array( 'parsetree' ) );
}
}
@@ -129,19 +128,13 @@ class ApiExpandTemplates extends ApiBase {
if ( isset( $prop['properties'] ) ) {
$properties = $wgParser->getOutput()->getProperties();
if ( $properties ) {
- $properties_result = array();
- foreach ( $properties as $name => $value ) {
- $entry = array();
- $entry['name'] = $name;
- ApiResult::setContentValue( $entry, 'value', $value );
- $properties_result[] = $entry;
- }
- ApiResult::setIndexedTagName( $properties_result, 'property' );
- $retval['properties'] = $properties_result;
+ ApiResult::setArrayType( $properties, 'BCkvp', 'name' );
+ ApiResult::setIndexedTagName( $properties, 'property' );
+ $retval['properties'] = $properties;
}
}
- if ( isset( $prop['volatile'] ) && $frame->isVolatile() ) {
- $retval['volatile'] = '';
+ if ( isset( $prop['volatile'] ) ) {
+ $retval['volatile'] = $frame->isVolatile();
}
if ( isset( $prop['ttl'] ) && $frame->getTTL() !== null ) {
$retval['ttl'] = $frame->getTTL();
diff --git a/includes/api/ApiImageRotate.php b/includes/api/ApiImageRotate.php
index 7b99921de7dd..865d39fafe47 100644
--- a/includes/api/ApiImageRotate.php
+++ b/includes/api/ApiImageRotate.php
@@ -42,7 +42,7 @@ class ApiImageRotate extends ApiBase {
$v = $val;
}
if ( $flag !== null ) {
- $v[$flag] = '';
+ $v[$flag] = true;
}
$result[] = $v;
}
@@ -71,7 +71,7 @@ class ApiImageRotate extends ApiBase {
$r['id'] = $title->getArticleID();
ApiQueryBase::addTitleInfo( $r, $title );
if ( !$title->exists() ) {
- $r['missing'] = '';
+ $r['missing'] = true;
}
$file = wfFindFile( $title, array( 'latest' => true ) );
diff --git a/includes/api/ApiImport.php b/includes/api/ApiImport.php
index 9d76a46176a3..2e87d22da06d 100644
--- a/includes/api/ApiImport.php
+++ b/includes/api/ApiImport.php
@@ -155,7 +155,7 @@ class ApiImportReporter extends ImportReporter {
if ( $title === null ) {
# Invalid or non-importable title
$r['title'] = $pageInfo['title'];
- $r['invalid'] = '';
+ $r['invalid'] = true;
} else {
ApiQueryBase::addTitleInfo( $r, $title );
$r['revisions'] = intval( $successCount );
diff --git a/includes/api/ApiManageTags.php b/includes/api/ApiManageTags.php
index 80317d3576e3..240d35062af7 100644
--- a/includes/api/ApiManageTags.php
+++ b/includes/api/ApiManageTags.php
@@ -49,8 +49,8 @@ class ApiManageTags extends ApiBase {
if ( !$status->isGood() ) {
$ret['warnings'] = $this->getErrorFormatter()->arrayFromStatus( $status, 'warning' );
}
- if ( $status->value !== null ) {
- $ret['success'] = '';
+ $ret['success'] = $status->value !== null;
+ if ( $ret['success'] ) {
$ret['logid'] = $status->value;
}
$result->addValue( null, $this->getModuleName(), $ret );
diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php
index 0db18e7168e6..e42958bf5aad 100644
--- a/includes/api/ApiMove.php
+++ b/includes/api/ApiMove.php
@@ -83,18 +83,14 @@ class ApiMove extends ApiBase {
'reason' => $params['reason']
);
- if ( $fromTitle->exists() ) {
- //NOTE: we assume that if the old title exists, it's because it was re-created as
- // a redirect to the new title. This is not safe, but what we did before was
- // even worse: we just determined whether a redirect should have been created,
- // and reported that it was created if it should have, without any checks.
- // Also note that isRedirect() is unreliable because of bug 37209.
- $r['redirectcreated'] = '';
- }
+ //NOTE: we assume that if the old title exists, it's because it was re-created as
+ // a redirect to the new title. This is not safe, but what we did before was
+ // even worse: we just determined whether a redirect should have been created,
+ // and reported that it was created if it should have, without any checks.
+ // Also note that isRedirect() is unreliable because of bug 37209.
+ $r['redirectcreated'] = $fromTitle->exists();
- if ( $toTitleExists ) {
- $r['moveoverredirect'] = '';
- }
+ $r['moveoverredirect'] = $toTitleExists;
// Move the talk page
if ( $params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
@@ -103,9 +99,7 @@ class ApiMove extends ApiBase {
if ( $status->isOK() ) {
$r['talkfrom'] = $fromTalk->getPrefixedText();
$r['talkto'] = $toTalk->getPrefixedText();
- if ( $toTalkExists ) {
- $r['talkmoveoverredirect'] = '';
- }
+ $r['talkmoveoverredirect'] = $toTalkExists;
} else {
// We're not gonna dieUsage() on failure, since we already changed something
$error = $this->getErrorFromStatus( $status );
diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php
index 33790f9285b0..8c03dceeff4c 100644
--- a/includes/api/ApiOpenSearch.php
+++ b/includes/api/ApiOpenSearch.php
@@ -212,6 +212,7 @@ class ApiOpenSearch extends ApiBase {
switch ( $this->getFormat() ) {
case 'json':
// http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions/1.1
+ $result->addArrayType( null, 'array' );
$result->addValue( null, 0, strval( $search ) );
$terms = array();
$descriptions = array();
diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php
index 02a25fe82f31..e6f218d62b4a 100644
--- a/includes/api/ApiPageSet.php
+++ b/includes/api/ApiPageSet.php
@@ -96,7 +96,7 @@ class ApiPageSet extends ApiBase {
$v = $val;
}
if ( $flag !== null ) {
- $v[$flag] = '';
+ $v[$flag] = true;
}
$result[] = $v;
}
diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php
index bb661b213986..25069d9db734 100644
--- a/includes/api/ApiParamInfo.php
+++ b/includes/api/ApiParamInfo.php
@@ -216,7 +216,7 @@ class ApiParamInfo extends ApiBase {
$this->formatHelpMessages( $ret, 'description', $module->getFinalDescription() );
foreach ( $module->getHelpFlags() as $flag ) {
- $ret[$flag] = '';
+ $ret[$flag] = true;
}
$ret['helpurls'] = (array)$module->getHelpUrls();
@@ -265,12 +265,10 @@ class ApiParamInfo extends ApiBase {
$this->formatHelpMessages( $item, 'description', $paramDesc[$name], true );
}
- if ( !empty( $settings[ApiBase::PARAM_REQUIRED] ) ) {
- $item['required'] = '';
- }
+ $item['required'] = !empty( $settings[ApiBase::PARAM_REQUIRED] );
if ( !empty( $settings[ApiBase::PARAM_DEPRECATED] ) ) {
- $item['deprecated'] = '';
+ $item['deprecated'] = true;
}
if ( $name === 'token' && $module->needsToken() ) {
@@ -307,8 +305,8 @@ class ApiParamInfo extends ApiBase {
}
}
- if ( !empty( $settings[ApiBase::PARAM_ISMULTI] ) ) {
- $item['multi'] = '';
+ $item['multi'] = !empty( $settings[ApiBase::PARAM_ISMULTI] );
+ if ( $item['multi'] ) {
$item['limit'] = $this->getMain()->canApiHighLimits() ?
ApiBase::LIMIT_SML2 :
ApiBase::LIMIT_SML1;
@@ -317,14 +315,14 @@ class ApiParamInfo extends ApiBase {
}
if ( !empty( $settings[ApiBase::PARAM_ALLOW_DUPLICATES] ) ) {
- $item['allowsduplicates'] = '';
+ $item['allowsduplicates'] = true;
}
if ( isset( $settings[ApiBase::PARAM_TYPE] ) ) {
if ( $settings[ApiBase::PARAM_TYPE] === 'submodule' ) {
$item['type'] = $module->getModuleManager()->getNames( $name );
sort( $item['type'] );
- $item['submodules'] = '';
+ $item['submodules'] = true;
} else {
$item['type'] = $settings[ApiBase::PARAM_TYPE];
}
diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index 267bced7664a..fc004cfdbed7 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -225,21 +225,17 @@ class ApiParse extends ApiBase {
if ( $params['onlypst'] ) {
// Build a result and bail out
$result_array = array();
- $result_array['text'] = array();
- ApiResult::setContentValue( $result_array['text'], 'text', $this->pstContent->serialize( $format ) );
+ $result_array['text'] = $this->pstContent->serialize( $format );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
if ( isset( $prop['wikitext'] ) ) {
- $result_array['wikitext'] = array();
- ApiResult::setContentValue( $result_array['wikitext'], 'wikitext', $this->content->serialize( $format ) );
+ $result_array['wikitext'] = $this->content->serialize( $format );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'wikitext';
}
if ( !is_null( $params['summary'] ) ||
( !is_null( $params['sectiontitle'] ) && $this->section === 'new' )
) {
- $result_array['parsedsummary'] = array();
- ApiResult::setContentValue(
- $result_array['parsedsummary'],
- 'parsedsummary',
- $this->formatSummary( $titleObj, $params )
- );
+ $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsedsummary';
}
$result->addValue( null, $this->getModuleName(), $result_array );
@@ -272,19 +268,15 @@ class ApiParse extends ApiBase {
}
if ( isset( $prop['text'] ) ) {
- $result_array['text'] = array();
- ApiResult::setContentValue( $result_array['text'], 'text', $p_result->getText() );
+ $result_array['text'] = $p_result->getText();
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
}
if ( !is_null( $params['summary'] ) ||
( !is_null( $params['sectiontitle'] ) && $this->section === 'new' )
) {
- $result_array['parsedsummary'] = array();
- ApiResult::setContentValue(
- $result_array['parsedsummary'],
- 'parsedsummary',
- $this->formatSummary( $titleObj, $params )
- );
+ $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsedsummary';
}
if ( isset( $prop['langlinks'] ) ) {
@@ -307,9 +299,8 @@ class ApiParse extends ApiBase {
$result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
}
if ( isset( $prop['categorieshtml'] ) ) {
- $categoriesHtml = $this->categoriesHtml( $p_result->getCategories() );
- $result_array['categorieshtml'] = array();
- ApiResult::setContentValue( $result_array['categorieshtml'], 'categorieshtml', $categoriesHtml );
+ $result_array['categorieshtml'] = $this->categoriesHtml( $p_result->getCategories() );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'categorieshtml';
}
if ( isset( $prop['links'] ) ) {
$result_array['links'] = $this->formatLinks( $p_result->getLinks() );
@@ -349,12 +340,8 @@ class ApiParse extends ApiBase {
}
if ( isset( $prop['headhtml'] ) ) {
- $result_array['headhtml'] = array();
- ApiResult::setContentValue(
- $result_array['headhtml'],
- 'headhtml',
- $context->getOutput()->headElement( $context->getSkin() )
- );
+ $result_array['headhtml'] = $context->getOutput()->headElement( $context->getSkin() );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
}
}
@@ -366,11 +353,8 @@ class ApiParse extends ApiBase {
}
if ( isset( $prop['indicators'] ) ) {
- foreach ( $p_result->getIndicators() as $name => $content ) {
- $indicator = array( 'name' => $name );
- ApiResult::setContentValue( $indicator, 'content', $content );
- $result_array['indicators'][] = $indicator;
- }
+ $result_array['indicators'] = (array)$p_result->getIndicators();
+ ApiResult::setArrayType( $result_array['indicators'], 'BCkvp', 'name' );
}
if ( isset( $prop['iwlinks'] ) ) {
@@ -378,15 +362,16 @@ class ApiParse extends ApiBase {
}
if ( isset( $prop['wikitext'] ) ) {
- $result_array['wikitext'] = array();
- ApiResult::setContentValue( $result_array['wikitext'], 'wikitext', $this->content->serialize( $format ) );
+ $result_array['wikitext'] = $this->content->serialize( $format );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'wikitext';
if ( !is_null( $this->pstContent ) ) {
- $result_array['psttext'] = array();
- ApiResult::setContentValue( $result_array['psttext'], 'psttext', $this->pstContent->serialize( $format ) );
+ $result_array['psttext'] = $this->pstContent->serialize( $format );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'psttext';
}
}
if ( isset( $prop['properties'] ) ) {
- $result_array['properties'] = $this->formatProperties( $p_result->getProperties() );
+ $result_array['properties'] = (array)$p_result->getProperties();
+ ApiResult::setArrayType( $result_array['properties'], 'BCkvp', 'name' );
}
if ( isset( $prop['limitreportdata'] ) ) {
@@ -394,9 +379,8 @@ class ApiParse extends ApiBase {
$this->formatLimitReportData( $p_result->getLimitReportData() );
}
if ( isset( $prop['limitreporthtml'] ) ) {
- $limitreportHtml = EditPage::getPreviewLimitReport( $p_result );
- $result_array['limitreporthtml'] = array();
- ApiResult::setContentValue( $result_array['limitreporthtml'], 'limitreporthtml', $limitreportHtml );
+ $result_array['limitreporthtml'] = EditPage::getPreviewLimitReport( $p_result );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'limitreporthtml';
}
if ( $params['generatexml'] ) {
@@ -411,8 +395,8 @@ class ApiParse extends ApiBase {
} else {
$xml = $dom->__toString();
}
- $result_array['parsetree'] = array();
- ApiResult::setContentValue( $result_array['parsetree'], 'parsetree', $xml );
+ $result_array['parsetree'] = $xml;
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree';
}
$result_mapping = array(
@@ -589,9 +573,9 @@ class ApiParse extends ApiBase {
$entry['sortkey'] = $sortkey;
ApiResult::setContentValue( $entry, 'category', $link );
if ( !isset( $hiddencats[$link] ) ) {
- $entry['missing'] = '';
+ $entry['missing'] = true;
} elseif ( $hiddencats[$link] ) {
- $entry['hidden'] = '';
+ $entry['hidden'] = true;
}
$result[] = $entry;
}
@@ -613,9 +597,7 @@ class ApiParse extends ApiBase {
$entry = array();
$entry['ns'] = $ns;
ApiResult::setContentValue( $entry, 'title', Title::makeTitle( $ns, $title )->getFullText() );
- if ( $id != 0 ) {
- $entry['exists'] = '';
- }
+ $entry['exists'] = $id != 0;
$result[] = $entry;
}
}
@@ -655,18 +637,6 @@ class ApiParse extends ApiBase {
return $result;
}
- private function formatProperties( $properties ) {
- $result = array();
- foreach ( $properties as $name => $value ) {
- $entry = array();
- $entry['name'] = $name;
- ApiResult::setContentValue( $entry, 'value', $value );
- $result[] = $entry;
- }
-
- return $result;
- }
-
private function formatCss( $css ) {
$result = array();
foreach ( $css as $file => $link ) {
@@ -689,8 +659,7 @@ class ApiParse extends ApiBase {
if ( !is_array( $value ) ) {
$value = array( $value );
}
- ApiResult::setIndexedTagName( $value, 'param' );
- ApiResult::setIndexedTagNameOnSubarrays( $value, 'param' );
+ ApiResult::setIndexedTagNameRecursive( $value, 'param' );
$entry = array_merge( $entry, $value );
$result[] = $entry;
}
diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php
index 496db8fec789..c07aaca43602 100644
--- a/includes/api/ApiProtect.php
+++ b/includes/api/ApiProtect.php
@@ -123,7 +123,7 @@ class ApiProtect extends ApiBase {
'reason' => $params['reason']
);
if ( $cascade ) {
- $res['cascade'] = '';
+ $res['cascade'] = true;
}
$res['protections'] = $resultProtections;
$result = $this->getResult();
diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php
index 67f78349f4fd..a22be498c5e2 100644
--- a/includes/api/ApiPurge.php
+++ b/includes/api/ApiPurge.php
@@ -53,7 +53,7 @@ class ApiPurge extends ApiBase {
ApiQueryBase::addTitleInfo( $r, $title );
$page = WikiPage::factory( $title );
$page->doPurge(); // Directly purge and skip the UI part of purge().
- $r['purged'] = '';
+ $r['purged'] = true;
if ( $forceLinkUpdate || $forceRecursiveLinkUpdate ) {
if ( !$this->getUser()->pingLimiter( 'linkpurge' ) ) {
@@ -74,7 +74,7 @@ class ApiPurge extends ApiBase {
$title, null, $forceRecursiveLinkUpdate, $p_result );
DataUpdate::runUpdates( $updates );
- $r['linkupdate'] = '';
+ $r['linkupdate'] = true;
if ( $enableParserCache ) {
$pcache = ParserCache::singleton();
diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php
index b1069c736bcf..082fccb670a8 100644
--- a/includes/api/ApiQuery.php
+++ b/includes/api/ApiQuery.php
@@ -403,18 +403,18 @@ class ApiQuery extends ApiBase {
foreach ( $pageSet->getMissingTitles() as $fakeId => $title ) {
$vals = array();
ApiQueryBase::addTitleInfo( $vals, $title );
- $vals['missing'] = '';
+ $vals['missing'] = true;
$pages[$fakeId] = $vals;
}
// Report any invalid titles
foreach ( $pageSet->getInvalidTitles() as $fakeId => $title ) {
- $pages[$fakeId] = array( 'title' => $title, 'invalid' => '' );
+ $pages[$fakeId] = array( 'title' => $title, 'invalid' => true );
}
// Report any missing page ids
foreach ( $pageSet->getMissingPageIDs() as $pageid ) {
$pages[$pageid] = array(
'pageid' => $pageid,
- 'missing' => ''
+ 'missing' => true
);
}
// Report special pages
@@ -422,15 +422,15 @@ class ApiQuery extends ApiBase {
foreach ( $pageSet->getSpecialTitles() as $fakeId => $title ) {
$vals = array();
ApiQueryBase::addTitleInfo( $vals, $title );
- $vals['special'] = '';
+ $vals['special'] = true;
if ( $title->isSpecialPage() &&
!SpecialPageFactory::exists( $title->getDBkey() )
) {
- $vals['missing'] = '';
+ $vals['missing'] = true;
} elseif ( $title->getNamespace() == NS_MEDIA &&
!wfFindFile( $title )
) {
- $vals['missing'] = '';
+ $vals['missing'] = true;
}
$pages[$fakeId] = $vals;
}
@@ -445,6 +445,7 @@ class ApiQuery extends ApiBase {
if ( count( $pages ) ) {
$pageSet->populateGeneratorData( $pages );
+ ApiResult::setArrayType( $pages, 'BCarray' );
if ( $this->mParams['indexpageids'] ) {
$pageIDs = array_keys( $pages );
@@ -525,9 +526,8 @@ class ApiQuery extends ApiBase {
$result->addValue( null, 'text', $exportxml, ApiResult::NO_SIZE_CHECK );
$result->addValue( null, 'mime', 'text/xml', ApiResult::NO_SIZE_CHECK );
} else {
- $r = array();
- ApiResult::setContentValue( $r, 'xml', $exportxml );
- $result->addValue( 'query', 'export', $r, ApiResult::NO_SIZE_CHECK );
+ $result->addValue( 'query', 'export', $exportxml, ApiResult::NO_SIZE_CHECK );
+ $result->addValue( 'query', ApiResult::META_BC_SUBELEMENTS, array( 'export' ) );
}
}
diff --git a/includes/api/ApiQueryAllCategories.php b/includes/api/ApiQueryAllCategories.php
index 4ecc4b7af5f8..cc0b71afbc7b 100644
--- a/includes/api/ApiQueryAllCategories.php
+++ b/includes/api/ApiQueryAllCategories.php
@@ -135,8 +135,8 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
$item['files'] = intval( $row->cat_files );
$item['subcats'] = intval( $row->cat_subcats );
}
- if ( isset( $prop['hidden'] ) && $row->cat_hidden ) {
- $item['hidden'] = '';
+ if ( isset( $prop['hidden'] ) ) {
+ $item['hidden'] = (bool)$row->cat_hidden;
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $item );
if ( !$fit ) {
diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php
index 1a4a4d904137..fadecfb47e27 100644
--- a/includes/api/ApiQueryAllLinks.php
+++ b/includes/api/ApiQueryAllLinks.php
@@ -200,7 +200,9 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
}
if ( is_null( $resultPageSet ) ) {
- $vals = array();
+ $vals = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
if ( $fld_ids ) {
$vals['fromid'] = intval( $row->pl_from );
}
diff --git a/includes/api/ApiQueryAllMessages.php b/includes/api/ApiQueryAllMessages.php
index 00816a32686e..44af83d03eda 100644
--- a/includes/api/ApiQueryAllMessages.php
+++ b/includes/api/ApiQueryAllMessages.php
@@ -146,7 +146,7 @@ class ApiQueryAllMessages extends ApiQueryBase {
$messageIsCustomised = isset( $customisedMessages['pages'][$langObj->ucfirst( $message )] );
if ( $customised === $messageIsCustomised ) {
if ( $customised ) {
- $a['customised'] = '';
+ $a['customised'] = true;
}
} else {
continue;
@@ -156,7 +156,7 @@ class ApiQueryAllMessages extends ApiQueryBase {
$msg = wfMessage( $message, $args )->inLanguage( $langObj );
if ( !$msg->exists() ) {
- $a['missing'] = '';
+ $a['missing'] = true;
} else {
// Check if the parser is enabled:
if ( $params['enableparser'] ) {
@@ -170,7 +170,7 @@ class ApiQueryAllMessages extends ApiQueryBase {
if ( isset( $prop['default'] ) ) {
$default = wfMessage( $message )->inLanguage( $langObj )->useDatabase( false );
if ( !$default->exists() ) {
- $a['defaultmissing'] = '';
+ $a['defaultmissing'] = true;
} elseif ( $default->plain() != $msgString ) {
$a['default'] = $default->plain();
}
diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php
index 8c9e1baa81a9..d7354e266030 100644
--- a/includes/api/ApiQueryAllUsers.php
+++ b/includes/api/ApiQueryAllUsers.php
@@ -253,7 +253,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
$data['blockexpiry'] = $row->ipb_expiry;
}
if ( $row->ipb_deleted ) {
- $data['hidden'] = '';
+ $data['hidden'] = true;
}
if ( $fld_editcount ) {
$data['editcount'] = intval( $row->user_editcount );
diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php
index 92cf62df8658..1df14e0b8aec 100644
--- a/includes/api/ApiQueryBacklinks.php
+++ b/includes/api/ApiQueryBacklinks.php
@@ -194,7 +194,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
$a = array( 'pageid' => intval( $row->page_id ) );
ApiQueryBase::addTitleInfo( $a, $t );
if ( $row->page_is_redirect ) {
- $a['redirect'] = '';
+ $a['redirect'] = true;
}
// Put all the results in an array first
$this->resultArr[$a['pageid']] = $a;
@@ -313,7 +313,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
$a['pageid'] = intval( $row->page_id );
ApiQueryBase::addTitleInfo( $a, Title::makeTitle( $row->page_namespace, $row->page_title ) );
if ( $row->page_is_redirect ) {
- $a['redirect'] = '';
+ $a['redirect'] = true;
}
$parentID = $this->pageMap[$ns][$row->{$this->bl_title}];
// Put all the results in an array first
diff --git a/includes/api/ApiQueryBacklinksprop.php b/includes/api/ApiQueryBacklinksprop.php
index b4752ae9d4b7..8e271e7b9a68 100644
--- a/includes/api/ApiQueryBacklinksprop.php
+++ b/includes/api/ApiQueryBacklinksprop.php
@@ -287,8 +287,8 @@ class ApiQueryBacklinksprop extends ApiQueryGeneratorBase {
if ( $fld_fragment && $row->rd_fragment !== null && $row->rd_fragment !== '' ) {
$vals['fragment'] = $row->rd_fragment;
}
- if ( $fld_redirect && $row->page_is_redirect ) {
- $vals['redirect'] = '';
+ if ( $fld_redirect ) {
+ $vals['redirect'] = (bool)$row->page_is_redirect;
}
$fit = $this->addPageSubItem( $id, $vals );
if ( !$fit ) {
diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php
index 72e4fefb856e..4a7023b76378 100644
--- a/includes/api/ApiQueryBlocks.php
+++ b/includes/api/ApiQueryBlocks.php
@@ -187,7 +187,9 @@ class ApiQueryBlocks extends ApiQueryBase {
$this->setContinueEnumParameter( 'continue', "$row->ipb_timestamp|$row->ipb_id" );
break;
}
- $block = array();
+ $block = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
if ( $fld_id ) {
$block['id'] = $row->ipb_id;
}
@@ -218,27 +220,13 @@ class ApiQueryBlocks extends ApiQueryBase {
}
if ( $fld_flags ) {
// For clarity, these flags use the same names as their action=block counterparts
- if ( $row->ipb_auto ) {
- $block['automatic'] = '';
- }
- if ( $row->ipb_anon_only ) {
- $block['anononly'] = '';
- }
- if ( $row->ipb_create_account ) {
- $block['nocreate'] = '';
- }
- if ( $row->ipb_enable_autoblock ) {
- $block['autoblock'] = '';
- }
- if ( $row->ipb_block_email ) {
- $block['noemail'] = '';
- }
- if ( $row->ipb_deleted ) {
- $block['hidden'] = '';
- }
- if ( $row->ipb_allow_usertalk ) {
- $block['allowusertalk'] = '';
- }
+ $block['automatic'] = (bool)$row->ipb_auto;
+ $block['anononly'] = (bool)$row->ipb_anon_only;
+ $block['nocreate'] = (bool)$row->ipb_create_account;
+ $block['autoblock'] = (bool)$row->ipb_enable_autoblock;
+ $block['noemail'] = (bool)$row->ipb_block_email;
+ $block['hidden'] = (bool)$row->ipb_deleted;
+ $block['allowusertalk'] = (bool)$row->ipb_allow_usertalk;
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $block );
if ( !$fit ) {
diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php
index 6aa714e7473d..35fa56efd1de 100644
--- a/includes/api/ApiQueryCategories.php
+++ b/includes/api/ApiQueryCategories.php
@@ -150,8 +150,8 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
if ( isset( $prop['timestamp'] ) ) {
$vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp );
}
- if ( isset( $prop['hidden'] ) && !is_null( $row->pp_propname ) ) {
- $vals['hidden'] = '';
+ if ( isset( $prop['hidden'] ) ) {
+ $vals['hidden'] = !is_null( $row->pp_propname );
}
$fit = $this->addPageSubItem( $row->cl_from, $vals );
diff --git a/includes/api/ApiQueryCategoryInfo.php b/includes/api/ApiQueryCategoryInfo.php
index 5c67ebf279aa..9f6c604496ed 100644
--- a/includes/api/ApiQueryCategoryInfo.php
+++ b/includes/api/ApiQueryCategoryInfo.php
@@ -86,9 +86,7 @@ class ApiQueryCategoryInfo extends ApiQueryBase {
$vals['pages'] = $row->cat_pages - $row->cat_subcats - $row->cat_files;
$vals['files'] = intval( $row->cat_files );
$vals['subcats'] = intval( $row->cat_subcats );
- if ( $row->cat_hidden ) {
- $vals['hidden'] = '';
- }
+ $vals['hidden'] = (bool)$row->cat_hidden;
$fit = $this->addPageSubItems( $catids[$row->cat_title], $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $row->cat_title );
diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php
index 82ab93983210..ec0c1d146bb0 100644
--- a/includes/api/ApiQueryCategoryMembers.php
+++ b/includes/api/ApiQueryCategoryMembers.php
@@ -246,7 +246,9 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
}
if ( is_null( $resultPageSet ) ) {
- $vals = array();
+ $vals = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
if ( $fld_ids ) {
$vals['pageid'] = intval( $row->page_id );
}
diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php
index b2c59d8d22a6..72a331f1cc4c 100644
--- a/includes/api/ApiQueryDeletedrevs.php
+++ b/includes/api/ApiQueryDeletedrevs.php
@@ -320,7 +320,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
}
if ( $fld_user || $fld_userid ) {
if ( $row->ar_deleted & Revision::DELETED_USER ) {
- $rev['userhidden'] = '';
+ $rev['userhidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_USER, $user ) ) {
@@ -335,7 +335,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
if ( $fld_comment || $fld_parsedcomment ) {
if ( $row->ar_deleted & Revision::DELETED_COMMENT ) {
- $rev['commenthidden'] = '';
+ $rev['commenthidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_COMMENT, $user ) ) {
@@ -349,15 +349,15 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
}
}
- if ( $fld_minor && $row->ar_minor_edit == 1 ) {
- $rev['minor'] = '';
+ if ( $fld_minor ) {
+ $rev['minor'] = $row->ar_minor_edit == 1;
}
if ( $fld_len ) {
$rev['len'] = $row->ar_len;
}
if ( $fld_sha1 ) {
if ( $row->ar_deleted & Revision::DELETED_TEXT ) {
- $rev['sha1hidden'] = '';
+ $rev['sha1hidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_TEXT, $user ) ) {
@@ -370,7 +370,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
}
if ( $fld_content ) {
if ( $row->ar_deleted & Revision::DELETED_TEXT ) {
- $rev['texthidden'] = '';
+ $rev['texthidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_TEXT, $user ) ) {
@@ -394,7 +394,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
}
if ( $anyHidden && ( $row->ar_deleted & Revision::DELETED_RESTRICTED ) ) {
- $rev['suppressed'] = '';
+ $rev['suppressed'] = true;
}
if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
diff --git a/includes/api/ApiQueryDuplicateFiles.php b/includes/api/ApiQueryDuplicateFiles.php
index 010f8d59a758..4d0bcfed31c8 100644
--- a/includes/api/ApiQueryDuplicateFiles.php
+++ b/includes/api/ApiQueryDuplicateFiles.php
@@ -137,11 +137,9 @@ class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase {
$r = array(
'name' => $dupName,
'user' => $dupFile->getUser( 'text' ),
- 'timestamp' => wfTimestamp( TS_ISO_8601, $dupFile->getTimestamp() )
+ 'timestamp' => wfTimestamp( TS_ISO_8601, $dupFile->getTimestamp() ),
+ 'shared' => !$dupFile->isLocal(),
);
- if ( !$dupFile->isLocal() ) {
- $r['shared'] = '';
- }
$fit = $this->addPageSubItem( $pageId, $r );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $image . '|' . $dupName );
diff --git a/includes/api/ApiQueryExtLinksUsage.php b/includes/api/ApiQueryExtLinksUsage.php
index a26eff273dd5..3f65a19e8ff8 100644
--- a/includes/api/ApiQueryExtLinksUsage.php
+++ b/includes/api/ApiQueryExtLinksUsage.php
@@ -112,7 +112,9 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
}
if ( is_null( $resultPageSet ) ) {
- $vals = array();
+ $vals = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
if ( $fld_ids ) {
$vals['pageid'] = intval( $row->page_id );
}
diff --git a/includes/api/ApiQueryFileRepoInfo.php b/includes/api/ApiQueryFileRepoInfo.php
index 88961400ae06..9ad7e27e6b96 100644
--- a/includes/api/ApiQueryFileRepoInfo.php
+++ b/includes/api/ApiQueryFileRepoInfo.php
@@ -56,6 +56,8 @@ class ApiQueryFileRepoInfo extends ApiQueryBase {
$result = $this->getResult();
ApiResult::setIndexedTagName( $repos, 'repo' );
+ ApiResult::setArrayTypeRecursive( $repos, 'assoc' );
+ ApiResult::setArrayType( $repos, 'array' );
$result->addValue( array( 'query' ), 'repos', $repos );
}
diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php
index cba3b7353c8a..4d357a7f4cd3 100644
--- a/includes/api/ApiQueryFilearchive.php
+++ b/includes/api/ApiQueryFilearchive.php
@@ -218,17 +218,17 @@ class ApiQueryFilearchive extends ApiQueryBase {
}
if ( $row->fa_deleted & File::DELETED_FILE ) {
- $file['filehidden'] = '';
+ $file['filehidden'] = true;
}
if ( $row->fa_deleted & File::DELETED_COMMENT ) {
- $file['commenthidden'] = '';
+ $file['commenthidden'] = true;
}
if ( $row->fa_deleted & File::DELETED_USER ) {
- $file['userhidden'] = '';
+ $file['userhidden'] = true;
}
if ( $row->fa_deleted & File::DELETED_RESTRICTED ) {
// This file is deleted for normal admins
- $file['suppressed'] = '';
+ $file['suppressed'] = true;
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $file );
diff --git a/includes/api/ApiQueryIWBacklinks.php b/includes/api/ApiQueryIWBacklinks.php
index 61928c3c4226..618387d2b791 100644
--- a/includes/api/ApiQueryIWBacklinks.php
+++ b/includes/api/ApiQueryIWBacklinks.php
@@ -132,7 +132,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
ApiQueryBase::addTitleInfo( $entry, $title );
if ( $row->page_is_redirect ) {
- $entry['redirect'] = '';
+ $entry['redirect'] = true;
}
if ( $iwprefix ) {
diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php
index d5da4951c358..94b4bbdb4853 100644
--- a/includes/api/ApiQueryImageInfo.php
+++ b/includes/api/ApiQueryImageInfo.php
@@ -373,7 +373,9 @@ class ApiQueryImageInfo extends ApiQueryBase {
);
}
$version = $opts['version'];
- $vals = array();
+ $vals = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
// Timestamp is shown even if the file is revdelete'd in interface
// so do same here.
if ( isset( $prop['timestamp'] ) ) {
@@ -397,7 +399,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
if ( $user || $userid ) {
if ( $file->isDeleted( File::DELETED_USER ) ) {
- $vals['userhidden'] = '';
+ $vals['userhidden'] = true;
$anyHidden = true;
}
if ( $canShowField( File::DELETED_USER ) ) {
@@ -408,7 +410,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
$vals['userid'] = $file->getUser( 'id' );
}
if ( !$file->getUser( 'id' ) ) {
- $vals['anon'] = '';
+ $vals['anon'] = true;
}
}
}
@@ -438,7 +440,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
if ( $pcomment || $comment ) {
if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
- $vals['commenthidden'] = '';
+ $vals['commenthidden'] = true;
$anyHidden = true;
}
if ( $canShowField( File::DELETED_COMMENT ) ) {
@@ -469,7 +471,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
}
if ( $file->isDeleted( File::DELETED_FILE ) ) {
- $vals['filehidden'] = '';
+ $vals['filehidden'] = true;
$anyHidden = true;
}
diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php
index db28df746180..66178d4f72bb 100644
--- a/includes/api/ApiQueryInfo.php
+++ b/includes/api/ApiQueryInfo.php
@@ -395,10 +395,10 @@ class ApiQueryInfo extends ApiQueryBase {
$pageInfo['length'] = intval( $this->pageLength[$pageid] );
if ( isset( $this->pageIsRedir[$pageid] ) && $this->pageIsRedir[$pageid] ) {
- $pageInfo['redirect'] = '';
+ $pageInfo['redirect'] = true;
}
if ( $this->pageIsNew[$pageid] ) {
- $pageInfo['new'] = '';
+ $pageInfo['new'] = true;
}
}
@@ -431,8 +431,8 @@ class ApiQueryInfo extends ApiQueryBase {
ApiResult::setIndexedTagName( $pageInfo['restrictiontypes'], 'rt' );
}
- if ( $this->fld_watched && isset( $this->watched[$ns][$dbkey] ) ) {
- $pageInfo['watched'] = '';
+ if ( $this->fld_watched ) {
+ $pageInfo['watched'] = isset( $this->watched[$ns][$dbkey] );
}
if ( $this->fld_watchers ) {
@@ -464,8 +464,8 @@ class ApiQueryInfo extends ApiQueryBase {
$pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_CURRENT );
$pageInfo['canonicalurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CANONICAL );
}
- if ( $this->fld_readable && $title->userCan( 'read', $this->getUser() ) ) {
- $pageInfo['readable'] = '';
+ if ( $this->fld_readable ) {
+ $pageInfo['readable'] = $title->userCan( 'read', $this->getUser() );
}
if ( $this->fld_preload ) {
@@ -497,9 +497,7 @@ class ApiQueryInfo extends ApiQueryBase {
$pageInfo['actions'] = array();
foreach ( $this->params['testactions'] as $action ) {
$this->countTestedActions++;
- if ( $title->userCan( $action, $user ) ) {
- $pageInfo['actions'][$action] = '';
- }
+ $pageInfo['actions'][$action] = $title->userCan( $action, $user );
}
}
@@ -532,7 +530,7 @@ class ApiQueryInfo extends ApiQueryBase {
'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 )
);
if ( $row->pr_cascade ) {
- $a['cascade'] = '';
+ $a['cascade'] = true;
}
$this->protections[$title->getNamespace()][$title->getDBkey()][] = $a;
}
diff --git a/includes/api/ApiQueryLangBacklinks.php b/includes/api/ApiQueryLangBacklinks.php
index 885d10c1414b..7be18b2ff763 100644
--- a/includes/api/ApiQueryLangBacklinks.php
+++ b/includes/api/ApiQueryLangBacklinks.php
@@ -131,7 +131,7 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
ApiQueryBase::addTitleInfo( $entry, $title );
if ( $row->page_is_redirect ) {
- $entry['redirect'] = '';
+ $entry['redirect'] = true;
}
if ( $lllang ) {
diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php
index 553747e548fa..7b2381f4d3f9 100644
--- a/includes/api/ApiQueryLogEvents.php
+++ b/includes/api/ApiQueryLogEvents.php
@@ -230,9 +230,6 @@ class ApiQueryLogEvents extends ApiQueryBase {
}
$vals = $this->extractRowInfo( $row );
- if ( !$vals ) {
- continue;
- }
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', "$row->log_timestamp|$row->log_id" );
@@ -270,7 +267,9 @@ class ApiQueryLogEvents extends ApiQueryBase {
private function extractRowInfo( $row ) {
$logEntry = DatabaseLogEntry::newFromRow( $row );
- $vals = array();
+ $vals = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
$anyHidden = false;
$user = $this->getUser();
@@ -284,7 +283,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
if ( $this->fld_title || $this->fld_ids || $this->fld_details && $row->log_params !== '' ) {
if ( LogEventsList::isDeleted( $row, LogPage::DELETED_ACTION ) ) {
- $vals['actionhidden'] = '';
+ $vals['actionhidden'] = true;
$anyHidden = true;
}
if ( LogEventsList::userCan( $row, LogPage::DELETED_ACTION, $user ) ) {
@@ -308,7 +307,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
if ( $this->fld_user || $this->fld_userid ) {
if ( LogEventsList::isDeleted( $row, LogPage::DELETED_USER ) ) {
- $vals['userhidden'] = '';
+ $vals['userhidden'] = true;
$anyHidden = true;
}
if ( LogEventsList::userCan( $row, LogPage::DELETED_USER, $user ) ) {
@@ -320,7 +319,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
}
if ( !$row->log_user ) {
- $vals['anon'] = '';
+ $vals['anon'] = true;
}
}
}
@@ -330,7 +329,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
if ( ( $this->fld_comment || $this->fld_parsedcomment ) && isset( $row->log_comment ) ) {
if ( LogEventsList::isDeleted( $row, LogPage::DELETED_COMMENT ) ) {
- $vals['commenthidden'] = '';
+ $vals['commenthidden'] = true;
$anyHidden = true;
}
if ( LogEventsList::userCan( $row, LogPage::DELETED_COMMENT, $user ) ) {
@@ -355,7 +354,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
}
if ( $anyHidden && LogEventsList::isDeleted( $row, LogPage::DELETED_RESTRICTED ) ) {
- $vals['suppressed'] = '';
+ $vals['suppressed'] = true;
}
return $vals;
diff --git a/includes/api/ApiQueryPageProps.php b/includes/api/ApiQueryPageProps.php
index 269afb147c7b..dd19bf23cfb3 100644
--- a/includes/api/ApiQueryPageProps.php
+++ b/includes/api/ApiQueryPageProps.php
@@ -110,6 +110,7 @@ class ApiQueryPageProps extends ApiQueryBase {
* @return bool True if it fits in the result
*/
private function addPageProps( $result, $page, $props ) {
+ ApiResult::setArrayType( $props, 'assoc' );
$fit = $result->addValue( array( 'query', 'pages', $page ), 'pageprops', $props );
if ( !$fit ) {
diff --git a/includes/api/ApiQueryPagesWithProp.php b/includes/api/ApiQueryPagesWithProp.php
index 143bc06d860b..7bcaf2472239 100644
--- a/includes/api/ApiQueryPagesWithProp.php
+++ b/includes/api/ApiQueryPagesWithProp.php
@@ -99,7 +99,9 @@ class ApiQueryPagesWithProp extends ApiQueryGeneratorBase {
}
if ( $resultPageSet === null ) {
- $vals = array();
+ $vals = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
if ( $fld_ids ) {
$vals['pageid'] = (int)$row->page_id;
}
diff --git a/includes/api/ApiQueryPrefixSearch.php b/includes/api/ApiQueryPrefixSearch.php
index 35942ca6a5c9..8eb644fcf972 100644
--- a/includes/api/ApiQueryPrefixSearch.php
+++ b/includes/api/ApiQueryPrefixSearch.php
@@ -69,7 +69,7 @@ class ApiQueryPrefixSearch extends ApiQueryGeneratorBase {
'title' => $title->getPrefixedText(),
);
if ( $title->isSpecialPage() ) {
- $vals['special'] = '';
+ $vals['special'] = true;
} else {
$vals['pageid'] = intval( $title->getArticleId() );
}
diff --git a/includes/api/ApiQueryQueryPage.php b/includes/api/ApiQueryQueryPage.php
index 062a44f8e4a0..650ac8fef91d 100644
--- a/includes/api/ApiQueryQueryPage.php
+++ b/includes/api/ApiQueryQueryPage.php
@@ -68,9 +68,9 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase {
$r = array( 'name' => $params['page'] );
if ( $qp->isCached() ) {
if ( !$qp->isCacheable() ) {
- $r['disabled'] = '';
+ $r['disabled'] = true;
} else {
- $r['cached'] = '';
+ $r['cached'] = true;
$ts = $qp->getCachedTimestamp();
if ( $ts ) {
$r['cachedtimestamp'] = wfTimestamp( TS_ISO_8601, $ts );
diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php
index 28f8b7d9af2f..f6a64785c47f 100644
--- a/includes/api/ApiQueryRecentChanges.php
+++ b/includes/api/ApiQueryRecentChanges.php
@@ -384,9 +384,6 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
$vals = $this->extractRowInfo( $row );
/* Add that row's data to our final output. */
- if ( !$vals ) {
- continue;
- }
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" );
@@ -428,7 +425,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
/* Create a new entry in the result for the title. */
if ( $this->fld_title || $this->fld_ids ) {
if ( $type === RC_LOG && ( $row->rc_deleted & LogPage::DELETED_ACTION ) ) {
- $vals['actionhidden'] = '';
+ $vals['actionhidden'] = true;
$anyHidden = true;
}
if ( $type !== RC_LOG ||
@@ -452,7 +449,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
/* Add user data and 'anon' flag, if user is anonymous. */
if ( $this->fld_user || $this->fld_userid ) {
if ( $row->rc_deleted & Revision::DELETED_USER ) {
- $vals['userhidden'] = '';
+ $vals['userhidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_USER, $user ) ) {
@@ -465,22 +462,16 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
}
if ( !$row->rc_user ) {
- $vals['anon'] = '';
+ $vals['anon'] = true;
}
}
}
/* Add flags, such as new, minor, bot. */
if ( $this->fld_flags ) {
- if ( $row->rc_bot ) {
- $vals['bot'] = '';
- }
- if ( $row->rc_type == RC_NEW ) {
- $vals['new'] = '';
- }
- if ( $row->rc_minor ) {
- $vals['minor'] = '';
- }
+ $vals['bot'] = (bool)$row->rc_bot;
+ $vals['new'] = $row->rc_type == RC_NEW;
+ $vals['minor'] = (bool)$row->rc_minor;
}
/* Add sizes of each revision. (Only available on 1.10+) */
@@ -497,7 +488,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
/* Add edit summary / log summary. */
if ( $this->fld_comment || $this->fld_parsedcomment ) {
if ( $row->rc_deleted & Revision::DELETED_COMMENT ) {
- $vals['commenthidden'] = '';
+ $vals['commenthidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_COMMENT, $user ) ) {
@@ -512,23 +503,18 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
}
if ( $this->fld_redirect ) {
- if ( $row->page_is_redirect ) {
- $vals['redirect'] = '';
- }
+ $vals['redirect'] = (bool)$row->page_is_redirect;
}
/* Add the patrolled flag */
- if ( $this->fld_patrolled && $row->rc_patrolled == 1 ) {
- $vals['patrolled'] = '';
- }
-
- if ( $this->fld_patrolled && ChangesList::isUnpatrolled( $row, $user ) ) {
- $vals['unpatrolled'] = '';
+ if ( $this->fld_patrolled ) {
+ $vals['patrolled'] = $row->rc_patrolled == 1;
+ $vals['unpatrolled'] = ChangesList::isUnpatrolled( $row, $user );
}
if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
if ( $row->rc_deleted & LogPage::DELETED_ACTION ) {
- $vals['actionhidden'] = '';
+ $vals['actionhidden'] = true;
$anyHidden = true;
}
if ( LogEventsList::userCanBitfield( $row->rc_deleted, LogPage::DELETED_ACTION, $user ) ) {
@@ -551,7 +537,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
if ( $this->fld_sha1 && $row->rev_sha1 !== null ) {
if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
- $vals['sha1hidden'] = '';
+ $vals['sha1hidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->rev_deleted, Revision::DELETED_TEXT, $user ) ) {
@@ -577,7 +563,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
}
if ( $anyHidden && ( $row->rc_deleted & Revision::DELETED_RESTRICTED ) ) {
- $vals['suppressed'] = '';
+ $vals['suppressed'] = true;
}
return $vals;
diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php
index 1805f40a2295..64f6120ae4a7 100644
--- a/includes/api/ApiQueryRevisionsBase.php
+++ b/includes/api/ApiQueryRevisionsBase.php
@@ -168,13 +168,13 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
}
}
- if ( $this->fld_flags && $revision->isMinor() ) {
- $vals['minor'] = '';
+ if ( $this->fld_flags ) {
+ $vals['minor'] = $revision->isMinor();
}
if ( $this->fld_user || $this->fld_userid ) {
if ( $revision->isDeleted( Revision::DELETED_USER ) ) {
- $vals['userhidden'] = '';
+ $vals['userhidden'] = true;
$anyHidden = true;
}
if ( $revision->userCan( Revision::DELETED_USER, $user ) ) {
@@ -183,7 +183,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
}
$userid = $revision->getUser( Revision::RAW );
if ( !$userid ) {
- $vals['anon'] = '';
+ $vals['anon'] = true;
}
if ( $this->fld_userid ) {
@@ -206,7 +206,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
if ( $this->fld_sha1 ) {
if ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
- $vals['sha1hidden'] = '';
+ $vals['sha1hidden'] = true;
$anyHidden = true;
}
if ( $revision->userCan( Revision::DELETED_TEXT, $user ) ) {
@@ -224,7 +224,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
if ( $this->fld_comment || $this->fld_parsedcomment ) {
if ( $revision->isDeleted( Revision::DELETED_COMMENT ) ) {
- $vals['commenthidden'] = '';
+ $vals['commenthidden'] = true;
$anyHidden = true;
}
if ( $revision->userCan( Revision::DELETED_COMMENT, $user ) ) {
@@ -267,10 +267,10 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
}
}
if ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
- $vals['texthidden'] = '';
+ $vals['texthidden'] = true;
$anyHidden = true;
} elseif ( !$content ) {
- $vals['textmissing'] = '';
+ $vals['textmissing'] = true;
}
}
if ( $this->fld_content && $content ) {
@@ -293,7 +293,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
}
$vals['parsetree'] = $xml;
} else {
- $vals['badcontentformatforparsetree'] = '';
+ $vals['badcontentformatforparsetree'] = true;
$this->setWarning( "Conversion to XML is supported for wikitext only, " .
$title->getPrefixedDBkey() .
" uses content model " . $content->getModel() );
@@ -314,7 +314,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
$this->setWarning( "Template expansion is supported for wikitext only, " .
$title->getPrefixedDBkey() .
" uses content model " . $content->getModel() );
- $vals['badcontentformat'] = '';
+ $vals['badcontentformat'] = true;
$text = false;
}
}
@@ -335,7 +335,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
$name = $title->getPrefixedDBkey();
$this->setWarning( "The requested format {$this->contentFormat} is not " .
"supported for content model $model used by $name" );
- $vals['badcontentformat'] = '';
+ $vals['badcontentformat'] = true;
$text = false;
} else {
$text = $content->serialize( $format );
@@ -369,7 +369,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
$name = $title->getPrefixedDBkey();
$this->setWarning( "The requested format {$this->contentFormat} is not " .
"supported for content model $model used by $name" );
- $vals['diff']['badcontentformat'] = '';
+ $vals['diff']['badcontentformat'] = true;
$engine = null;
} else {
$difftocontent = ContentHandler::makeContent(
@@ -395,12 +395,12 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
}
}
} else {
- $vals['diff']['notcached'] = '';
+ $vals['diff']['notcached'] = true;
}
}
if ( $anyHidden && $revision->isDeleted( Revision::DELETED_RESTRICTED ) ) {
- $vals['suppressed'] = '';
+ $vals['suppressed'] = true;
}
return $vals;
diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php
index 22447f74d20f..b81e993b66d6 100644
--- a/includes/api/ApiQuerySiteinfo.php
+++ b/includes/api/ApiQuerySiteinfo.php
@@ -150,9 +150,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
$allowFrom = array( '' );
$allowException = true;
if ( !$config->get( 'AllowExternalImages' ) ) {
- if ( $config->get( 'EnableImageWhitelist' ) ) {
- $data['imagewhitelistenabled'] = '';
- }
+ $data['imagewhitelistenabled'] = (bool)$config->get( 'EnableImageWhitelist' );
$allowFrom = $config->get( 'AllowExternalImagesFrom' );
$allowException = !empty( $allowFrom );
}
@@ -161,13 +159,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
ApiResult::setIndexedTagName( $data['externalimages'], 'prefix' );
}
- if ( !$config->get( 'DisableLangConversion' ) ) {
- $data['langconversion'] = '';
- }
-
- if ( !$config->get( 'DisableTitleConversion' ) ) {
- $data['titleconversion'] = '';
- }
+ $data['langconversion'] = !$config->get( 'DisableLangConversion' );
+ $data['titleconversion'] = !$config->get( 'DisableTitleConversion' );
if ( $wgContLang->linkPrefixExtension() ) {
$linkPrefixCharset = $wgContLang->linkPrefixCharset();
@@ -180,11 +173,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
$linktrail = $wgContLang->linkTrail();
- if ( $linktrail ) {
- $data['linktrail'] = $linktrail;
- } else {
- $data['linktrail'] = '';
- }
+ $data['linktrail'] = $linktrail ?: '';
$data['legaltitlechars'] = Title::legalChars();
@@ -224,18 +213,14 @@ class ApiQuerySiteinfo extends ApiQueryBase {
ApiResult::setIndexedTagName( $data['variants'], 'lang' );
}
- if ( $wgContLang->isRTL() ) {
- $data['rtl'] = '';
- }
+ $data['rtl'] = $wgContLang->isRTL();
$data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
- if ( wfReadOnly() ) {
- $data['readonly'] = '';
+ $data['readonly'] = wfReadOnly();
+ if ( $data['readonly'] ) {
$data['readonlyreason'] = wfReadOnlyReason();
}
- if ( $config->get( 'EnableWriteAPI' ) ) {
- $data['writeapi'] = '';
- }
+ $data['writeapi'] = (bool)$config->get( 'EnableWriteAPI' );
$tz = $config->get( 'Localtimezone' );
$offset = $config->get( 'LocalTZoffset' );
@@ -251,20 +236,21 @@ class ApiQuerySiteinfo extends ApiQueryBase {
$data['scriptpath'] = $config->get( 'ScriptPath' );
$data['script'] = $config->get( 'Script' );
$data['variantarticlepath'] = $config->get( 'VariantArticlePath' );
+ $data[ApiResult::META_BC_BOOLS][] = 'variantarticlepath';
$data['server'] = $config->get( 'Server' );
$data['servername'] = $config->get( 'ServerName' );
$data['wikiid'] = wfWikiID();
$data['time'] = wfTimestamp( TS_ISO_8601, time() );
- if ( $config->get( 'MiserMode' ) ) {
- $data['misermode'] = '';
- }
+ $data['misermode'] = (bool)$config->get( 'MiserMode' );
$data['maxuploadsize'] = UploadBase::getMaxUploadSize();
$data['thumblimits'] = $config->get( 'ThumbLimits' );
+ ApiResult::setArrayType( $data['thumblimits'], 'BCassoc' );
ApiResult::setIndexedTagName( $data['thumblimits'], 'limit' );
$data['imagelimits'] = array();
+ ApiResult::setArrayType( $data['imagelimits'], 'BCassoc' );
ApiResult::setIndexedTagName( $data['imagelimits'], 'limit' );
foreach ( $config->get( 'ImageLimits' ) as $k => $limit ) {
$data['imagelimits'][$k] = array( 'width' => $limit[0], 'height' => $limit[1] );
@@ -284,7 +270,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
protected function appendNamespaces( $property ) {
global $wgContLang;
- $data = array();
+ $data = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
foreach ( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
$data[$ns] = array(
'id' => intval( $ns ),
@@ -293,21 +281,14 @@ class ApiQuerySiteinfo extends ApiQueryBase {
ApiResult::setContentValue( $data[$ns], 'name', $title );
$canonical = MWNamespace::getCanonicalName( $ns );
- if ( MWNamespace::hasSubpages( $ns ) ) {
- $data[$ns]['subpages'] = '';
- }
+ $data[$ns]['subpages'] = MWNamespace::hasSubpages( $ns );
if ( $canonical ) {
$data[$ns]['canonical'] = strtr( $canonical, '_', ' ' );
}
- if ( MWNamespace::isContent( $ns ) ) {
- $data[$ns]['content'] = '';
- }
-
- if ( MWNamespace::isNonincludable( $ns ) ) {
- $data[$ns]['nonincludable'] = '';
- }
+ $data[$ns]['content'] = MWNamespace::isContent( $ns );
+ $data[$ns]['nonincludable'] = MWNamespace::isNonincludable( $ns );
$contentmodel = MWNamespace::getNamespaceContentModel( $ns );
if ( $contentmodel ) {
@@ -367,9 +348,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
foreach ( $wgContLang->getMagicWords() as $magicword => $aliases ) {
$caseSensitive = array_shift( $aliases );
$arr = array( 'name' => $magicword, 'aliases' => $aliases );
- if ( $caseSensitive ) {
- $arr['case-sensitive'] = '';
- }
+ $arr['case-sensitive'] = (bool)$caseSensitive;
ApiResult::setIndexedTagName( $arr['aliases'], 'alias' );
$data[] = $arr;
}
@@ -402,20 +381,20 @@ class ApiQuerySiteinfo extends ApiQueryBase {
$val = array();
$val['prefix'] = $prefix;
if ( isset( $row['iw_local'] ) && $row['iw_local'] == '1' ) {
- $val['local'] = '';
+ $val['local'] = true;
}
if ( isset( $row['iw_trans'] ) && $row['iw_trans'] == '1' ) {
- $val['trans'] = '';
+ $val['trans'] = true;
}
if ( isset( $langNames[$prefix] ) ) {
$val['language'] = $langNames[$prefix];
}
if ( in_array( $prefix, $localInterwikis ) ) {
- $val['localinterwiki'] = '';
+ $val['localinterwiki'] = true;
}
if ( in_array( $prefix, $extraLangPrefixes ) ) {
- $val['extralanglink'] = '';
+ $val['extralanglink'] = true;
$linktext = wfMessage( "interlanguage-link-$prefix" );
if ( !$linktext->isDisabled() ) {
@@ -429,9 +408,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
$val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT );
- if ( substr( $row['iw_url'], 0, 2 ) == '//' ) {
- $val['protorel'] = '';
- }
+ $val['protorel'] = substr( $row['iw_url'], 0, 2 ) == '//';
if ( isset( $row['iw_wikiid'] ) && $row['iw_wikiid'] !== '' ) {
$val['wikiid'] = $row['iw_wikiid'];
}
@@ -747,10 +724,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
$skin = array( 'code' => $name );
ApiResult::setContentValue( $skin, 'name', $displayName );
if ( !isset( $allowed[$name] ) ) {
- $skin['unusable'] = '';
+ $skin['unusable'] = true;
}
if ( $name === $default ) {
- $skin['default'] = '';
+ $skin['default'] = true;
}
$data[] = $skin;
}
@@ -793,7 +770,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
public function appendDefaultOptions( $property ) {
- return $this->getResult()->addValue( 'query', $property, User::getDefaultOptions() );
+ $options = User::getDefaultOptions();
+ $options[ApiResult::META_BC_BOOLS] = array_keys( $options );
+ return $this->getResult()->addValue( 'query', $property, $options );
}
private function formatParserTags( $item ) {
diff --git a/includes/api/ApiQueryTags.php b/includes/api/ApiQueryTags.php
index aa9121667960..45f73b206a3d 100644
--- a/includes/api/ApiQueryTags.php
+++ b/includes/api/ApiQueryTags.php
@@ -108,8 +108,8 @@ class ApiQueryTags extends ApiQueryBase {
$isExtension = isset( $extensionDefinedTags[$tagName] );
$isExplicit = isset( $explicitlyDefinedTags[$tagName] );
- if ( $fld_defined && ( $isExtension || $isExplicit ) ) {
- $tag['defined'] = '';
+ if ( $fld_defined ) {
+ $tag['defined'] = $isExtension || $isExplicit;
}
if ( $fld_source ) {
@@ -122,10 +122,8 @@ class ApiQueryTags extends ApiQueryBase {
}
}
- if ( $fld_active &&
- ( $isExplicit || isset( $extensionActivatedTags[$tagName] ) )
- ) {
- $tag['active'] = '';
+ if ( $fld_active ) {
+ $tag['active'] = $isExplicit || isset( $extensionActivatedTags[$tagName] );
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $tag );
diff --git a/includes/api/ApiQueryTokens.php b/includes/api/ApiQueryTokens.php
index f8eee8dfcd66..65a08a3b9750 100644
--- a/includes/api/ApiQueryTokens.php
+++ b/includes/api/ApiQueryTokens.php
@@ -35,7 +35,9 @@ class ApiQueryTokens extends ApiQueryBase {
public function execute() {
$params = $this->extractRequestParams();
- $res = array();
+ $res = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
if ( $this->lacksSameOriginSecurity() ) {
$this->setWarning( 'Tokens may not be obtained when the same-origin policy is not applied' );
diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php
index f6c63560f93f..e5ec67d0fd17 100644
--- a/includes/api/ApiQueryUserContributions.php
+++ b/includes/api/ApiQueryUserContributions.php
@@ -335,7 +335,7 @@ class ApiQueryContributions extends ApiQueryBase {
$anyHidden = false;
if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
- $vals['texthidden'] = '';
+ $vals['texthidden'] = true;
$anyHidden = true;
}
@@ -343,7 +343,7 @@ class ApiQueryContributions extends ApiQueryBase {
$vals['userid'] = $row->rev_user;
$vals['user'] = $row->rev_user_text;
if ( $row->rev_deleted & Revision::DELETED_USER ) {
- $vals['userhidden'] = '';
+ $vals['userhidden'] = true;
$anyHidden = true;
}
if ( $this->fld_ids ) {
@@ -367,20 +367,14 @@ class ApiQueryContributions extends ApiQueryBase {
}
if ( $this->fld_flags ) {
- if ( $row->rev_parent_id == 0 && !is_null( $row->rev_parent_id ) ) {
- $vals['new'] = '';
- }
- if ( $row->rev_minor_edit ) {
- $vals['minor'] = '';
- }
- if ( $row->page_latest == $row->rev_id ) {
- $vals['top'] = '';
- }
+ $vals['new'] = $row->rev_parent_id == 0 && !is_null( $row->rev_parent_id );
+ $vals['minor'] = (bool)$row->rev_minor_edit;
+ $vals['top'] = $row->page_latest == $row->rev_id;
}
if ( ( $this->fld_comment || $this->fld_parsedcomment ) && isset( $row->rev_comment ) ) {
if ( $row->rev_deleted & Revision::DELETED_COMMENT ) {
- $vals['commenthidden'] = '';
+ $vals['commenthidden'] = true;
$anyHidden = true;
}
@@ -400,8 +394,8 @@ class ApiQueryContributions extends ApiQueryBase {
}
}
- if ( $this->fld_patrolled && $row->rc_patrolled ) {
- $vals['patrolled'] = '';
+ if ( $this->fld_patrolled ) {
+ $vals['patrolled'] = (bool)$row->rc_patrolled;
}
if ( $this->fld_size && !is_null( $row->rev_len ) ) {
@@ -429,7 +423,7 @@ class ApiQueryContributions extends ApiQueryBase {
}
if ( $anyHidden && $row->rev_deleted & Revision::DELETED_RESTRICTED ) {
- $vals['suppressed'] = '';
+ $vals['suppressed'] = true;
}
return $vals;
diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php
index fd095fcc3cdd..3d3590c54f93 100644
--- a/includes/api/ApiQueryUserInfo.php
+++ b/includes/api/ApiQueryUserInfo.php
@@ -61,7 +61,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
$vals['name'] = $user->getName();
if ( $user->isAnon() ) {
- $vals['anon'] = '';
+ $vals['anon'] = true;
}
if ( isset( $this->prop['blockinfo'] ) ) {
@@ -78,23 +78,26 @@ class ApiQueryUserInfo extends ApiQueryBase {
}
}
- if ( isset( $this->prop['hasmsg'] ) && $user->getNewtalk() ) {
- $vals['messages'] = '';
+ if ( isset( $this->prop['hasmsg'] ) ) {
+ $vals['messages'] = $user->getNewtalk();
}
if ( isset( $this->prop['groups'] ) ) {
$vals['groups'] = $user->getEffectiveGroups();
+ ApiResult::setArrayType( $vals['groups'], 'array' ); // even if empty
ApiResult::setIndexedTagName( $vals['groups'], 'g' ); // even if empty
}
if ( isset( $this->prop['implicitgroups'] ) ) {
$vals['implicitgroups'] = $user->getAutomaticGroups();
+ ApiResult::setArrayType( $vals['implicitgroups'], 'array' ); // even if empty
ApiResult::setIndexedTagName( $vals['implicitgroups'], 'g' ); // even if empty
}
if ( isset( $this->prop['rights'] ) ) {
// User::getRights() may return duplicate values, strip them
$vals['rights'] = array_values( array_unique( $user->getRights() ) );
+ ApiResult::setArrayType( $vals['rights'], 'array' ); // even if empty
ApiResult::setIndexedTagName( $vals['rights'], 'r' ); // even if empty
}
@@ -108,6 +111,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
if ( isset( $this->prop['options'] ) ) {
$vals['options'] = $user->getOptions();
+ $vals['options'][ApiResult::META_BC_BOOLS] = array_keys( $vals['options'] );
}
if ( isset( $this->prop['preferencestoken'] ) ) {
@@ -191,9 +195,13 @@ class ApiQueryUserInfo extends ApiQueryBase {
}
protected function getRateLimits() {
+ $retval = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
+
$user = $this->getUser();
if ( !$user->isPingLimitable() ) {
- return array(); // No limits
+ return $retval; // No limits
}
// Find out which categories we belong to
@@ -213,7 +221,6 @@ class ApiQueryUserInfo extends ApiQueryBase {
$categories = array_merge( $categories, $user->getGroups() );
// Now get the actual limits
- $retval = array();
foreach ( $this->getConfig()->get( 'RateLimits' ) as $action => $limits ) {
foreach ( $categories as $cat ) {
if ( isset( $limits[$cat] ) && !is_null( $limits[$cat] ) ) {
diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php
index e2c47f54f2a3..f22c21340e34 100644
--- a/includes/api/ApiQueryUsers.php
+++ b/includes/api/ApiQueryUsers.php
@@ -110,7 +110,7 @@ class ApiQueryUsers extends ApiQueryBase {
foreach ( $users as $u ) {
$n = User::getCanonicalName( $u );
if ( $n === false || $n === '' ) {
- $vals = array( 'name' => $u, 'invalid' => '' );
+ $vals = array( 'name' => $u, 'invalid' => true );
$fit = $result->addValue( array( 'query', $this->getModuleName() ),
null, $vals );
if ( !$fit ) {
@@ -190,7 +190,7 @@ class ApiQueryUsers extends ApiQueryBase {
$data[$name]['rights'] = $user->getRights();
}
if ( $row->ipb_deleted ) {
- $data[$name]['hidden'] = '';
+ $data[$name]['hidden'] = true;
}
if ( isset( $this->prop['blockinfo'] ) && !is_null( $row->ipb_by_text ) ) {
$data[$name]['blockid'] = $row->ipb_id;
@@ -201,8 +201,8 @@ class ApiQueryUsers extends ApiQueryBase {
$data[$name]['blockexpiry'] = $row->ipb_expiry;
}
- if ( isset( $this->prop['emailable'] ) && $user->canReceiveEmail() ) {
- $data[$name]['emailable'] = '';
+ if ( isset( $this->prop['emailable'] ) ) {
+ $data[$name]['emailable'] = $user->canReceiveEmail();
}
if ( isset( $this->prop['gender'] ) ) {
@@ -237,7 +237,7 @@ class ApiQueryUsers extends ApiQueryBase {
$iwUser = $urPage->fetchUser( $u );
if ( $iwUser instanceof UserRightsProxy ) {
- $data[$u]['interwiki'] = '';
+ $data[$u]['interwiki'] = true;
if ( !is_null( $params['token'] ) ) {
$tokenFunctions = $this->getTokenFunctions();
@@ -252,16 +252,19 @@ class ApiQueryUsers extends ApiQueryBase {
}
}
} else {
- $data[$u]['missing'] = '';
+ $data[$u]['missing'] = true;
}
} else {
if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) {
+ ApiResult::setArrayType( $data[$u]['groups'], 'array' );
ApiResult::setIndexedTagName( $data[$u]['groups'], 'g' );
}
if ( isset( $this->prop['implicitgroups'] ) && isset( $data[$u]['implicitgroups'] ) ) {
+ ApiResult::setArrayType( $data[$u]['implicitgroups'], 'array' );
ApiResult::setIndexedTagName( $data[$u]['implicitgroups'], 'g' );
}
if ( isset( $this->prop['rights'] ) && isset( $data[$u]['rights'] ) ) {
+ ApiResult::setArrayType( $data[$u]['rights'], 'array' );
ApiResult::setIndexedTagName( $data[$u]['rights'], 'r' );
}
}
diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php
index bd1ed0a1fc9f..9f7387c710e8 100644
--- a/includes/api/ApiQueryWatchlist.php
+++ b/includes/api/ApiQueryWatchlist.php
@@ -307,7 +307,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
if ( $this->fld_title || $this->fld_ids ) {
// These should already have been filtered out of the query, but just in case.
if ( $type === RC_LOG && ( $row->rc_deleted & LogPage::DELETED_ACTION ) ) {
- $vals['actionhidden'] = '';
+ $vals['actionhidden'] = true;
$anyHidden = true;
}
if ( $type !== RC_LOG ||
@@ -327,7 +327,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
/* Add user data and 'anon' flag, if user is anonymous. */
if ( $this->fld_user || $this->fld_userid ) {
if ( $row->rc_deleted & Revision::DELETED_USER ) {
- $vals['userhidden'] = '';
+ $vals['userhidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_USER, $user ) ) {
@@ -342,22 +342,16 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
}
if ( !$row->rc_user ) {
- $vals['anon'] = '';
+ $vals['anon'] = true;
}
}
}
/* Add flags, such as new, minor, bot. */
if ( $this->fld_flags ) {
- if ( $row->rc_bot ) {
- $vals['bot'] = '';
- }
- if ( $row->rc_type == RC_NEW ) {
- $vals['new'] = '';
- }
- if ( $row->rc_minor ) {
- $vals['minor'] = '';
- }
+ $vals['bot'] = (bool)$row->rc_bot;
+ $vals['new'] = $row->rc_type == RC_NEW;
+ $vals['minor'] = (bool)$row->rc_minor;
}
/* Add sizes of each revision. (Only available on 1.10+) */
@@ -380,7 +374,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
/* Add edit summary / log summary. */
if ( $this->fld_comment || $this->fld_parsedcomment ) {
if ( $row->rc_deleted & Revision::DELETED_COMMENT ) {
- $vals['commenthidden'] = '';
+ $vals['commenthidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_COMMENT, $user ) ) {
@@ -395,17 +389,14 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
}
/* Add the patrolled flag */
- if ( $this->fld_patrol && $row->rc_patrolled == 1 ) {
- $vals['patrolled'] = '';
- }
-
- if ( $this->fld_patrol && ChangesList::isUnpatrolled( $row, $user ) ) {
- $vals['unpatrolled'] = '';
+ if ( $this->fld_patrol ) {
+ $vals['patrolled'] = $row->rc_patrolled == 1;
+ $vals['unpatrolled'] = ChangesList::isUnpatrolled( $row, $user );
}
if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
if ( $row->rc_deleted & LogPage::DELETED_ACTION ) {
- $vals['actionhidden'] = '';
+ $vals['actionhidden'] = true;
$anyHidden = true;
}
if ( LogEventsList::userCanBitfield( $row->rc_deleted, LogPage::DELETED_ACTION, $user ) ) {
@@ -417,7 +408,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
}
if ( $anyHidden && ( $row->rc_deleted & Revision::DELETED_RESTRICTED ) ) {
- $vals['suppressed'] = '';
+ $vals['suppressed'] = true;
}
return $vals;
diff --git a/includes/api/ApiResult.php b/includes/api/ApiResult.php
index 490b8310dcad..5db8ca71ad60 100644
--- a/includes/api/ApiResult.php
+++ b/includes/api/ApiResult.php
@@ -180,7 +180,9 @@ class ApiResult implements ApiSerializable {
* Clear the current result data.
*/
public function reset() {
- $this->data = array();
+ $this->data = array(
+ self::META_TYPE => 'assoc', // Usually what's desired
+ );
$this->size = 0;
}
@@ -1242,7 +1244,7 @@ class ApiResult implements ApiSerializable {
}
/**
- * Alias for self::defineIndexedTagName()
+ * Alias for self::addIndexedTagName()
* @deprecated since 1.25, use $this->addIndexedTagName() instead
* @param array $path Path to the array, like addValue()'s $path
* @param string $tag
diff --git a/includes/api/ApiSetNotificationTimestamp.php b/includes/api/ApiSetNotificationTimestamp.php
index e41ee070a895..86a3f6aa04e8 100644
--- a/includes/api/ApiSetNotificationTimestamp.php
+++ b/includes/api/ApiSetNotificationTimestamp.php
@@ -115,21 +115,21 @@ class ApiSetNotificationTimestamp extends ApiBase {
foreach ( $pageSet->getInvalidTitles() as $title ) {
$r = array();
$r['title'] = $title;
- $r['invalid'] = '';
+ $r['invalid'] = true;
$result[] = $r;
}
foreach ( $pageSet->getMissingPageIDs() as $p ) {
$page = array();
$page['pageid'] = $p;
- $page['missing'] = '';
- $page['notwatched'] = '';
+ $page['missing'] = true;
+ $page['notwatched'] = true;
$result[] = $page;
}
foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
$rev = array();
$rev['revid'] = $r;
- $rev['missing'] = '';
- $rev['notwatched'] = '';
+ $rev['missing'] = true;
+ $rev['notwatched'] = true;
$result[] = $rev;
}
@@ -163,7 +163,7 @@ class ApiSetNotificationTimestamp extends ApiBase {
'title' => $title->getPrefixedText(),
);
if ( !$title->exists() ) {
- $r['missing'] = '';
+ $r['missing'] = true;
}
if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] ) ) {
$r['notificationtimestamp'] = '';
@@ -171,7 +171,7 @@ class ApiSetNotificationTimestamp extends ApiBase {
$r['notificationtimestamp'] = wfTimestamp( TS_ISO_8601, $timestamps[$ns][$dbkey] );
}
} else {
- $r['notwatched'] = '';
+ $r['notwatched'] = true;
}
$result[] = $r;
}
diff --git a/includes/api/ApiTokens.php b/includes/api/ApiTokens.php
index 9eb40209e6a3..4d7fc5a087f2 100644
--- a/includes/api/ApiTokens.php
+++ b/includes/api/ApiTokens.php
@@ -37,7 +37,9 @@ class ApiTokens extends ApiBase {
$this->logFeatureUsage( "action=tokens" );
$params = $this->extractRequestParams();
- $res = array();
+ $res = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
$types = $this->getTokenTypes();
foreach ( $params['type'] as $type ) {
diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php
index 6a585d4f1758..85d051def5c3 100644
--- a/includes/api/ApiWatch.php
+++ b/includes/api/ApiWatch.php
@@ -109,15 +109,15 @@ class ApiWatch extends ApiBase {
if ( $params['unwatch'] ) {
$status = UnwatchAction::doUnwatch( $title, $user );
+ $res['unwatched'] = $status->isOK();
if ( $status->isOK() ) {
- $res['unwatched'] = '';
$res['message'] = $this->msg( 'removedwatchtext', $title->getPrefixedText() )
->title( $title )->parseAsBlock();
}
} else {
$status = WatchAction::doWatch( $title, $user );
+ $res['watched'] = $status->isOK();
if ( $status->isOK() ) {
- $res['watched'] = '';
$res['message'] = $this->msg( 'addedwatchtext', $title->getPrefixedText() )
->title( $title )->parseAsBlock();
}
diff --git a/tests/phpunit/includes/api/ApiContinuationManagerTest.php b/tests/phpunit/includes/api/ApiContinuationManagerTest.php
index ea08c0284748..2edf0c6fb1dd 100644
--- a/tests/phpunit/includes/api/ApiContinuationManagerTest.php
+++ b/tests/phpunit/includes/api/ApiContinuationManagerTest.php
@@ -84,7 +84,7 @@ class ApiContinuationManagerTest extends MediaWikiTestCase {
'gcontinue' => 3,
'continue' => 'gcontinue||',
), $result->getResultData( 'continue' ) );
- $this->assertSame( '', $result->getResultData( 'batchcomplete' ) );
+ $this->assertSame( true, $result->getResultData( 'batchcomplete' ) );
$manager = self::getManager( '', $allModules, array( 'mock1', 'mock2' ) );
$this->assertSame( false, $manager->isGeneratorDone() );
diff --git a/tests/phpunit/includes/api/ApiErrorFormatterTest.php b/tests/phpunit/includes/api/ApiErrorFormatterTest.php
index 344af62fddeb..8ebdf60f5f19 100644
--- a/tests/phpunit/includes/api/ApiErrorFormatterTest.php
+++ b/tests/phpunit/includes/api/ApiErrorFormatterTest.php
@@ -15,6 +15,11 @@ class ApiErrorFormatterTest extends MediaWikiTestCase {
$result = new ApiResult( 8388608 );
$formatter = new ApiErrorFormatter( $result, Language::factory( $lang ), $format, $useDB );
+ // Add default type
+ $expect1[ApiResult::META_TYPE] = 'assoc';
+ $expect2[ApiResult::META_TYPE] = 'assoc';
+ $expect3[ApiResult::META_TYPE] = 'assoc';
+
$formatter->addWarning( 'string', 'mainpage' );
$formatter->addError( 'err', 'mainpage' );
$this->assertSame( $expect1, $result->getResultData(), 'Simple test' );
@@ -262,6 +267,7 @@ class ApiErrorFormatterTest extends MediaWikiTestCase {
ApiResult::META_CONTENT => 'warnings',
),
),
+ ApiResult::META_TYPE => 'assoc',
), $result->getResultData(), 'Simple test' );
$result->reset();
@@ -293,6 +299,7 @@ class ApiErrorFormatterTest extends MediaWikiTestCase {
ApiResult::META_CONTENT => 'warnings',
),
),
+ ApiResult::META_TYPE => 'assoc',
), $result->getResultData(), 'Complex test' );
$result->reset();
@@ -315,6 +322,7 @@ class ApiErrorFormatterTest extends MediaWikiTestCase {
ApiResult::META_CONTENT => 'warnings',
),
),
+ ApiResult::META_TYPE => 'assoc',
), $result->getResultData(), 'Status test' );
$I = ApiResult::META_INDEXED_TAG_NAME;
diff --git a/tests/phpunit/includes/api/ApiResultTest.php b/tests/phpunit/includes/api/ApiResultTest.php
index 7e43a240a718..03d058a7cf40 100644
--- a/tests/phpunit/includes/api/ApiResultTest.php
+++ b/tests/phpunit/includes/api/ApiResultTest.php
@@ -144,7 +144,12 @@ class ApiResultTest extends MediaWikiTestCase {
$result2 = new ApiResult( 8388608 );
$result2->addValue( null, 'foo', 'bar' );
ApiResult::setValue( $arr, 'baz', $result2 );
- $this->assertSame( array( 'baz' => array( 'foo' => 'bar' ) ), $arr );
+ $this->assertSame( array(
+ 'baz' => array(
+ ApiResult::META_TYPE => 'assoc',
+ 'foo' => 'bar',
+ )
+ ), $arr );
$arr = array();
ApiResult::setValue( $arr, 'foo', "foo\x80bar" );
@@ -182,6 +187,7 @@ class ApiResultTest extends MediaWikiTestCase {
'unnamed 2',
'a' => array( 'b' => array() ),
'setContentValue' => '3',
+ ApiResult::META_TYPE => 'assoc',
ApiResult::META_CONTENT => 'setContentValue',
), $result->getResultData() );
$this->assertSame( 20, $result->getSize() );
@@ -217,7 +223,9 @@ class ApiResultTest extends MediaWikiTestCase {
$result->getResultData( array( ApiResult::META_CONTENT ) ) );
$result->reset();
- $this->assertSame( array(), $result->getResultData() );
+ $this->assertSame( array(
+ ApiResult::META_TYPE => 'assoc',
+ ), $result->getResultData() );
$this->assertSame( 0, $result->getSize() );
$result->addValue( null, 'foo', 1 );
@@ -227,7 +235,7 @@ class ApiResultTest extends MediaWikiTestCase {
$result->addValue( null, 'bottom', '2' );
$result->addValue( null, 'foo', '2', ApiResult::OVERRIDE );
$result->addValue( null, 'bar', '2', ApiResult::OVERRIDE | ApiResult::ADD_ON_TOP );
- $this->assertSame( array( 0, 'top', 'foo', 'bar', 'bottom' ),
+ $this->assertSame( array( 0, 'top', 'foo', 'bar', 'bottom', ApiResult::META_TYPE ),
array_keys( $result->getResultData() ) );
$result->reset();
@@ -240,8 +248,10 @@ class ApiResultTest extends MediaWikiTestCase {
$result->reset();
$result->addValue( null, 'sub', array( 'foo' => 1 ) );
$result->addValue( null, 'sub', array( 'bar' => 1 ) );
- $this->assertSame( array( 'sub' => array( 'foo' => 1, 'bar' => 1 ) ),
- $result->getResultData() );
+ $this->assertSame( array(
+ 'sub' => array( 'foo' => 1, 'bar' => 1 ),
+ ApiResult::META_TYPE => 'assoc',
+ ), $result->getResultData() );
try {
$result->addValue( null, 'sub', array( 'foo' => 2, 'baz' => 2 ) );
@@ -264,6 +274,7 @@ class ApiResultTest extends MediaWikiTestCase {
$this->assertSame( array(
'title' => (string)$title,
'obj' => array( 'foo' => 1, 'bar' => 2, ApiResult::META_TYPE => 'assoc' ),
+ ApiResult::META_TYPE => 'assoc',
), $result->getResultData() );
$fh = tmpfile();
@@ -313,9 +324,15 @@ class ApiResultTest extends MediaWikiTestCase {
$result->reset();
$result->addParsedLimit( 'foo', 12 );
- $this->assertSame( array( 'limits' => array( 'foo' => 12 ) ), $result->getResultData() );
+ $this->assertSame( array(
+ 'limits' => array( 'foo' => 12 ),
+ ApiResult::META_TYPE => 'assoc',
+ ), $result->getResultData() );
$result->addParsedLimit( 'foo', 13 );
- $this->assertSame( array( 'limits' => array( 'foo' => 13 ) ), $result->getResultData() );
+ $this->assertSame( array(
+ 'limits' => array( 'foo' => 13 ),
+ ApiResult::META_TYPE => 'assoc',
+ ), $result->getResultData() );
$this->assertSame( null, $result->getResultData( array( 'foo', 'bar', 'baz' ) ) );
$this->assertSame( 13, $result->getResultData( array( 'limits', 'foo' ) ) );
try {
@@ -345,7 +362,13 @@ class ApiResultTest extends MediaWikiTestCase {
$result2 = new ApiResult( 8388608 );
$result2->addValue( null, 'foo', 'bar' );
$result->addValue( null, 'baz', $result2 );
- $this->assertSame( array( 'baz' => array( 'foo' => 'bar' ) ), $result->getResultData() );
+ $this->assertSame( array(
+ 'baz' => array(
+ 'foo' => 'bar',
+ ApiResult::META_TYPE => 'assoc',
+ ),
+ ApiResult::META_TYPE => 'assoc',
+ ), $result->getResultData() );
$result = new ApiResult( 8388608 );
$result->addValue( null, 'foo', "foo\x80bar" );
@@ -355,6 +378,7 @@ class ApiResultTest extends MediaWikiTestCase {
'foo' => "foo\xef\xbf\xbdbar",
'bar' => "\xc3\xa1",
'baz' => 74,
+ ApiResult::META_TYPE => 'assoc',
), $result->getResultData() );
}
@@ -403,7 +427,7 @@ class ApiResultTest extends MediaWikiTestCase {
$result->removePreserveKeysList( null, 'baz' );
$result->addArrayTypeRecursive( null, 'default' );
$result->addArrayType( null, 'array' );
- $this->assertSame( $expect, $result->getResultData() );
+ $this->assertEquals( $expect, $result->getResultData() );
$arr = array( 'foo' => array( 'bar' => array() ) );
$expect = array(
@@ -1211,7 +1235,7 @@ class ApiResultTest extends MediaWikiTestCase {
'gcontinue' => 3,
'continue' => 'gcontinue||',
), $result->getResultData( 'continue' ) );
- $this->assertSame( '', $result->getResultData( 'batchcomplete' ) );
+ $this->assertSame( true, $result->getResultData( 'batchcomplete' ) );
$this->assertSame( array(
'mocklist' => array( 'mlcontinue' => 2 ),
'generator' => array( 'gcontinue' => 3 ),
@@ -1229,7 +1253,7 @@ class ApiResultTest extends MediaWikiTestCase {
'gcontinue' => 3,
'continue' => 'gcontinue||mocklist',
), $result->getResultData( 'continue' ) );
- $this->assertSame( '', $result->getResultData( 'batchcomplete' ) );
+ $this->assertSame( true, $result->getResultData( 'batchcomplete' ) );
$this->assertSame( array(
'generator' => array( 'gcontinue' => 3 ),
), $result->getResultData( 'query-continue' ) );
@@ -1283,7 +1307,7 @@ class ApiResultTest extends MediaWikiTestCase {
'mlcontinue' => 2,
'continue' => '-||mock1|mock2',
), $result->getResultData( 'continue' ) );
- $this->assertSame( '', $result->getResultData( 'batchcomplete' ) );
+ $this->assertSame( true, $result->getResultData( 'batchcomplete' ) );
$this->assertSame( array(
'mocklist' => array( 'mlcontinue' => 2 ),
), $result->getResultData( 'query-continue' ) );
@@ -1296,7 +1320,7 @@ class ApiResultTest extends MediaWikiTestCase {
$result->endContinuation( 'raw' );
$result->endContinuation( 'standard' );
$this->assertSame( null, $result->getResultData( 'continue' ) );
- $this->assertSame( '', $result->getResultData( 'batchcomplete' ) );
+ $this->assertSame( true, $result->getResultData( 'batchcomplete' ) );
$this->assertSame( null, $result->getResultData( 'query-continue' ) );
$main->setContinuationManager( null );
diff --git a/tests/phpunit/includes/api/format/ApiFormatTestBase.php b/tests/phpunit/includes/api/format/ApiFormatTestBase.php
index 67949ab9f2df..cabf62b18a32 100644
--- a/tests/phpunit/includes/api/format/ApiFormatTestBase.php
+++ b/tests/phpunit/includes/api/format/ApiFormatTestBase.php
@@ -33,6 +33,7 @@ abstract class ApiFormatTestBase extends MediaWikiTestCase {
$main->getModuleManager()->addModule( $this->printerName, 'format', $class );
}
$result = $main->getResult();
+ $result->addArrayType( null, 'default' );
foreach ( $data as $k => $v ) {
$result->addValue( null, $k, $v );
}
diff --git a/tests/phpunit/includes/api/query/ApiQueryContinue2Test.php b/tests/phpunit/includes/api/query/ApiQueryContinue2Test.php
index 243176139aff..cd735223c25e 100644
--- a/tests/phpunit/includes/api/query/ApiQueryContinue2Test.php
+++ b/tests/phpunit/includes/api/query/ApiQueryContinue2Test.php
@@ -61,7 +61,7 @@ class ApiQueryContinue2Test extends ApiQueryContinueTestBase {
};
// generator + 1 prop + 1 list
$data = $this->query( $mk( 99, 99, true ), 1, 'g1p', false ) +
- array( 'batchcomplete' => '' );
+ array( 'batchcomplete' => true );
$this->checkC( $data, $mk( 1, 1, true ), 6, 'g1p-11t' );
$this->checkC( $data, $mk( 2, 2, true ), 3, 'g1p-22t' );
$this->checkC( $data, $mk( 1, 1, false ), 6, 'g1p-11f' );
diff --git a/tests/phpunit/includes/api/query/ApiQueryContinueTest.php b/tests/phpunit/includes/api/query/ApiQueryContinueTest.php
index de9965b6e9dd..d441f4c40632 100644
--- a/tests/phpunit/includes/api/query/ApiQueryContinueTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryContinueTest.php
@@ -67,7 +67,7 @@ class ApiQueryContinueTest extends ApiQueryContinueTestBase {
);
};
$data = $this->query( $mk( 99 ), 1, '1L', false ) +
- array( 'batchcomplete' => '' );
+ array( 'batchcomplete' => true );
// 1 list
$this->checkC( $data, $mk( 1 ), 5, '1L-1' );
@@ -95,7 +95,7 @@ class ApiQueryContinueTest extends ApiQueryContinueTestBase {
};
// 2 lists
$data = $this->query( $mk( 99, 99 ), 1, '2L', false ) +
- array( 'batchcomplete' => '' );
+ array( 'batchcomplete' => true );
$this->checkC( $data, $mk( 1, 1 ), 5, '2L-11' );
$this->checkC( $data, $mk( 2, 2 ), 3, '2L-22' );
$this->checkC( $data, $mk( 3, 3 ), 2, '2L-33' );
@@ -120,7 +120,7 @@ class ApiQueryContinueTest extends ApiQueryContinueTestBase {
};
// generator + 1 prop
$data = $this->query( $mk( 99, 99 ), 1, 'G1P', false ) +
- array( 'batchcomplete' => '' );
+ array( 'batchcomplete' => true );
$this->checkC( $data, $mk( 1, 1 ), 11, 'G1P-11' );
$this->checkC( $data, $mk( 2, 2 ), 6, 'G1P-22' );
$this->checkC( $data, $mk( 3, 3 ), 4, 'G1P-33' );
@@ -146,7 +146,7 @@ class ApiQueryContinueTest extends ApiQueryContinueTestBase {
};
// generator + 2 props
$data = $this->query( $mk( 99, 99, 99 ), 1, 'G2P', false ) +
- array( 'batchcomplete' => '' );
+ array( 'batchcomplete' => true );
$this->checkC( $data, $mk( 1, 1, 1 ), 16, 'G2P-111' );
$this->checkC( $data, $mk( 2, 2, 2 ), 9, 'G2P-222' );
$this->checkC( $data, $mk( 3, 3, 3 ), 6, 'G2P-333' );
@@ -180,7 +180,7 @@ class ApiQueryContinueTest extends ApiQueryContinueTestBase {
};
// generator + 1 prop + 1 list
$data = $this->query( $mk( 99, 99, 99 ), 1, 'G1P1L', false ) +
- array( 'batchcomplete' => '' );
+ array( 'batchcomplete' => true );
$this->checkC( $data, $mk( 1, 1, 1 ), 11, 'G1P1L-111' );
$this->checkC( $data, $mk( 2, 2, 2 ), 6, 'G1P1L-222' );
$this->checkC( $data, $mk( 3, 3, 3 ), 4, 'G1P1L-333' );
@@ -218,7 +218,7 @@ class ApiQueryContinueTest extends ApiQueryContinueTestBase {
};
// generator + 1 prop + 1 list
$data = $this->query( $mk( 99, 99, 99, 99, 99 ), 1, 'G2P2L1M', false ) +
- array( 'batchcomplete' => '' );
+ array( 'batchcomplete' => true );
$this->checkC( $data, $mk( 1, 1, 1, 1, 1 ), 16, 'G2P2L1M-11111' );
$this->checkC( $data, $mk( 2, 2, 2, 2, 2 ), 9, 'G2P2L1M-22222' );
$this->checkC( $data, $mk( 3, 3, 3, 3, 3 ), 6, 'G2P2L1M-33333' );
@@ -249,7 +249,7 @@ class ApiQueryContinueTest extends ApiQueryContinueTestBase {
};
// generator + 1 prop
$data = $this->query( $mk( 99, true, 99, true ), 1, 'G=P', false ) +
- array( 'batchcomplete' => '' );
+ array( 'batchcomplete' => true );
$this->checkC( $data, $mk( 1, true, 1, true ), 4, 'G=P-1t1t' );
$this->checkC( $data, $mk( 2, true, 2, true ), 2, 'G=P-2t2t' );
@@ -296,7 +296,7 @@ class ApiQueryContinueTest extends ApiQueryContinueTestBase {
};
// generator + 1 list
$data = $this->query( $mk( 99, true, 99, true ), 1, 'G=L', false ) +
- array( 'batchcomplete' => '' );
+ array( 'batchcomplete' => true );
$this->checkC( $data, $mk( 1, true, 1, true ), 5, 'G=L-1t1t' );
$this->checkC( $data, $mk( 2, true, 2, true ), 3, 'G=L-2t2t' );