MediaWiki  1.34.0
ArchivedFile Class Reference

Class representing a row of the 'filearchive' table. More...

Collaboration diagram for ArchivedFile:

Public Member Functions

 __construct ( $title, $id=0, $key='', $sha1='')
 
 exists ()
 
 getBits ()
 Return the bits of the image file, in bytes. More...
 
 getDescription ()
 Return upload description. More...
 
 getGroup ()
 Return the FileStore storage group. More...
 
 getHandler ()
 Get a MediaHandler instance for this file. More...
 
 getHeight ()
 Return the height of the image. More...
 
 getID ()
 
 getKey ()
 Return the FileStore key. More...
 
 getMediaType ()
 Return the type of the media in the file. More...
 
 getMetadata ()
 Get handler-specific metadata. More...
 
 getMimeType ()
 Returns the MIME type of the file. More...
 
 getName ()
 Return the file name. More...
 
 getRawDescription ()
 Return upload description. More...
 
 getRawUser ()
 Return the user ID of the uploader. More...
 
 getRawUserText ()
 Return the user name of the uploader. More...
 
 getSha1 ()
 Get the SHA-1 base 36 hash of the file. More...
 
 getSize ()
 Return the size of the image file, in bytes. More...
 
 getStorageKey ()
 Return the FileStore key (overriding base File class) More...
 
 getTimestamp ()
 Return upload timestamp. More...
 
 getTitle ()
 Return the associated title object. More...
 
 getUser ( $type='text')
 Returns ID or name of user who uploaded the file. More...
 
 getVisibility ()
 Returns the deletion bitfield. More...
 
 getWidth ()
 Return the width of the image. More...
 
 isDeleted ( $field)
 for file or revision rows More...
 
 load ()
 Loads a file object from the filearchive table. More...
 
 loadFromRow ( $row)
 Load ArchivedFile object fields from a DB row. More...
 
 pageCount ()
 Returns the number of pages of a multipage document, or false for documents which aren't multipage documents. More...
 
 userCan ( $field, User $user=null)
 Determine if the current user is allowed to view a particular field of this FileStore image file, if it's marked as deleted. More...
 

Static Public Member Functions

static getQueryInfo ()
 Return the tables, fields, and join conditions to be selected to create a new archivedfile object. More...
 
static newFromRow ( $row)
 Loads a file object from the filearchive table. More...
 

Protected Attributes

MediaHandler $handler
 
Title $title
 

Private Attributes

string $archive_name
 Original base filename. More...
 
int $bits
 Size in bytes. More...
 
bool $dataLoaded
 Whether or not all this has been loaded from the database (loadFromXxx) More...
 
int $deleted
 Bitfield akin to rev_deleted. More...
 
string $description
 Upload description. More...
 
bool $exists
 
string $group
 FileStore storage group. More...
 
int $height
 Height. More...
 
int $id
 Filearchive row ID. More...
 
string $key
 FileStore SHA-1 key. More...
 
string $media_type
 Media type. More...
 
string $metadata
 Metadata string. More...
 
string $mime
 MIME type. More...
 
string $name
 File name. More...
 
int false $pageCount
 Number of pages of a multipage document, or false for documents which aren't multipage documents. More...
 
string $sha1
 SHA-1 hash of file content. More...
 
int $size
 File size in bytes. More...
 
string $timestamp
 Time of upload. More...
 
User null $user
 Uploader. More...
 
int $width
 Width. More...
 

Detailed Description

Class representing a row of the 'filearchive' table.

Definition at line 31 of file ArchivedFile.php.

Constructor & Destructor Documentation

◆ __construct()

ArchivedFile::__construct (   $title,
  $id = 0,
  $key = '',
  $sha1 = '' 
)
Exceptions
MWException
Parameters
Title$title
int$id
string$key
string$sha1

Definition at line 107 of file ArchivedFile.php.

References $id, $key, $sha1, $title, exists(), Title\getDBkey(), and File\normalizeTitle().

