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

Static Public Member Functions

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

Public Attributes

const FOR_PUBLIC = 1
 
const FOR_THIS_USER = 2
 
const RAW = 3
 

Protected Attributes

bool $exists
 
MediaHandler $handler
 
Title $title
 

Private Member Functions

 getHandler ()
 Get a MediaHandler instance for this file.
 

Private Attributes

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

Detailed Description

Class representing a row of the 'filearchive' table.

Stability: stable
to extend

Definition at line 35 of file ArchivedFile.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 118 of file ArchivedFile.php.

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

Member Function Documentation

◆ exists()

ArchivedFile::exists ( )
Returns
bool

Definition at line 356 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 432 of file ArchivedFile.php.

References $bits, and load().

◆ getDescription()

ArchivedFile::getDescription ( int  $audience = self::FOR_PUBLIC,
Authority  $performer = null 
)

Return upload description.

Since
1.37 the method takes $audience and $performer parameters.
Parameters
int$audienceOne of: File::FOR_PUBLIC to be displayed to all users File::FOR_THIS_USER to be displayed to the given user File::RAW get the description regardless of permissions
Authority | null$performerto check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
string

Definition at line 576 of file ArchivedFile.php.

◆ getGroup()

ArchivedFile::getGroup ( )

Return the FileStore storage group.

Returns
string

Definition at line 384 of file ArchivedFile.php.

References $group.

◆ getHandler()

ArchivedFile::getHandler ( )
private

Get a MediaHandler instance for this file.

Returns
MediaHandler

Definition at line 452 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 402 of file ArchivedFile.php.

References $height, and load().

◆ getID()

ArchivedFile::getID ( )
Returns
int

Definition at line 347 of file ArchivedFile.php.

References $id, and load().

◆ getKey()

ArchivedFile::getKey ( )

Return the FileStore key.

Returns
string

Definition at line 366 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 486 of file ArchivedFile.php.

References $media_type, and load().

◆ getMetadata()

ArchivedFile::getMetadata ( )

Get handler-specific metadata.

Returns
string

Definition at line 412 of file ArchivedFile.php.

References $metadata, and load().

◆ getMimeType()

ArchivedFile::getMimeType ( )

Returns the MIME type of the file.

Returns
string

Definition at line 442 of file ArchivedFile.php.

References $mime, and load().

Referenced by getHandler().

◆ getName()

ArchivedFile::getName ( )

Return the file name.

Returns
string

Definition at line 336 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.34, fa_user and fa_user_text have not been present in the database, but they continue to be available in query results as an alias.

Since
1.31
Stability: stable
to override
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 247 of file ArchivedFile.php.

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

◆ getRawDescription()

ArchivedFile::getRawDescription ( )

Return upload description.

Deprecated:
since 1.37. Use getDescription with self::RAW audience.
Returns
string

Definition at line 615 of file ArchivedFile.php.

References wfDeprecated().

◆ getRawUser()

ArchivedFile::getRawUser ( )

Return the user ID of the uploader.

Deprecated:
since 1.37. Use getUploader with self::RAW audience.
Returns
int

Definition at line 593 of file ArchivedFile.php.

References wfDeprecated().

◆ getRawUserText()

ArchivedFile::getRawUserText ( )

Return the user name of the uploader.

Deprecated:
since 1.37. Use getUploader with self::RAW audience.
Returns
string

Definition at line 604 of file ArchivedFile.php.

References wfDeprecated().

◆ getSha1()

ArchivedFile::getSha1 ( )

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

Returns
string
Since
1.21

Definition at line 509 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 422 of file ArchivedFile.php.

References $size, and load().

◆ getStorageKey()

ArchivedFile::getStorageKey ( )

Return the FileStore key (overriding base File class)

Returns
string

Definition at line 376 of file ArchivedFile.php.

References getKey().

Referenced by EraseArchivedFile\scrubVersion().

◆ getTimestamp()

ArchivedFile::getTimestamp ( )

Return upload timestamp.

Returns
string

Definition at line 497 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 324 of file ArchivedFile.php.

References $title, and load().

◆ getUploader()

ArchivedFile::getUploader ( int  $audience = self::FOR_PUBLIC,
Authority  $performer = null 
)
Since
1.37
Stability: stable
to override
Parameters
int$audienceOne of: File::FOR_PUBLIC to be displayed to all users File::FOR_THIS_USER to be displayed to the given user File::RAW get the description regardless of permissions
Authority | null$performerto check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
UserIdentity|null

Definition at line 553 of file ArchivedFile.php.

◆ 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.
Deprecated:
since 1.37. Use getUploader instead.
Parameters
string$type'text', 'id', or 'object'
Returns
int|string|User|null
Exceptions
MWException
Since
1.31 added 'object'

Definition at line 527 of file ArchivedFile.php.

References $type, load(), User\newFromIdentity(), and wfDeprecated().

◆ getVisibility()

ArchivedFile::getVisibility ( )

Returns the deletion bitfield.

Returns
int

Definition at line 625 of file ArchivedFile.php.

◆ getWidth()

ArchivedFile::getWidth ( )

Return the width of the image.

Returns
int

Definition at line 392 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 637 of file ArchivedFile.php.

◆ load()

ArchivedFile::load ( )

Loads a file object from the filearchive table.

Stability: stable
to override
Exceptions
MWException
Returns
bool|null True on success or null

Definition at line 167 of file ArchivedFile.php.

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

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

◆ loadFromRow()

ArchivedFile::loadFromRow (   $row)

Load ArchivedFile object fields from a DB row.

Stability: stable
to override
Parameters
stdClass$rowObject database row
Since
1.21

Definition at line 289 of file ArchivedFile.php.

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

Referenced by load().

◆ newFromRow()

static ArchivedFile::newFromRow (   $row)
static

Loads a file object from the filearchive table.

Stability: stable
to override
Parameters
stdClass$row
Returns
ArchivedFile

Definition at line 225 of file ArchivedFile.php.

References $file, 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.

Stability: stable
to override
Returns
int|false

Definition at line 466 of file ArchivedFile.php.

References $pageCount, getHandler(), and pageCount().

Referenced by pageCount().

◆ userCan()

ArchivedFile::userCan (   $field,
Authority  $performer 
)

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
Authority$performer
Returns
bool

Definition at line 650 of file ArchivedFile.php.

References $title, and getTitle().

Member Data Documentation

◆ $archive_name

string ArchivedFile::$archive_name
private

Original base filename.

Definition at line 99 of file ArchivedFile.php.

◆ $bits

int ArchivedFile::$bits
private

Size in bytes.

Definition at line 58 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 85 of file ArchivedFile.php.

◆ $deleted

int ArchivedFile::$deleted
private

Bitfield akin to rev_deleted.

Definition at line 88 of file ArchivedFile.php.

◆ $description

string ArchivedFile::$description
private

Upload description.

Definition at line 76 of file ArchivedFile.php.

◆ $exists

bool ArchivedFile::$exists
protected

Definition at line 108 of file ArchivedFile.php.

Referenced by exists().

◆ $group

string ArchivedFile::$group
private

FileStore storage group.

Definition at line 49 of file ArchivedFile.php.

Referenced by getGroup(), and load().

◆ $handler

MediaHandler ArchivedFile::$handler
protected

Definition at line 102 of file ArchivedFile.php.

Referenced by getHandler().

◆ $height

int ArchivedFile::$height
private

Height.

Definition at line 64 of file ArchivedFile.php.

Referenced by getHeight().

◆ $id

int ArchivedFile::$id
private

Filearchive row ID.

Definition at line 43 of file ArchivedFile.php.

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

◆ $key

string ArchivedFile::$key
private

FileStore SHA-1 key.

Definition at line 52 of file ArchivedFile.php.

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

◆ $media_type

string ArchivedFile::$media_type
private

Media type.

Definition at line 73 of file ArchivedFile.php.

Referenced by getMediaType().

◆ $metadata

string ArchivedFile::$metadata
private

Definition at line 67 of file ArchivedFile.php.

Referenced by getMetadata().

◆ $mime

string ArchivedFile::$mime
private

MIME type.

Definition at line 70 of file ArchivedFile.php.

Referenced by getMimeType().

◆ $name

string ArchivedFile::$name
private

File name.

Definition at line 46 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 96 of file ArchivedFile.php.

Referenced by pageCount().

◆ $sha1

string ArchivedFile::$sha1
private

SHA-1 hash of file content.

Definition at line 91 of file ArchivedFile.php.

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

◆ $size

int ArchivedFile::$size
private

File size in bytes.

Definition at line 55 of file ArchivedFile.php.

Referenced by getSize().

◆ $timestamp

string ArchivedFile::$timestamp
private

Time of upload.

Definition at line 82 of file ArchivedFile.php.

◆ $title

Title ArchivedFile::$title
protected

Definition at line 105 of file ArchivedFile.php.

Referenced by __construct(), and getTitle().

◆ $user

UserIdentity null ArchivedFile::$user
private

Uploader.

Definition at line 79 of file ArchivedFile.php.

◆ $width

int ArchivedFile::$width
private

Width.

Definition at line 61 of file ArchivedFile.php.

Referenced by getWidth().

◆ FOR_PUBLIC

const ArchivedFile::FOR_PUBLIC = 1

Definition at line 38 of file ArchivedFile.php.

◆ FOR_THIS_USER

const ArchivedFile::FOR_THIS_USER = 2

Definition at line 39 of file ArchivedFile.php.

Referenced by RevDelArchivedFileItem\getApiData().

◆ RAW

const ArchivedFile::RAW = 3

Definition at line 40 of file ArchivedFile.php.


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