MediaWiki master
MediaWiki\FileRepo\File\ArchivedFile Class Reference

Deleted file in the 'filearchive' table. More...

Collaboration diagram for MediaWiki\FileRepo\File\ArchivedFile:

Public Member Functions

 __construct ( $title, $id=0, $key='', $sha1='')
 
 exists ()
 
 getBits ()
 
 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 as a serialized string.
 
 getMetadataArray ()
 Get unserialized handler-specific metadata.
 
 getMetadataForDb (IReadableDatabase $db)
 Serialize the metadata array for insertion into img_metadata, oi_metadata or fa_metadata.
 
 getMetadataItems (array $itemNames)
 
 getMimeType ()
 Returns the MIME type of the file.
 
 getName ()
 Return the file name.
 
 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)
 
 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 Member Functions

 loadMetadataFromDbFieldValue (IReadableDatabase $db, $metadataBlob)
 Unserialize a metadata blob which came from the database and store it in $this.
 
 loadMetadataFromString ( $metadataString)
 Unserialize a metadata string which came from some non-DB source, or is the return value of IReadableDatabase::decodeBlob().
 

Protected Attributes

bool $exists
 
bool $extraDataLoaded = false
 Whether or not lazy-loaded data has been loaded from the database.
 
MediaHandler $handler
 
array $metadataArray = []
 Unserialized metadata.
 
string[] $metadataBlobs = []
 Map of metadata item name to blob address.
 
string null $metadataSerializationFormat
 One of the MDS_* constants, giving the format of the metadata as stored in the DB, or null if the data was not loaded from the DB.
 
Title null $title
 
string[] $unloadedMetadataBlobs = []
 Map of metadata item name to blob address for items that exist but have not yet been loaded into $this->metadataArray.
 

Detailed Description

Deleted file in the 'filearchive' table.

Stability: stable
to extend

Definition at line 31 of file ArchivedFile.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\FileRepo\File\ArchivedFile::__construct ( $title,
$id = 0,
$key = '',
$sha1 = '' )

Member Function Documentation

◆ exists()

◆ getBits()

MediaWiki\FileRepo\File\ArchivedFile::getBits ( )
Returns
int

Definition at line 604 of file ArchivedFile.php.

◆ getDescription()

MediaWiki\FileRepo\File\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 721 of file ArchivedFile.php.

◆ getGroup()

MediaWiki\FileRepo\File\ArchivedFile::getGroup ( )

Return the FileStore storage group.

Returns
string

Definition at line 395 of file ArchivedFile.php.

◆ getHeight()

MediaWiki\FileRepo\File\ArchivedFile::getHeight ( )

Return the height of the image.

Returns
int

Definition at line 413 of file ArchivedFile.php.

References MediaWiki\FileRepo\File\ArchivedFile\load().

◆ getID()

MediaWiki\FileRepo\File\ArchivedFile::getID ( )
Returns
int

Definition at line 358 of file ArchivedFile.php.

References MediaWiki\FileRepo\File\ArchivedFile\load().

◆ getKey()

MediaWiki\FileRepo\File\ArchivedFile::getKey ( )

Return the FileStore key.

Returns
string

Definition at line 377 of file ArchivedFile.php.

References MediaWiki\FileRepo\File\ArchivedFile\load().

Referenced by MediaWiki\FileRepo\File\ArchivedFile\getStorageKey().

◆ getMediaType()

MediaWiki\FileRepo\File\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 658 of file ArchivedFile.php.

◆ getMetadata()

MediaWiki\FileRepo\File\ArchivedFile::getMetadata ( )

Get handler-specific metadata as a serialized string.

Deprecated
since 1.37 use getMetadataArray() or getMetadataItem()
Returns
string

Definition at line 425 of file ArchivedFile.php.

References MediaWiki\FileRepo\File\ArchivedFile\getMetadataArray().

◆ getMetadataArray()

MediaWiki\FileRepo\File\ArchivedFile::getMetadataArray ( )

Get unserialized handler-specific metadata.

Since
1.39
Returns
array

Definition at line 443 of file ArchivedFile.php.

References MediaWiki\FileRepo\File\ArchivedFile\getMetadataItems().

Referenced by MediaWiki\FileRepo\File\ArchivedFile\getMetadata().

◆ getMetadataForDb()

