112 $this->title =
false;
114 $this->group =
'deleted';
120 $this->metadata =
'';
121 $this->mime =
"unknown/unknown";
122 $this->media_type =
'';
123 $this->description =
'';
125 $this->timestamp =
null;
127 $this->dataLoaded =
false;
132 $this->title = File::normalizeTitle(
$title,
'exception' );
149 throw new MWException(
"No specifications provided to ArchivedFile constructor." );
160 if ( $this->dataLoaded ) {
165 if ( $this->
id > 0 ) {
172 if ( $this->title ) {
173 $conds[
'fa_name'] = $this->title->getDBkey();
179 if ( $conds === [] ) {
180 throw new MWException(
"No specific information for retrieving archived file" );
183 if ( !$this->title || $this->title->getNamespace() ==
NS_FILE ) {
184 $this->dataLoaded =
true;
187 $row =
$dbr->selectRow(
188 $fileQuery[
'tables'],
189 $fileQuery[
'fields'],
192 [
'ORDER BY' =>
'fa_timestamp DESC' ],
203 throw new MWException(
'This title does not correspond to an image page.' );
219 $file->loadFromRow( $row );
235 $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin(
'fa_description' );
236 $actorQuery = ActorMigration::newMigration()->getJoin(
'fa_user' );
238 'tables' => [
'filearchive' ] + $commentQuery[
'tables'] + $actorQuery[
'tables'],
255 'fa_deleted_timestamp',
257 ] + $commentQuery[
'fields'] + $actorQuery[
'fields'],
258 'joins' => $commentQuery[
'joins'] + $actorQuery[
'joins'],
270 $this->
id = intval( $row->fa_id );
271 $this->name = $row->fa_name;
272 $this->archive_name = $row->fa_archive_name;
273 $this->group = $row->fa_storage_group;
274 $this->key = $row->fa_storage_key;
275 $this->size = $row->fa_size;
276 $this->bits = $row->fa_bits;
277 $this->width = $row->fa_width;
278 $this->height = $row->fa_height;
279 $this->metadata = $row->fa_metadata;
280 $this->mime =
"$row->fa_major_mime/$row->fa_minor_mime";
281 $this->media_type = $row->fa_media_type;
282 $this->description = MediaWikiServices::getInstance()->getCommentStore()
285 $this->user =
User::newFromAnyId( $row->fa_user, $row->fa_user_text, $row->fa_actor );
286 $this->timestamp = $row->fa_timestamp;
287 $this->deleted = $row->fa_deleted;
288 if ( isset( $row->fa_sha1 ) ) {
289 $this->sha1 = $row->fa_sha1;
294 if ( !$this->title ) {
295 $this->title = Title::makeTitleSafe(
NS_FILE, $row->fa_name );
305 if ( !$this->title ) {
317 if ( $this->name ===
false ) {
433 if ( !isset( $this->handler ) ) {
450 if ( $this->
getHandler() && $this->handler->isMultiPage( $this ) ) {
452 $this->
pageCount = $this->handler->pageCount( $this );
509 if (
$type ===
'object' ) {
511 } elseif (
$type ===
'text' ) {
512 return $this->user ? $this->user->
getName() :
'';
513 } elseif (
$type ===
'id' ) {
514 return $this->user ? $this->user->getId() : 0;
527 if ( $this->
isDeleted( File::DELETED_COMMENT ) ) {
549 return $this->
getUser(
'text' );
582 return ( $this->deleted & $field ) == $field;
597 wfDeprecated( __METHOD__ .
' without passing a $user parameter',
'1.35' );
602 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 $function is deprecated.
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
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this FileStore image file,...
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.
getDescription()
Return upload description.
int $id
Filearchive row ID.
getRawUser()
Return the user ID of the uploader.
__construct( $title, $id=0, $key='', $sha1='')
Stable to call.
load()
Loads a file object from the filearchive table Stable to override.
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 Stable to override.
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)
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.
string $metadata
Metadata string.
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.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getName()
Get the user name, or the IP of an anonymous user.
static newFromAnyId( $userId, $userName, $actorId, $dbDomain=false)
Static factory method for creation from an ID, name, and/or actor ID.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.