From 7b9b91ead5e9f0bcbbb2daf2b8734cbee932c02d Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 9 Dec 2013 11:22:27 -0500 Subject: [PATCH] API: Add iiprop=canonicaltitle With recent changes to the filerepo backends, prop=imageinfo will now return information for the target file when file redirects are queried. To make this more transparent to clients, add an iiprop to return the canonical title for the imageinfo data. Change-Id: I62e368ffe09512f1af6677994f1ccca776b97651 --- includes/api/ApiQueryImageInfo.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 86cba83066..bf11a76f19 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -385,6 +385,7 @@ class ApiQueryImageInfo extends ApiQueryBase { } } + $canonicaltitle = isset( $prop['canonicaltitle'] ); $url = isset( $prop['url'] ); $sha1 = isset( $prop['sha1'] ); $meta = isset( $prop['metadata'] ); @@ -395,7 +396,7 @@ class ApiQueryImageInfo extends ApiQueryBase { $bitdepth = isset( $prop['bitdepth'] ); $uploadwarning = isset( $prop['uploadwarning'] ); - if ( ( $url || $sha1 || $meta || $mime || $mediatype || $archive || $bitdepth ) + if ( ( $canonicaltitle || $url || $sha1 || $meta || $mime || $mediatype || $archive || $bitdepth ) && $file->isDeleted( File::DELETED_FILE ) ) { $vals['filehidden'] = ''; @@ -404,6 +405,10 @@ class ApiQueryImageInfo extends ApiQueryBase { return $vals; } + if ( $canonicaltitle ) { + $vals['canonicaltitle'] = $file->getTitle()->getPrefixedText(); + } + if ( $url ) { if ( !is_null( $thumbParams ) ) { $mto = $file->transform( $thumbParams ); @@ -618,6 +623,7 @@ class ApiQueryImageInfo extends ApiQueryBase { 'userid' => ' userid - Add the user ID that uploaded the image version', 'comment' => ' comment - Comment on the version', 'parsedcomment' => ' parsedcomment - Parse the comment on the version', + 'canonicaltitle' => ' canonicaltitle - Adds the canonical title of the image file', 'url' => ' url - Gives URL to the image and the description page', 'size' => ' size - Adds the size of the image in bytes ' . 'and the height, width and page count (if applicable)', @@ -737,6 +743,12 @@ class ApiQueryImageInfo extends ApiQueryBase { ApiBase::PROP_NULLABLE => true ) ), + 'canonicaltitle' => array( + 'canonicaltitle' => array( + ApiBase::PROP_TYPE => 'string', + ApiBase::PROP_NULLABLE => true + ) + ), 'url' => array( 'filehidden' => 'boolean', 'thumburl' => array( -- 2.20.1