From: Derk-Jan Hartman Date: Sun, 17 Apr 2016 15:46:07 +0000 (+0200) Subject: API: Allow subclassing ApiQueryImageInfo X-Git-Tag: 1.31.0-rc.0~7274^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_del%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=6e7473536925f2c502fd51d8bcb8caada050d31e;p=lhc%2Fweb%2Fwiklou.git API: Allow subclassing ApiQueryImageInfo execute() references the static self::getInfo, which therefor cannot be overriden by the subclass ApiQueryVideoInfo. Preferably, we'd fix the implementation to not require this subclassing, but this will make that transition easier. Use late static binding to make sure the subclass implementation can be used. Change-Id: Iab2d01abb9f9b3b799123d8ee344ea139e476576 --- diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index ab94574065..13e6340203 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -162,7 +162,7 @@ class ApiQueryImageInfo extends ApiQueryBase { $gotOne = true; $fit = $this->addPageSubItem( $pageId, - self::getInfo( $img, $prop, $result, + static::getInfo( $img, $prop, $result, $finalThumbParams, $opts ) ); @@ -197,7 +197,7 @@ class ApiQueryImageInfo extends ApiQueryBase { } $fit = self::getTransformCount() < self::TRANSFORM_LIMIT && $this->addPageSubItem( $pageId, - self::getInfo( $oldie, $prop, $result, + static::getInfo( $oldie, $prop, $result, $finalThumbParams, $opts ) ); @@ -533,11 +533,11 @@ class ApiQueryImageInfo extends ApiQueryBase { if ( $metadata && $version !== 'latest' ) { $metadata = $file->convertMetadataVersion( $metadata, $version ); } - $vals['metadata'] = $metadata ? self::processMetaData( $metadata, $result ) : null; + $vals['metadata'] = $metadata ? static::processMetaData( $metadata, $result ) : null; } if ( $commonmeta ) { $metaArray = $file->getCommonMetaArray(); - $vals['commonmetadata'] = $metaArray ? self::processMetaData( $metaArray, $result ) : []; + $vals['commonmetadata'] = $metaArray ? static::processMetaData( $metaArray, $result ) : []; } if ( $extmetadata ) { @@ -601,7 +601,7 @@ class ApiQueryImageInfo extends ApiQueryBase { ApiResult::META_BC_BOOLS => [ 'value' ], ]; if ( is_array( $value ) ) { - $r['value'] = self::processMetaData( $value, $result ); + $r['value'] = static::processMetaData( $value, $result ); } else { $r['value'] = $value; } @@ -641,8 +641,8 @@ class ApiQueryImageInfo extends ApiQueryBase { 'prop' => [ ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_DFLT => 'timestamp|user', - ApiBase::PARAM_TYPE => self::getPropertyNames(), - ApiBase::PARAM_HELP_MSG_PER_VALUE => self::getPropertyMessages(), + ApiBase::PARAM_TYPE => static::getPropertyNames(), + ApiBase::PARAM_HELP_MSG_PER_VALUE => static::getPropertyMessages(), ], 'limit' => [ ApiBase::PARAM_TYPE => 'limit', @@ -703,7 +703,7 @@ class ApiQueryImageInfo extends ApiQueryBase { * @return array */ public static function getPropertyNames( $filter = [] ) { - return array_keys( self::getPropertyMessages( $filter ) ); + return array_keys( static::getPropertyMessages( $filter ) ); } /** @@ -787,7 +787,7 @@ class ApiQueryImageInfo extends ApiQueryBase { public static function getPropertyDescriptions( $filter = [], $modulePrefix = '' ) { return array_merge( [ 'What image information to get:' ], - array_values( array_diff_key( self::getProperties( $modulePrefix ), array_flip( $filter ) ) ) + array_values( array_diff_key( static::getProperties( $modulePrefix ), array_flip( $filter ) ) ) ); }