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?
/**
* 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',
'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::newKey( 'fa_description' )->getFields();
+ }
+
+ /**
+ * 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::newKey( 'fa_description' )->getJoin();
+ 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'],
];
}
$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::newKey( 'fa_description' )
+ // Legacy because $row may have come from self::selectFields()
+ ->getCommentLegacy( wfGetDB( DB_REPLICA ), $row )->text;
$this->user = $row->fa_user;
$this->user_text = $row->fa_user_text;
$this->timestamp = $row->fa_timestamp;
throw new MWException( "Unknown type '$type'." );
}
- /**
- * Return the user name of the uploader.
- *
- * @deprecated since 1.23 Use getUser( 'text' ) instead.
- * @return string|int
- */
- 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.
*