MediaWiki\FileRepo\File\ArchivedFile::getMetadataForDb ( IReadableDatabase $db)

Serialize the metadata array for insertion into img_metadata, oi_metadata or fa_metadata.

If metadata splitting is enabled, this may write blobs to the database, returning their addresses.

Access: internal
Parameters
IReadableDatabase$db
Returns
string|Blob

Definition at line 493 of file ArchivedFile.php.

References Wikimedia\Rdbms\IReadableDatabase\encodeBlob().

◆ getMetadataItems()

MediaWiki\FileRepo\File\ArchivedFile::getMetadataItems ( array $itemNames)

◆ getMimeType()

MediaWiki\FileRepo\File\ArchivedFile::getMimeType ( )

Returns the MIME type of the file.

Returns
string

Definition at line 614 of file ArchivedFile.php.

◆ getName()

MediaWiki\FileRepo\File\ArchivedFile::getName ( )

Return the file name.

Returns
string

Definition at line 347 of file ArchivedFile.php.

References MediaWiki\FileRepo\File\ArchivedFile\load().

Referenced by EraseArchivedFile\scrubVersion().

◆ getQueryInfo()

static MediaWiki\FileRepo\File\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
Deprecated
since 1.41 use FileSelectQueryBuilder instead
Returns
array[] With three keys:
  • tables: (string[]) to include in the $table to IDatabase->select() or SelectQueryBuilder::tables
  • fields: (string[]) to include in the $vars to IDatabase->select() or SelectQueryBuilder::fields
  • joins: (array) to include in the $join_conds to IDatabase->select() or SelectQueryBuilder::joinConds

Definition at line 279 of file ArchivedFile.php.

References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\FileRepo\File\ArchivedFile\getQueryInfo(), and MediaWiki\FileRepo\File\FileSelectQueryBuilder\newForArchivedFile().

Referenced by MediaWiki\Api\ApiQueryFilearchive\execute(), and MediaWiki\FileRepo\File\ArchivedFile\getQueryInfo().

◆ getSha1()

MediaWiki\FileRepo\File\ArchivedFile::getSha1 ( )

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

Returns
string
Since
1.21

Definition at line 681 of file ArchivedFile.php.

◆ getSize()

MediaWiki\FileRepo\File\ArchivedFile::getSize ( )

Return the size of the image file, in bytes.

Returns
int

Definition at line 595 of file ArchivedFile.php.

◆ getStorageKey()

MediaWiki\FileRepo\File\ArchivedFile::getStorageKey ( )

Return the FileStore key (overriding base File class)

Returns
string

Definition at line 387 of file ArchivedFile.php.

References MediaWiki\FileRepo\File\ArchivedFile\getKey().

Referenced by EraseArchivedFile\scrubVersion().

◆ getTimestamp()

MediaWiki\FileRepo\File\ArchivedFile::getTimestamp ( )

Return upload timestamp.

Returns
string

Definition at line 669 of file ArchivedFile.php.

References wfTimestamp().

Referenced by EraseArchivedFile\scrubVersion().

◆ getTitle()

MediaWiki\FileRepo\File\ArchivedFile::getTitle ( )

Return the associated title object.

Returns
Title

Definition at line 335 of file ArchivedFile.php.

References MediaWiki\FileRepo\File\ArchivedFile\$title, and MediaWiki\FileRepo\File\ArchivedFile\load().

◆ getUploader()

MediaWiki\FileRepo\File\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 698 of file ArchivedFile.php.

◆ getVisibility()

MediaWiki\FileRepo\File\ArchivedFile::getVisibility ( )

Returns the deletion bitfield.

Returns
int

Definition at line 736 of file ArchivedFile.php.

◆ getWidth()

MediaWiki\FileRepo\File\ArchivedFile::getWidth ( )

Return the width of the image.

Returns
int

Definition at line 403 of file ArchivedFile.php.

References MediaWiki\FileRepo\File\ArchivedFile\load().

◆ isDeleted()

MediaWiki\FileRepo\File\ArchivedFile::isDeleted ( $field)

for file or revision rows

Parameters
int$fieldOne of DELETED_* bitfield constants
Returns
bool

Definition at line 748 of file ArchivedFile.php.

◆ load()

◆ loadFromRow()

MediaWiki\FileRepo\File\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 296 of file ArchivedFile.php.

References MediaWiki\FileRepo\File\ArchivedFile\exists(), MediaWiki\FileRepo\LocalRepo\getHashFromKey(), MediaWiki\MediaWikiServices\getInstance(), MediaWiki\FileRepo\File\ArchivedFile\loadMetadataFromDbFieldValue(), and NS_FILE.

Referenced by MediaWiki\FileRepo\File\ArchivedFile\load().

◆ loadMetadataFromDbFieldValue()

MediaWiki\FileRepo\File\ArchivedFile::loadMetadataFromDbFieldValue ( IReadableDatabase $db,
$metadataBlob )
protected

Unserialize a metadata blob which came from the database and store it in $this.

Since
1.39
Parameters
IReadableDatabase$db
string | Blob$metadataBlob

Definition at line 541 of file ArchivedFile.php.

References Wikimedia\Rdbms\IReadableDatabase\decodeBlob().

Referenced by MediaWiki\FileRepo\File\ArchivedFile\loadFromRow().

◆ loadMetadataFromString()

MediaWiki\FileRepo\File\ArchivedFile::loadMetadataFromString ( $metadataString)
protected

Unserialize a metadata string which came from some non-DB source, or is the return value of IReadableDatabase::decodeBlob().

Since
1.37
Parameters
string$metadataString

Definition at line 552 of file ArchivedFile.php.

◆ newFromRow()

static MediaWiki\FileRepo\File\ArchivedFile::newFromRow ( $row)
static

Loads a file object from the filearchive table.

Stability: stable
to override
Parameters
stdClass$row
Returns
ArchivedFile

Definition at line 255 of file ArchivedFile.php.

References MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\makeTitle(), and NS_FILE.

Referenced by MediaWiki\Api\ApiQueryFilearchive\execute().

◆ pageCount()

MediaWiki\FileRepo\File\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 638 of file ArchivedFile.php.

◆ userCan()

MediaWiki\FileRepo\File\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 761 of file ArchivedFile.php.

Member Data Documentation

◆ $exists

bool MediaWiki\FileRepo\File\ArchivedFile::$exists
protected

Definition at line 138 of file ArchivedFile.php.

Referenced by MediaWiki\FileRepo\File\ArchivedFile\exists().

◆ $extraDataLoaded

bool MediaWiki\FileRepo\File\ArchivedFile::$extraDataLoaded = false
protected

Whether or not lazy-loaded data has been loaded from the database.

Definition at line 78 of file ArchivedFile.php.

◆ $handler

MediaHandler MediaWiki\FileRepo\File\ArchivedFile::$handler
protected

Definition at line 132 of file ArchivedFile.php.

◆ $metadataArray

array MediaWiki\FileRepo\File\ArchivedFile::$metadataArray = []
protected

Unserialized metadata.

Definition at line 75 of file ArchivedFile.php.

◆ $metadataBlobs

string [] MediaWiki\FileRepo\File\ArchivedFile::$metadataBlobs = []
protected

Map of metadata item name to blob address.

Definition at line 89 of file ArchivedFile.php.

◆ $metadataSerializationFormat

string null MediaWiki\FileRepo\File\ArchivedFile::$metadataSerializationFormat
protected

One of the MDS_* constants, giving the format of the metadata as stored in the DB, or null if the data was not loaded from the DB.

Definition at line 86 of file ArchivedFile.php.

◆ $title

Title null MediaWiki\FileRepo\File\ArchivedFile::$title
protected

◆ $unloadedMetadataBlobs

string [] MediaWiki\FileRepo\File\ArchivedFile::$unloadedMetadataBlobs = []
protected

Map of metadata item name to blob address for items that exist but have not yet been loaded into $this->metadataArray.

Definition at line 97 of file ArchivedFile.php.

◆ FOR_PUBLIC

const MediaWiki\FileRepo\File\ArchivedFile::FOR_PUBLIC = 1

Definition at line 34 of file ArchivedFile.php.

◆ FOR_THIS_USER

const MediaWiki\FileRepo\File\ArchivedFile::FOR_THIS_USER = 2

Definition at line 35 of file ArchivedFile.php.

◆ RAW

const MediaWiki\FileRepo\File\ArchivedFile::RAW = 3

Definition at line 36 of file ArchivedFile.php.


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