jenkins-bot has submitted this change and it was merged.
Change subject: API: Allow filtering keys in iiprop=extmetadata
......................................................................
API: Allow filtering keys in iiprop=extmetadata
Requesting iiprop=extmetadata can return a *lot* of meta data, when the
client may only be interested in certain keys. This adds a
"iiextmetadatafilter" parameter to allow the client to indicate which
keys it cares about.
Change-Id: Ie2185ec285e40359fffab4932bff8cab16071a53
---
M includes/api/ApiQueryImageInfo.php
1 file changed, 12 insertions(+), 0 deletions(-)
Approvals:
MaxSem: Looks good to me, approved
Gergő Tisza: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/includes/api/ApiQueryImageInfo.php
b/includes/api/ApiQueryImageInfo.php
index 990130f..96840e8 100644
--- a/includes/api/ApiQueryImageInfo.php
+++ b/includes/api/ApiQueryImageInfo.php
@@ -53,6 +53,7 @@
'version' => $params['metadataversion'],
'language' => $params['extmetadatalanguage'],
'multilang' => $params['extmetadatamultilang'],
+ 'extmetadatafilter' => $params['extmetadatafilter'],
);
$pageIds = $this->getPageSet()->getAllTitlesByNamespace();
@@ -321,6 +322,7 @@
'version' => $metadataOpts ?: 'latest',
'language' => $wgContLang,
'multilang' => false,
+ 'extmetadatafilter' => array(),
);
}
$version = $metadataOpts['version'];
@@ -451,6 +453,11 @@
$format->setSingleLanguage( !$metadataOpts['multilang']
);
$format->getContext()->setLanguage(
$metadataOpts['language'] );
$extmetaArray = $format->fetchExtendedMetadata( $file );
+ if ( $metadataOpts['extmetadatafilter'] ) {
+ $extmetaArray = array_intersect_key(
+ $extmetaArray, array_flip(
$metadataOpts['extmetadatafilter'] )
+ );
+ }
$vals['extmetadata'] = $extmetaArray;
}
@@ -571,6 +578,10 @@
ApiBase::PARAM_TYPE => 'boolean',
ApiBase::PARAM_DFLT => false,
),
+ 'extmetadatafilter' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_ISMULTI => true,
+ ),
'urlparam' => array(
ApiBase::PARAM_DFLT => '',
ApiBase::PARAM_TYPE => 'string',
@@ -658,6 +669,7 @@
'translation to fetch, if multiple are
available, as well as how things',
'like numbers and various values are
formatted.' ),
'extmetadatamultilang' => 'If translations for
extmetadata property are available, fetch all of them.',
+ 'extmetadatafilter' => "If specified and non-empty,
only these keys will be returned for {$p}prop=extmetadata",
'continue' => 'If the query response includes a
continue value, use it here to get another page of results',
'localonly' => 'Look only for files in the local
repository',
);
--
To view, visit https://gerrit.wikimedia.org/r/95472
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie2185ec285e40359fffab4932bff8cab16071a53
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits