Go to the documentation of this file.
49 # The null default value is only here to avoid an E_STRICT
50 if ( $time ===
null ) {
51 throw new MWException( __METHOD__ .
' got null for $time parameter' );
64 return new static(
$title,
$repo,
null, $archiveName );
75 $file->loadFromRow( $row,
'oi_' );
93 $conds = [
'oi_sha1' =>
$sha1 ];
98 $fileQuery = static::getQueryInfo();
99 $row =
$dbr->selectRow(
100 $fileQuery[
'tables'], $fileQuery[
'fields'], $conds, __METHOD__, [], $fileQuery[
'joins']
103 return static::newFromRow( $row,
$repo );
121 $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin(
'oi_description' );
124 'tables' => [
'oldimage' ] + $commentQuery[
'tables'] + $actorQuery[
'tables'],
138 ] + $commentQuery[
'fields'] + $actorQuery[
'fields'],
139 'joins' => $commentQuery[
'joins'] + $actorQuery[
'joins'],
142 if ( in_array(
'omit-nonlazy', $options,
true ) ) {
146 if ( !in_array(
'omit-lazy', $options,
true ) ) {
148 $ret[
'fields'][] =
'oi_metadata';
163 $this->requestedTime = $time;
164 $this->archive_name = $archiveName;
165 if ( is_null( $time ) && is_null( $archiveName ) ) {
166 throw new MWException( __METHOD__ .
': must specify at least one of $time or $archiveName' );
181 if ( !isset( $this->archive_name ) ) {
203 $this->dataLoaded =
true;
205 $dbr = ( $flags & self::READ_LATEST )
206 ? $this->repo->getMasterDB()
207 : $this->repo->getReplicaDB();
209 $conds = [
'oi_name' => $this->
getName() ];
210 if ( is_null( $this->requestedTime ) ) {
213 $conds[
'oi_timestamp'] =
$dbr->timestamp( $this->requestedTime );
215 $fileQuery = static::getQueryInfo();
216 $row =
$dbr->selectRow(
217 $fileQuery[
'tables'],
218 $fileQuery[
'fields'],
221 [
'ORDER BY' =>
'oi_timestamp DESC' ],
227 $this->fileExists =
false;
235 $this->extraDataLoaded =
true;
236 $dbr = $this->repo->getReplicaDB();
237 $conds = [
'oi_name' => $this->
getName() ];
238 if ( is_null( $this->requestedTime ) ) {
241 $conds[
'oi_timestamp'] =
$dbr->timestamp( $this->requestedTime );
243 $fileQuery = static::getQueryInfo( [
'omit-nonlazy' ] );
245 $row =
$dbr->selectRow(
246 $fileQuery[
'tables'],
247 $fileQuery[
'fields'],
250 [
'ORDER BY' =>
'oi_timestamp DESC' ],
255 $dbr = $this->repo->getMasterDB();
256 $row =
$dbr->selectRow(
257 $fileQuery[
'tables'],
258 $fileQuery[
'fields'],
261 [
'ORDER BY' =>
'oi_timestamp DESC' ],
268 $this->
$name = $value;
271 throw new MWException(
"Could not find data for image '{$this->archive_name}'." );
277 $fields = parent::getCacheFields( $prefix );
278 $fields[] = $prefix .
'archive_name';
279 $fields[] = $prefix .
'deleted';
301 # Don't destroy file info of missing files
302 if ( !$this->fileExists ) {
303 wfDebug( __METHOD__ .
": file does not exist, aborting\n" );
308 $dbw = $this->repo->getMasterDB();
311 wfDebug( __METHOD__ .
': upgrading ' . $this->archive_name .
" to the current schema\n" );
312 $dbw->update(
'oldimage',
314 'oi_size' => $this->size,
315 'oi_width' => $this->width,
316 'oi_height' => $this->height,
317 'oi_bits' => $this->bits,
318 'oi_media_type' => $this->media_type,
319 'oi_major_mime' => $major,
320 'oi_minor_mime' => $minor,
321 'oi_metadata' => $this->metadata,
322 'oi_sha1' => $this->sha1,
325 'oi_archive_name' => $this->archive_name ],
338 return ( $this->deleted & $field ) == $field;
384 $status->fatal(
'filenotfound', $srcPath );
403 $dbw = $this->repo->getMasterDB();
405 $dstPath = $this->repo->getZonePath(
'public' ) .
'/' . $this->
getRel();
406 $props = $this->repo->getFileProps( $dstPath );
407 if ( !$props[
'fileExists'] ) {
411 $commentFields = MediaWikiServices::getInstance()->getCommentStore()
412 ->insert( $dbw,
'oi_description', $comment );
414 $dbw->insert(
'oldimage',
417 'oi_archive_name' => $archiveName,
418 'oi_size' => $props[
'size'],
419 'oi_width' => intval( $props[
'width'] ),
420 'oi_height' => intval( $props[
'height'] ),
421 'oi_bits' => $props[
'bits'],
422 'oi_timestamp' => $dbw->timestamp(
$timestamp ),
423 'oi_metadata' => $props[
'metadata'],
424 'oi_media_type' => $props[
'media_type'],
425 'oi_major_mime' => $props[
'major_mime'],
426 'oi_minor_mime' => $props[
'minor_mime'],
427 'oi_sha1' => $props[
'sha1'],
428 ] + $commentFields + $actorFields, __METHOD__
443 if ( $archiveName ===
'' || !is_string( $archiveName ) ) {
446 return parent::exists();
unprefixRow( $row, $prefix='img_')
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
static newFromKey( $sha1, $repo, $timestamp=false)
Create a OldLocalFile from a SHA-1 key Do not call this except from inside a repo class.
unlock()
Decrement the lock reference count and end the atomic section if it reaches zero.
static userCanBitfield( $bitfield, $field, User $user=null, Title $title=null)
Determine if the current user is allowed to view a particular field of this revision,...
static getQueryInfo(array $options=[])
Return the tables, fields, and join conditions to be selected to create a new oldlocalfile object.
getVisibility()
Returns bitfield value.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
exists()
If archive name is an empty string, then file does not "exist".
string $sha1
SHA-1 base 36 content hash.
static splitMime( $mime)
Split an internet media type into its two components; if not a two-part name, set the minor type to '...
recordOldUpload( $srcPath, $archiveName, $timestamp, $comment, $user)
Record a file upload in the oldimage table, without adding log entries.
getArchiveRel( $suffix=false)
Get the path of an archived file relative to the public zone root.
static newMigration()
Static constructor.
publishTo( $src, $dstRel, $flags=0, array $options=[])
Move or copy a file to a specified location.
string $archive_name
Archive name.
upgradeRow()
Fix assorted version-related problems with the image row by reloading it from the file.
loadFromRow( $row, $prefix='img_')
Load file metadata from a DB result row.
int $deleted
Bitfield akin to rev_deleted.
loadExtraFromDB()
Load lazy file metadata from the DB.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
__construct( $title, $repo, $time, $archiveName)
uploadOld( $srcPath, $timestamp, $comment, $user)
Upload a file directly into archive.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Class to represent a local file in the wiki's own database.
string int $requestedTime
Timestamp.
lock()
Start an atomic DB section and lock the image for update or increments a reference counter if the loc...
load( $flags=0)
Load file metadata from cache or DB, unless already loaded.
getName()
Return the name of this file.
string $timestamp
Upload timestamp.
static newFromRow( $row, $repo)
getCacheFields( $prefix='img_')
Returns the list of object properties that are included as-is in the cache.Must be the empty string s...
static newFromTitle( $title, $repo, $time=null)
loadFromFile()
Load metadata from the file itself.
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this image file,...
string $name
The name of a file from its title object.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Class to represent a file in the oldimage table.
static newFromArchiveName( $title, $repo, $archiveName)
loadFromDB( $flags=0)
Load file metadata from the DB.