109 $this->title =
false;
111 $this->group =
'deleted';
117 $this->metadata =
'';
118 $this->mime =
"unknown/unknown";
119 $this->media_type =
'';
120 $this->description =
'';
122 $this->timestamp =
null;
124 $this->dataLoaded =
false;
129 $this->title = File::normalizeTitle(
$title,
'exception' );
146 throw new MWException(
"No specifications provided to ArchivedFile constructor." );
156 if ( $this->dataLoaded ) {
161 if ( $this->
id > 0 ) {
168 if ( $this->title ) {
169 $conds[
'fa_name'] = $this->title->getDBkey();
175 if ( $conds === [] ) {
176 throw new MWException(
"No specific information for retrieving archived file" );
179 if ( !$this->title || $this->title->getNamespace() ==
NS_FILE ) {
180 $this->dataLoaded =
true;
183 $row =
$dbr->selectRow(
184 $fileQuery[
'tables'],
185 $fileQuery[
'fields'],
188 [
'ORDER BY' =>
'fa_timestamp DESC' ],
199 throw new MWException(
'This title does not correspond to an image page.' );
214 $file->loadFromRow( $row );
229 $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin(
'fa_description' );
230 $actorQuery = ActorMigration::newMigration()->getJoin(
'fa_user' );
232 'tables' => [
'filearchive' ] + $commentQuery[
'tables'] + $actorQuery[
'tables'],
249 'fa_deleted_timestamp',
251 ] + $commentQuery[
'fields'] + $actorQuery[
'fields'],
252 'joins' => $commentQuery[
'joins'] + $actorQuery[
'joins'],
263 $this->
id = intval( $row->fa_id );
264 $this->name = $row->fa_name;
265 $this->archive_name = $row->fa_archive_name;
266 $this->group = $row->fa_storage_group;
267 $this->key = $row->fa_storage_key;
268 $this->size = $row->fa_size;
269 $this->bits = $row->fa_bits;
270 $this->width = $row->fa_width;
271 $this->height = $row->fa_height;
272 $this->metadata = $row->fa_metadata;
273 $this->mime =
"$row->fa_major_mime/$row->fa_minor_mime";
274 $this->media_type = $row->fa_media_type;
275 $this->description = MediaWikiServices::getInstance()->getCommentStore()
278 $this->user = User::newFromAnyId( $row->fa_user, $row->fa_user_text, $row->fa_actor );
279 $this->timestamp = $row->fa_timestamp;
280 $this->deleted = $row->fa_deleted;
281 if ( isset( $row->fa_sha1 ) ) {
282 $this->sha1 = $row->fa_sha1;
287 if ( !$this->title ) {
288 $this->title = Title::makeTitleSafe(
NS_FILE, $row->fa_name );
298 if ( !$this->title ) {
310 if ( $this->name ===
false ) {
426 if ( !isset( $this->handler ) ) {
442 if ( $this->
getHandler() && $this->handler->isMultiPage( $this ) ) {
444 $this->
pageCount = $this->handler->pageCount( $this );
501 if (
$type ===
'object' ) {
503 } elseif (
$type ===
'text' ) {
504 return $this->user ? $this->user->
getName() :
'';
505 } elseif (
$type ===
'id' ) {
506 return $this->user ? $this->user->getId() : 0;
519 if ( $this->
isDeleted( File::DELETED_COMMENT ) ) {
541 return $this->
getUser(
'text' );
574 return ( $this->deleted & $field ) == $field;
588 return Revision::userCanBitfield( $this->deleted, $field,
$user,
$title ?: null );
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
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='')
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)
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.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.