122 $this->group =
'deleted';
128 $this->metadata =
'';
129 $this->mime =
"unknown/unknown";
130 $this->media_type =
'';
131 $this->description =
'';
133 $this->timestamp =
null;
135 $this->dataLoaded =
false;
140 $this->title = File::normalizeTitle(
$title,
'exception' );
157 throw new MWException(
"No specifications provided to ArchivedFile constructor." );
168 if ( $this->dataLoaded ) {
173 if ( $this->
id > 0 ) {
180 if ( $this->title ) {
181 $conds[
'fa_name'] = $this->title->getDBkey();
187 if ( $conds === [] ) {
188 throw new MWException(
"No specific information for retrieving archived file" );
191 if ( !$this->title || $this->title->getNamespace() ===
NS_FILE ) {
192 $this->dataLoaded =
true;
195 $row =
$dbr->selectRow(
196 $fileQuery[
'tables'],
197 $fileQuery[
'fields'],
200 [
'ORDER BY' =>
'fa_timestamp DESC' ],
211 throw new MWException(
'This title does not correspond to an image page.' );
227 $file->loadFromRow( $row );
248 $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin(
'fa_description' );
252 'filearchive_actor' =>
'actor'
253 ] + $commentQuery[
'tables'],
270 'fa_deleted_timestamp',
273 'fa_user' =>
'filearchive_actor.actor_user',
274 'fa_user_text' =>
'filearchive_actor.actor_name'
275 ] + $commentQuery[
'fields'],
277 'filearchive_actor' => [
'JOIN',
'actor_id=fa_actor' ]
278 ] + $commentQuery[
'joins'],
290 $this->
id = intval( $row->fa_id );
291 $this->name = $row->fa_name;
292 $this->archive_name = $row->fa_archive_name;
293 $this->group = $row->fa_storage_group;
294 $this->key = $row->fa_storage_key;
295 $this->size = $row->fa_size;
296 $this->bits = $row->fa_bits;
297 $this->width = $row->fa_width;
298 $this->height = $row->fa_height;
299 $this->metadata = $row->fa_metadata;
300 $this->mime =
"$row->fa_major_mime/$row->fa_minor_mime";
301 $this->media_type = $row->fa_media_type;
302 $services = MediaWikiServices::getInstance();
303 $this->description = $services->getCommentStore()
306 $this->user = $services->getUserFactory()
307 ->newFromAnyId( $row->fa_user, $row->fa_user_text, $row->fa_actor );
308 $this->timestamp = $row->fa_timestamp;
309 $this->deleted = $row->fa_deleted;
310 if ( isset( $row->fa_sha1 ) ) {
311 $this->sha1 = $row->fa_sha1;
316 if ( !$this->title ) {
317 $this->title = Title::makeTitleSafe(
NS_FILE, $row->fa_name );
327 if ( !$this->title ) {
339 if ( $this->name ===
false ) {
455 if ( !isset( $this->handler ) ) {
472 if ( $this->
getHandler() && $this->handler->isMultiPage( $this ) ) {
474 $this->
pageCount = $this->handler->pageCount( $this );
530 if ( $audience === self::FOR_PUBLIC && $this->
isDeleted( File::DELETED_USER ) ) {
532 } elseif ( $audience === self::FOR_THIS_USER && !$this->
userCan( File::DELETED_USER, $performer ) ) {
553 if ( $audience === self::FOR_PUBLIC && $this->isDeleted( File::DELETED_COMMENT ) ) {
555 } elseif ( $audience === self::FOR_THIS_USER && !$this->userCan( File::DELETED_COMMENT, $performer ) ) {
558 return $this->description;
569 return $this->deleted;
581 return ( $this->deleted & $field ) == $field;
595 return RevisionRecord::userCanBitfield(
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Class representing a row of the 'filearchive' table.
getTimestamp()
Return upload timestamp.
getSize()
Return the size of the image file, in bytes.
bool $dataLoaded
Whether or not all this has been loaded from the database (loadFromXxx)
isDeleted( $field)
for file or revision rows
getHeight()
Return the height of the image.
getBits()
Return the bits of the image file, in bytes.
int $size
File size in bytes.
string $sha1
SHA-1 hash of file content.
string $media_type
Media type.
string $key
FileStore SHA-1 key.
string $group
FileStore storage group.
string $description
Upload description.
getSha1()
Get the SHA-1 base 36 hash of the file.
string $archive_name
Original base filename.
int false $pageCount
Number of pages of a multipage document, or false for documents which aren't multipage documents.
getHandler()
Get a MediaHandler instance for this file.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new archivedfile object.
loadFromRow( $row)
Load ArchivedFile object fields from a DB row.
UserIdentity null $user
Uploader.
int $id
Filearchive row ID.
__construct( $title, $id=0, $key='', $sha1='')
string null $timestamp
Time of upload.
getUploader(int $audience=self::FOR_PUBLIC, Authority $performer=null)
load()
Loads a file object from the filearchive table.
pageCount()
Returns the number of pages of a multipage document, or false for documents which aren't multipage do...
getGroup()
Return the FileStore storage group.
static newFromRow( $row)
Loads a file object from the filearchive table.
getTitle()
Return the associated title object.
string false $name
File name.
getWidth()
Return the width of the image.
int $deleted
Bitfield akin to rev_deleted.
getStorageKey()
Return the FileStore key (overriding base File class)
getDescription(int $audience=self::FOR_PUBLIC, Authority $performer=null)
Return upload description.
getMimeType()
Returns the MIME type of the file.
getKey()
Return the FileStore key.
userCan( $field, Authority $performer)
Determine if the current user is allowed to view a particular field of this FileStore image file,...
getName()
Return the file name.
getMediaType()
Return the type of the media in the file.
getVisibility()
Returns the deletion bitfield.
getMetadata()
Get handler-specific metadata.
static getHashFromKey( $key)
Gets the SHA1 hash from a storage key.
Represents a title within MediaWiki.
getDBkey()
Get the main part with underscores.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.