X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryFilearchive.php;h=212b61340ac64897af028fb97beb717fc61a0482;hb=1d7a1bf8bddf0908e4f572c82268733f63126a13;hp=03be491e7cc17d08695cde64a7a81c2471b23026;hpb=8eac2feedb7ee093d2c48504e1eb2b8a9dbc8452;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index 03be491e7c..212b61340a 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -38,16 +38,12 @@ class ApiQueryFilearchive extends ApiQueryBase { } public function execute() { - $user = $this->getUser(); // Before doing anything at all, let's check permissions - if ( !$user->isAllowed( 'deletedhistory' ) ) { - $this->dieUsage( - 'You don\'t have permission to view deleted file information', - 'permissiondenied' - ); - } + $this->checkUserRightsAny( 'deletedhistory' ); + $user = $this->getUser(); $db = $this->getDB(); + $commentStore = new CommentStore( 'fa_description' ); $params = $this->extractRequestParams(); @@ -71,13 +67,19 @@ class ApiQueryFilearchive extends ApiQueryBase { $this->addFieldsIf( 'fa_sha1', $fld_sha1 ); $this->addFieldsIf( [ 'fa_user', 'fa_user_text' ], $fld_user ); $this->addFieldsIf( [ 'fa_height', 'fa_width', 'fa_size' ], $fld_dimensions || $fld_size ); - $this->addFieldsIf( 'fa_description', $fld_description ); $this->addFieldsIf( [ 'fa_major_mime', 'fa_minor_mime' ], $fld_mime ); $this->addFieldsIf( 'fa_media_type', $fld_mediatype ); $this->addFieldsIf( 'fa_metadata', $fld_metadata ); $this->addFieldsIf( 'fa_bits', $fld_bitdepth ); $this->addFieldsIf( 'fa_archive_name', $fld_archivename ); + if ( $fld_description ) { + $commentQuery = $commentStore->getJoin(); + $this->addTables( $commentQuery['tables'] ); + $this->addFields( $commentQuery['fields'] ); + $this->addJoinConds( $commentQuery['joins'] ); + } + if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); $this->dieContinueUsageIf( count( $cont ) != 3 ); @@ -112,13 +114,13 @@ class ApiQueryFilearchive extends ApiQueryBase { if ( $sha1Set ) { $sha1 = strtolower( $params['sha1'] ); if ( !$this->validateSha1Hash( $sha1 ) ) { - $this->dieUsage( 'The SHA1 hash provided is not valid', 'invalidsha1hash' ); + $this->dieWithError( 'apierror-invalidsha1hash' ); } $sha1 = Wikimedia\base_convert( $sha1, 16, 36, 31 ); } elseif ( $sha1base36Set ) { $sha1 = strtolower( $params['sha1base36'] ); if ( !$this->validateSha1Base36Hash( $sha1 ) ) { - $this->dieUsage( 'The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash' ); + $this->dieWithError( 'apierror-invalidsha1base36hash' ); } } if ( $sha1 ) { @@ -170,10 +172,10 @@ class ApiQueryFilearchive extends ApiQueryBase { if ( $fld_description && Revision::userCanBitfield( $row->fa_deleted, File::DELETED_COMMENT, $user ) ) { - $file['description'] = $row->fa_description; + $file['description'] = $commentStore->getComment( $row )->text; if ( isset( $prop['parseddescription'] ) ) { $file['parseddescription'] = Linker::formatComment( - $row->fa_description, $title ); + $file['description'], $title ); } } if ( $fld_user && @@ -297,6 +299,6 @@ class ApiQueryFilearchive extends ApiQueryBase { } public function getHelpUrls() { - return 'https://www.mediawiki.org/wiki/API:Filearchive'; + return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Filearchive'; } }