Member Function Documentation

◆ exists()

ArchivedFile::exists ( )
Returns
bool

Definition at line 329 of file ArchivedFile.php.

References $exists, and load().

Referenced by __construct(), and load().

◆ getBits()

ArchivedFile::getBits ( )

Return the bits of the image file, in bytes.

Returns
int

Definition at line 405 of file ArchivedFile.php.

References $bits, and load().

◆ getDescription()

ArchivedFile::getDescription ( )

Return upload description.

Returns
string|int

Definition at line 517 of file ArchivedFile.php.

References $description, File\DELETED_COMMENT, isDeleted(), and load().

◆ getGroup()

ArchivedFile::getGroup ( )

Return the FileStore storage group.

Returns
string

Definition at line 357 of file ArchivedFile.php.

References $group.

◆ getHandler()

ArchivedFile::getHandler ( )

Get a MediaHandler instance for this file.

Returns
MediaHandler

Definition at line 425 of file ArchivedFile.php.

References $handler, MediaHandler\getHandler(), and getMimeType().

Referenced by pageCount().

◆ getHeight()

ArchivedFile::getHeight ( )

Return the height of the image.

Returns
int

Definition at line 375 of file ArchivedFile.php.

References $height, and load().

◆ getID()

ArchivedFile::getID ( )
Returns
int

Definition at line 320 of file ArchivedFile.php.

References $id, and load().

◆ getKey()

ArchivedFile::getKey ( )

Return the FileStore key.

Returns
string

Definition at line 339 of file ArchivedFile.php.

References $key, and load().

Referenced by getStorageKey().

◆ getMediaType()

ArchivedFile::getMediaType ( )

Return the type of the media in the file.

Use the value returned by this function with the MEDIATYPE_xxx constants.

Returns
string

Definition at line 458 of file ArchivedFile.php.

References $media_type, and load().

◆ getMetadata()

ArchivedFile::getMetadata ( )

Get handler-specific metadata.

Returns
string

Definition at line 385 of file ArchivedFile.php.

References $metadata, and load().

◆ getMimeType()

ArchivedFile::getMimeType ( )

Returns the MIME type of the file.

Returns
string

Definition at line 415 of file ArchivedFile.php.

References $mime, and load().

Referenced by getHandler().

◆ getName()

ArchivedFile::getName ( )

Return the file name.

Returns
string

Definition at line 309 of file ArchivedFile.php.

References $name, and load().

Referenced by EraseArchivedFile\scrubVersion().

◆ getQueryInfo()

static ArchivedFile::getQueryInfo ( )
static

Return the tables, fields, and join conditions to be selected to create a new archivedfile object.

Since
1.31
Returns
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()

Definition at line 228 of file ArchivedFile.php.

References ActorMigration\newMigration().

Referenced by RevDelArchivedFileList\doQuery(), ApiQueryFilearchive\execute(), EraseArchivedFile\execute(), LocalFileRestoreBatch\execute(), PageArchive\listFiles(), load(), and EraseArchivedFile\scrubAllVersions().

◆ getRawDescription()

ArchivedFile::getRawDescription ( )

Return upload description.

Returns
string

Definition at line 549 of file ArchivedFile.php.

References $description, and load().

◆ getRawUser()

ArchivedFile::getRawUser ( )

Return the user ID of the uploader.

Returns
int

Definition at line 531 of file ArchivedFile.php.

References getUser().

◆ getRawUserText()

ArchivedFile::getRawUserText ( )

Return the user name of the uploader.

Returns
string

Definition at line 540 of file ArchivedFile.php.

References getUser().

◆ getSha1()

ArchivedFile::getSha1 ( )

Get the SHA-1 base 36 hash of the file.

Returns
string
Since
1.21

Definition at line 481 of file ArchivedFile.php.

References $sha1, and load().

◆ getSize()

ArchivedFile::getSize ( )

Return the size of the image file, in bytes.

