47 # The null default value is only here to avoid an E_STRICT
48 if (
$time === null ) {
49 throw new MWException( __METHOD__ .
' got null for $time parameter' );
62 return new self(
$title,
$repo, null, $archiveName );
72 $file =
new self(
$title,
$repo, null, $row->oi_archive_name );
73 $file->loadFromRow( $row,
'oi_' );
91 $conds = [
'oi_sha1' =>
$sha1 ];
96 $row =
$dbr->selectRow(
'oldimage', self::selectFields(), $conds, __METHOD__ );
98 return self::newFromRow( $row,
$repo );
138 $this->requestedTime =
$time;
139 $this->archive_name = $archiveName;
140 if ( is_null(
$time ) && is_null( $archiveName ) ) {
141 throw new MWException( __METHOD__ .
': must specify at least one of $time or $archiveName' );
156 if ( !isset( $this->archive_name ) ) {
178 $this->dataLoaded =
true;
181 ? $this->repo->getMasterDB()
182 : $this->repo->getSlaveDB();
184 $conds = [
'oi_name' => $this->
getName() ];
185 if ( is_null( $this->requestedTime ) ) {
188 $conds[
'oi_timestamp'] =
$dbr->timestamp( $this->requestedTime );
191 $conds, __METHOD__, [
'ORDER BY' =>
'oi_timestamp DESC' ] );
195 $this->fileExists =
false;
205 $this->extraDataLoaded =
true;
206 $dbr = $this->repo->getSlaveDB();
207 $conds = [
'oi_name' => $this->
getName() ];
208 if ( is_null( $this->requestedTime ) ) {
211 $conds[
'oi_timestamp'] =
$dbr->timestamp( $this->requestedTime );
215 $conds, __METHOD__, [
'ORDER BY' =>
'oi_timestamp DESC' ] );
218 $dbr = $this->repo->getMasterDB();
220 $conds, __METHOD__, [
'ORDER BY' =>
'oi_timestamp DESC' ] );
228 throw new MWException(
"Could not find data for image '{$this->archive_name}'." );
238 $fields = parent::getCacheFields( $prefix );
239 $fields[] = $prefix .
'archive_name';
240 $fields[] = $prefix .
'deleted';
262 # Don't destroy file info of missing files
263 if ( !$this->fileExists ) {
264 wfDebug( __METHOD__ .
": file does not exist, aborting\n" );
269 $dbw = $this->repo->getMasterDB();
270 list( $major, $minor ) = self::splitMime( $this->mime );
272 wfDebug( __METHOD__ .
': upgrading ' . $this->archive_name .
" to the current schema\n" );
273 $dbw->update(
'oldimage',
275 'oi_size' => $this->size,
276 'oi_width' => $this->
width,
277 'oi_height' => $this->height,
278 'oi_bits' => $this->bits,
279 'oi_media_type' => $this->media_type,
280 'oi_major_mime' => $major,
281 'oi_minor_mime' => $minor,
282 'oi_metadata' => $this->metadata,
283 'oi_sha1' => $this->sha1,
286 'oi_archive_name' => $this->archive_name ],
299 return ( $this->deleted & $field ) == $field;
340 $dstRel =
'archive/' . $this->
getHashPath() . $archiveName;
345 $status->fatal(
'filenotfound', $srcPath );
365 $dbw = $this->repo->getMasterDB();
367 $dstPath = $this->repo->getZonePath(
'public' ) .
'/' . $this->
getRel();
368 $props = $this->repo->getFileProps( $dstPath );
369 if ( !$props[
'fileExists'] ) {
373 $dbw->insert(
'oldimage',
376 'oi_archive_name' => $archiveName,
377 'oi_size' => $props[
'size'],
378 'oi_width' => intval( $props[
'width'] ),
379 'oi_height' => intval( $props[
'height'] ),
380 'oi_bits' => $props[
'bits'],
381 'oi_timestamp' => $dbw->timestamp(
$timestamp ),
383 'oi_user' =>
$user->getId(),
384 'oi_user_text' =>
$user->getName(),
385 'oi_metadata' => $props[
'metadata'],
386 'oi_media_type' => $props[
'media_type'],
387 'oi_major_mime' => $props[
'major_mime'],
388 'oi_minor_mime' => $props[
'minor_mime'],
389 'oi_sha1' => $props[
'sha1'],
404 if ( $archiveName ===
'' || !is_string( $archiveName ) ) {
407 return parent::exists();
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
loadFromRow($row, $prefix= 'img_')
Load file metadata from a DB result row.
static newFromArchiveName($title, $repo, $archiveName)
unlock()
Decrement the lock reference count and end the atomic section if it reaches zero. ...
string $sha1
SHA-1 base 36 content hash.
getName()
Return the name of this file.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
string $name
The name of a file from its title object.
getCacheFields($prefix= 'img_')
unprefixRow($row, $prefix= 'img_')
int $user
User ID of uploader.
recordOldUpload($srcPath, $archiveName, $timestamp, $comment, $user)
Record a file upload in the oldimage table, without adding log entries.
static newFromTitle($title, $repo, $time=null)
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.
exists()
If archive name is an empty string, then file does not "exist".
Class to represent a file in the oldimage table.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
userCan($field, User $user=null)
Determine if the current user is allowed to view a particular field of this image file...
publishTo($src, $dstRel, $flags=0, array $options=[])
Move or copy a file to a specified location.
static selectFields()
Fields in the oldimage table.
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
uploadOld($srcPath, $archiveName, $timestamp, $comment, $user)
Upload a file directly into archive.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static newFromRow($row, $repo)
string $requestedTime
Timestamp.
string $archive_name
Archive name.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
lock()
Start an atomic DB section and lock the image for update or increments a reference counter if the loc...
__construct($title, $repo, $time, $archiveName)
int $deleted
Bitfield akin to rev_deleted.
Class to represent a local file in the wiki's own database.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
static newFromKey($sha1, $repo, $timestamp=false)
Create a OldLocalFile from a SHA-1 key Do not call this except from inside a repo class...
string $timestamp
Upload timestamp.
getLazyCacheFields($prefix= 'img_')
loadFromFile()
Load metadata from the file itself.
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, if it's marked as deleted.
load($flags=0)
Load file metadata from cache or DB, unless already loaded.
getVisibility()
Returns bitfield value.
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
see documentation in includes Linker php for Linker::makeImageLink & $time
loadExtraFromDB()
Load lazy file metadata from the DB.