120 $this->title =
false;
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 $this->description = MediaWikiServices::getInstance()->getCommentStore()
305 $this->user =
User::newFromAnyId( $row->fa_user, $row->fa_user_text, $row->fa_actor );
306 $this->timestamp = $row->fa_timestamp;
307 $this->deleted = $row->fa_deleted;
308 if ( isset( $row->fa_sha1 ) ) {
309 $this->sha1 = $row->fa_sha1;
314 if ( !$this->title ) {
315 $this->title = Title::makeTitleSafe(
NS_FILE, $row->fa_name );
325 if ( !$this->title ) {
337 if ( $this->name ===
false ) {
453 if ( !isset( $this->handler ) ) {
470 if ( $this->
getHandler() && $this->handler->isMultiPage( $this ) ) {
472 $this->
pageCount = $this->handler->pageCount( $this );
531 if (
$type ===
'object' ) {
533 } elseif (
$type ===
'text' ) {
534 return $this->user ? $this->user->getName() :
'';
535 } elseif (
$type ===
'id' ) {
536 return $this->user ? $this->user->getId() : 0;
555 if ( $audience === self::FOR_PUBLIC && $this->
isDeleted( File::DELETED_USER ) ) {
557 } elseif ( $audience === self::FOR_THIS_USER && !$this->
userCan( File::DELETED_USER, $performer ) ) {
578 if ( $audience === self::FOR_PUBLIC && $this->isDeleted( File::DELETED_COMMENT ) ) {
580 } elseif ( $audience === self::FOR_THIS_USER && !$this->userCan( File::DELETED_COMMENT, $performer ) ) {
583 return $this->description;
595 return $this->getUser(
'id' );
606 return $this->getUser(
'text' );
618 return $this->description;
628 return $this->deleted;
640 return ( $this->deleted & $field ) == $field;
654 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.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
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.
getRawUserText()
Return the user name of the uploader.
UserIdentity null $user
Uploader.
int $id
Filearchive row ID.
getRawUser()
Return the user ID of the uploader.
__construct( $title, $id=0, $key='', $sha1='')
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.
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.
getUser( $type='text')
Returns ID or name of user who uploaded 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,...
string $timestamp
Time of upload.
getName()
Return the file name.
getMediaType()
Return the type of the media in the file.
getRawDescription()
Return upload description.
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.
static newFromAnyId( $userId, $userName, $actorId, $dbDomain=false)
Static factory method for creation from an ID, name, and/or actor ID.
static newFromIdentity(UserIdentity $identity)
Returns a User object corresponding to the given UserIdentity.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.