Returns
int

Definition at line 395 of file ArchivedFile.php.

References $size, and load().

◆ getStorageKey()

ArchivedFile::getStorageKey ( )

Return the FileStore key (overriding base File class)

Returns
string

Definition at line 349 of file ArchivedFile.php.

References getKey().

Referenced by EraseArchivedFile\scrubVersion().

◆ getTimestamp()

ArchivedFile::getTimestamp ( )

Return upload timestamp.

Returns
string

Definition at line 469 of file ArchivedFile.php.

References load(), and wfTimestamp().

Referenced by EraseArchivedFile\scrubVersion().

◆ getTitle()

ArchivedFile::getTitle ( )

Return the associated title object.

Returns
Title

Definition at line 297 of file ArchivedFile.php.

References $title, and load().

Referenced by userCan().

◆ getUser()

ArchivedFile::getUser (   $type = 'text')

Returns ID or name of user who uploaded the file.

Note
Prior to MediaWiki 1.23, this method always returned the user id, and was inconsistent with the rest of the file classes.
Parameters
string$type'text', 'id', or 'object'
Returns
int|string|User|null
Exceptions
MWException
Since
1.31 added 'object'

Definition at line 498 of file ArchivedFile.php.

References $type, $user, User\getName(), and load().

Referenced by getRawUser(), and getRawUserText().

◆ getVisibility()

ArchivedFile::getVisibility ( )

Returns the deletion bitfield.

Returns
int

Definition at line 559 of file ArchivedFile.php.

References $deleted, and load().

◆ getWidth()

ArchivedFile::getWidth ( )

Return the width of the image.

Returns
int

Definition at line 365 of file ArchivedFile.php.

References $width, and load().

◆ isDeleted()

ArchivedFile::isDeleted (   $field)

for file or revision rows

Parameters
int$fieldOne of DELETED_* bitfield constants
Returns
bool

Definition at line 571 of file ArchivedFile.php.

References load().

Referenced by getDescription().

◆ load()

ArchivedFile::load ( )

Loads a file object from the filearchive table.

Exceptions
MWException
Returns
bool|null True on success or null

Definition at line 155 of file ArchivedFile.php.

References $dbr, $group, $id, $key, $sha1, DB_REPLICA, exists(), getQueryInfo(), loadFromRow(), NS_FILE, and wfGetDB().

Referenced by exists(), getBits(), getDescription(), getHeight(), getID(), getKey(), getMediaType(), getMetadata(), getMimeType(), getName(), getRawDescription(), getSha1(), getSize(), getTimestamp(), getTitle(), getUser(), getVisibility(), getWidth(), isDeleted(), and userCan().

◆ loadFromRow()

ArchivedFile::loadFromRow (   $row)

Load ArchivedFile object fields from a DB row.

Parameters
stdClass$rowObject database row
Since
1.21

Definition at line 262 of file ArchivedFile.php.

References DB_REPLICA, LocalRepo\getHashFromKey(), Title\makeTitleSafe(), User\newFromAnyId(), NS_FILE, and wfGetDB().

Referenced by load().

◆ newFromRow()

static ArchivedFile::newFromRow (   $row)
static

Loads a file object from the filearchive table.

Parameters
stdClass$row
Returns
ArchivedFile

Definition at line 212 of file ArchivedFile.php.

References $file, Title\makeTitle(), and NS_FILE.

Referenced by ApiQueryFilearchive\execute(), EraseArchivedFile\execute(), SpecialUndelete\formatFileRow(), RevDelArchivedFileItem\initFile(), and EraseArchivedFile\scrubAllVersions().

◆ pageCount()

ArchivedFile::pageCount ( )

Returns the number of pages of a multipage document, or false for documents which aren't multipage documents.

Returns
bool|int

Definition at line 438 of file ArchivedFile.php.

References $pageCount, and getHandler().

◆ userCan()

ArchivedFile::userCan (   $field,
User  $user = null 
)

