Go to the documentation of this file.
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__ );
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->getReplicaDB();
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;
203 $this->extraDataLoaded =
true;
204 $dbr = $this->repo->getReplicaDB();
205 $conds = [
'oi_name' => $this->
getName() ];
206 if ( is_null( $this->requestedTime ) ) {
209 $conds[
'oi_timestamp'] =
$dbr->timestamp( $this->requestedTime );
213 $conds, __METHOD__, [
'ORDER BY' =>
'oi_timestamp DESC' ] );
216 $dbr = $this->repo->getMasterDB();
218 $conds, __METHOD__, [
'ORDER BY' =>
'oi_timestamp DESC' ] );
226 throw new MWException(
"Could not find data for image '{$this->archive_name}'." );
235 $fields = parent::getCacheFields( $prefix );
236 $fields[] = $prefix .
'archive_name';
237 $fields[] = $prefix .
'deleted';
259 # Don't destroy file info of missing files
260 if ( !$this->fileExists ) {
261 wfDebug( __METHOD__ .
": file does not exist, aborting\n" );
266 $dbw = $this->repo->getMasterDB();
269 wfDebug( __METHOD__ .
': upgrading ' . $this->archive_name .
" to the current schema\n" );
270 $dbw->update(
'oldimage',
272 'oi_size' => $this->size,
273 'oi_width' => $this->
width,
274 'oi_height' => $this->height,
275 'oi_bits' => $this->bits,
276 'oi_media_type' => $this->media_type,
277 'oi_major_mime' => $major,
278 'oi_minor_mime' => $minor,
279 'oi_metadata' => $this->metadata,
280 'oi_sha1' => $this->sha1,
283 'oi_archive_name' => $this->archive_name ],
296 return ( $this->deleted & $field ) == $field;
337 $dstRel =
'archive/' . $this->
getHashPath() . $archiveName;
342 $status->fatal(
'filenotfound', $srcPath );
362 $dbw = $this->repo->getMasterDB();
364 $dstPath = $this->repo->getZonePath(
'public' ) .
'/' . $this->
getRel();
365 $props = $this->repo->getFileProps( $dstPath );
366 if ( !$props[
'fileExists'] ) {
370 $dbw->insert(
'oldimage',
373 'oi_archive_name' => $archiveName,
374 'oi_size' => $props[
'size'],
375 'oi_width' => intval( $props[
'width'] ),
376 'oi_height' => intval( $props[
'height'] ),
377 'oi_bits' => $props[
'bits'],
378 'oi_timestamp' => $dbw->timestamp(
$timestamp ),
379 'oi_description' => $comment,
380 'oi_user' =>
$user->getId(),
381 'oi_user_text' =>
$user->getName(),
382 'oi_metadata' => $props[
'metadata'],
383 'oi_media_type' => $props[
'media_type'],
384 'oi_major_mime' => $props[
'major_mime'],
385 'oi_minor_mime' => $props[
'minor_mime'],
386 'oi_sha1' => $props[
'sha1'],
401 if ( $archiveName ===
'' || !is_string( $archiveName ) ) {
404 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.
uploadOld( $srcPath, $archiveName, $timestamp, $comment, $user)
Upload a file directly into archive.
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,...
getVisibility()
Returns bitfield value.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
int $user
User ID of uploader.
exists()
If archive name is an empty string, then file does not "exist".
static selectFields()
Fields in the oldimage table.
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.
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
string $requestedTime
Timestamp.
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.
see documentation in includes Linker php for Linker::makeImageLink & $time
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
__construct( $title, $repo, $time, $archiveName)
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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
Class to represent a local file in the wiki's own database.
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_')
getLazyCacheFields( $prefix='img_')
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,...
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
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.
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.
it s the revision text itself In either if gzip is the revision text is gzipped $flags