X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ffilerepo%2Ffile%2FArchivedFile.php;h=9a7a55be9eb2d1a3e2e36b26642130b85ea9652c;hb=faf7cc4a09848c538320bd2b9067b1a77c0a0183;hp=921e129c36f564ddfbd7c34e3f97b5645000b4b3;hpb=2fdcd7bfdd95a3b1515b9a94289d67eb60add484;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/file/ArchivedFile.php b/includes/filerepo/file/ArchivedFile.php index 921e129c36..6577ab6742 100644 --- a/includes/filerepo/file/ArchivedFile.php +++ b/includes/filerepo/file/ArchivedFile.php @@ -81,7 +81,7 @@ class ArchivedFile { /** @var string SHA-1 hash of file content */ private $sha1; - /** @var string Number of pages of a multipage document, or false for + /** @var int|false Number of pages of a multipage document, or false for * documents which aren't multipage documents */ private $pageCount; @@ -178,12 +178,14 @@ class ArchivedFile { if ( !$this->title || $this->title->getNamespace() == NS_FILE ) { $this->dataLoaded = true; // set it here, to have also true on miss $dbr = wfGetDB( DB_REPLICA ); + $fileQuery = self::getQueryInfo(); $row = $dbr->selectRow( - 'filearchive', - self::selectFields(), + $fileQuery['tables'], + $fileQuery['fields'], $conds, __METHOD__, - [ 'ORDER BY' => 'fa_timestamp DESC' ] + [ 'ORDER BY' => 'fa_timestamp DESC' ], + $fileQuery['joins'] ); if ( !$row ) { // this revision does not exist? @@ -215,9 +217,11 @@ class ArchivedFile { /** * Fields in the filearchive table + * @deprecated since 1.31, use self::getQueryInfo() instead. * @return array */ static function selectFields() { + wfDeprecated( __METHOD__, '1.31' ); return [ 'fa_id', 'fa_name', @@ -232,13 +236,50 @@ class ArchivedFile { 'fa_media_type', 'fa_major_mime', 'fa_minor_mime', - 'fa_description', 'fa_user', 'fa_user_text', 'fa_timestamp', 'fa_deleted', 'fa_deleted_timestamp', /* Used by LocalFileRestoreBatch */ 'fa_sha1', + ] + CommentStore::getStore()->getFields( 'fa_description' ); + } + + /** + * Return the tables, fields, and join conditions to be selected to create + * a new archivedfile object. + * @since 1.31 + * @return array With three keys: + * - tables: (string[]) to include in the `$table` to `IDatabase->select()` + * - fields: (string[]) to include in the `$vars` to `IDatabase->select()` + * - joins: (array) to include in the `$join_conds` to `IDatabase->select()` + */ + public static function getQueryInfo() { + $commentQuery = CommentStore::getStore()->getJoin( 'fa_description' ); + return [ + 'tables' => [ 'filearchive' ] + $commentQuery['tables'], + 'fields' => [ + 'fa_id', + 'fa_name', + 'fa_archive_name', + 'fa_storage_key', + 'fa_storage_group', + 'fa_size', + 'fa_bits', + 'fa_width', + 'fa_height', + 'fa_metadata', + 'fa_media_type', + 'fa_major_mime', + 'fa_minor_mime', + 'fa_user', + 'fa_user_text', + 'fa_timestamp', + 'fa_deleted', + 'fa_deleted_timestamp', /* Used by LocalFileRestoreBatch */ + 'fa_sha1', + ] + $commentQuery['fields'], + 'joins' => $commentQuery['joins'], ]; } @@ -261,7 +302,9 @@ class ArchivedFile { $this->metadata = $row->fa_metadata; $this->mime = "$row->fa_major_mime/$row->fa_minor_mime"; $this->media_type = $row->fa_media_type; - $this->description = $row->fa_description; + $this->description = CommentStore::getStore() + // Legacy because $row may have come from self::selectFields() + ->getCommentLegacy( wfGetDB( DB_REPLICA ), 'fa_description', $row )->text; $this->user = $row->fa_user; $this->user_text = $row->fa_user_text; $this->timestamp = $row->fa_timestamp; @@ -492,26 +535,10 @@ class ArchivedFile { throw new MWException( "Unknown type '$type'." ); } - /** - * Return the user name of the uploader. - * - * @deprecated since 1.23 Use getUser( 'text' ) instead. - * @return string - */ - public function getUserText() { - wfDeprecated( __METHOD__, '1.23' ); - $this->load(); - if ( $this->isDeleted( File::DELETED_USER ) ) { - return 0; - } else { - return $this->user_text; - } - } - /** * Return upload description. * - * @return string + * @return string|int */ public function getDescription() { $this->load();