Determine if the current user is allowed to view a particular field of this FileStore image file, if it's marked as deleted.

Parameters
int$field
null | User$userUser object to check, or null to use $wgUser
Returns
bool

Definition at line 584 of file ArchivedFile.php.

References $title, $user, getTitle(), load(), and Revision\userCanBitfield().

Member Data Documentation

◆ $archive_name

string ArchivedFile::$archive_name
private

Original base filename.

Definition at line 89 of file ArchivedFile.php.

◆ $bits

int ArchivedFile::$bits
private

Size in bytes.

Definition at line 48 of file ArchivedFile.php.

Referenced by getBits().

◆ $dataLoaded

bool ArchivedFile::$dataLoaded
private

Whether or not all this has been loaded from the database (loadFromXxx)

Definition at line 75 of file ArchivedFile.php.

◆ $deleted

int ArchivedFile::$deleted
private

Bitfield akin to rev_deleted.

Definition at line 78 of file ArchivedFile.php.

Referenced by getVisibility().

◆ $description

string ArchivedFile::$description
private

Upload description.

Definition at line 66 of file ArchivedFile.php.

Referenced by getDescription(), and getRawDescription().

◆ $exists

bool ArchivedFile::$exists
private

Definition at line 98 of file ArchivedFile.php.

Referenced by exists().

◆ $group

string ArchivedFile::$group
private

FileStore storage group.

Definition at line 39 of file ArchivedFile.php.

Referenced by getGroup(), and load().

◆ $handler

MediaHandler ArchivedFile::$handler
protected

Definition at line 92 of file ArchivedFile.php.

Referenced by getHandler().

◆ $height

int ArchivedFile::$height
private

Height.

Definition at line 54 of file ArchivedFile.php.

Referenced by getHeight().

◆ $id

int ArchivedFile::$id
private

Filearchive row ID.

Definition at line 33 of file ArchivedFile.php.

Referenced by __construct(), getID(), and load().

◆ $key

string ArchivedFile::$key
private

FileStore SHA-1 key.

Definition at line 42 of file ArchivedFile.php.

Referenced by __construct(), getKey(), and load().

◆ $media_type

string ArchivedFile::$media_type
private

Media type.

Definition at line 63 of file ArchivedFile.php.

Referenced by getMediaType().

◆ $metadata

string ArchivedFile::$metadata
private

Metadata string.

Definition at line 57 of file ArchivedFile.php.

Referenced by getMetadata().

◆ $mime

string ArchivedFile::$mime
private

MIME type.

Definition at line 60 of file ArchivedFile.php.

Referenced by getMimeType().

◆ $name

string ArchivedFile::$name
private

File name.

Definition at line 36 of file ArchivedFile.php.

Referenced by getName().

◆ $pageCount

int false ArchivedFile::$pageCount
private

Number of pages of a multipage document, or false for documents which aren't multipage documents.

Definition at line 86 of file ArchivedFile.php.

Referenced by pageCount().

◆ $sha1

string ArchivedFile::$sha1
private

SHA-1 hash of file content.

Definition at line 81 of file ArchivedFile.php.

Referenced by __construct(), getSha1(), and load().

◆ $size

int ArchivedFile::$size
private

File size in bytes.

Definition at line 45 of file ArchivedFile.php.

Referenced by getSize().

◆ $timestamp

string ArchivedFile::$timestamp
private

Time of upload.

Definition at line 72 of file ArchivedFile.php.

◆ $title

Title ArchivedFile::$title
protected

Definition at line 95 of file ArchivedFile.php.

Referenced by __construct(), getTitle(), and userCan().

◆ $user

User null ArchivedFile::$user
private

Uploader.

Definition at line 69 of file ArchivedFile.php.

Referenced by getUser(), and userCan().

◆ $width

int ArchivedFile::$width
private

Width.

Definition at line 51 of file ArchivedFile.php.

Referenced by getWidth().


The documentation for this class was generated from the following file: