Anomie has uploaded a new change for review.

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


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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/72/95472/1

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: newchange
Gerrit-Change-Id: Ie2185ec285e40359fffab4932bff8cab16071a53
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

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

Reply via email to