MediaWiki
REL1_22
|
Class to represent a local file in the wiki's own database. More...
Public Member Functions | |
__construct ($title, $repo) | |
Constructor. | |
decodeRow ($row, $prefix= 'img_') | |
Decode a row from the database (either object or array) to an array with timestamps and MIME types decoded, and the field prefix removed. | |
delete ($reason, $suppress=false) | |
Delete all versions of the file. | |
deleteOld ($archiveName, $reason, $suppress=false) | |
Delete an old version of the file. | |
exists () | |
canRender inherited | |
getBitDepth () | |
getCacheFields ($prefix= 'img_') | |
getCacheKey () | |
Get the memcached key for the main data for this file, or false if there is no access to the shared cache. | |
getDescription ($audience=self::FOR_PUBLIC, User $user=null) | |
getDescriptionText ($lang=null) | |
Get the HTML text of the description page This is not used by ImagePage for local files, since (among other things) it skips the parser cache. | |
getDescriptionUrl () | |
isMultipage inherited | |
getHeight ($page=1) | |
Return the height of the image. | |
getHistory ($limit=null, $start=null, $end=null, $inc=true) | |
purgeDescription inherited | |
getLazyCacheFields ($prefix= 'img_') | |
getMediaType () | |
Return the type of the media in the file. | |
getMetadata () | |
Get handler-specific metadata. | |
getMimeType () | |
Returns the mime type of the file. | |
getSha1 () | |
getSize () | |
Return the size of the image file, in bytes. | |
getThumbnails ($archiveName=false) | |
getHandler inherited | |
getTimestamp () | |
getUpgraded () | |
getUser ($type= 'text') | |
Returns ID or name of user who uploaded the file. | |
getWidth ($page=1) | |
Return the width of the image. | |
isCacheable () | |
isMissing () | |
splitMime inherited | |
load ($flags=0) | |
Load file metadata from cache or DB, unless already loaded. | |
loadFromCache () | |
Try to load file metadata from memcached. | |
loadFromDB () | |
Load file metadata from the DB. | |
loadFromFile () | |
Load metadata from the file itself. | |
loadFromRow ($row, $prefix= 'img_') | |
Load file metadata from a DB result row. | |
lock () | |
Start a transaction and lock the image for update Increments a reference counter if the lock is already held. | |
maybeUpgradeRow () | |
Upgrade a row if it needs it. | |
migrateThumbFile ($thumbName) | |
getTransformScript inherited | |
move ($target) | |
getLinksTo inherited | |
nextHistoryLine () | |
Return the history of this file, line by line. | |
publish ($srcPath, $flags=0, array $options=array()) | |
Move or copy a file to its public location. | |
publishTo ($srcPath, $dstRel, $flags=0, array $options=array()) | |
Move or copy a file to a specified location. | |
purgeCache ($options=array()) | |
Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid. | |
purgeHistory () | |
Purge the shared history (OldLocalFile) cache. | |
purgeMetadataCache () | |
Refresh metadata in memcached, but don't touch thumbnails or squid. | |
purgeOldThumbnails ($archiveName) | |
Delete cached transformed files for an archived version only. | |
purgeThumbnails ($options=array()) | |
Delete cached transformed files for the current version only. | |
recordUpload ($oldver, $desc, $license= '', $copyStatus= '', $source= '', $watch=false, $timestamp=false, User $user=null) | |
Record a file upload in the upload log and the image table. | |
recordUpload2 ($oldver, $comment, $pageText, $props=false, $timestamp=false, $user=null) | |
Record a file upload in the upload log and the image table. | |
resetHistory () | |
Reset the history pointer to the first element of the history. | |
restore ($versions=array(), $unsuppress=false) | |
Restore all or specified deleted revisions to the given file. | |
saveToCache () | |
Save the file metadata to memcached. | |
setProps ($info) | |
Set properties in this object to be equal to those given in the associative array $info. | |
unlock () | |
Decrement the lock reference count. | |
unlockAndRollback () | |
Roll back the DB transaction and mark the image unlocked. | |
upgradeRow () | |
Fix assorted version-related problems with the image row by reloading it from the file. | |
upload ($srcPath, $comment, $pageText, $flags=0, $props=false, $timestamp=false, $user=null) | |
getHashPath inherited | |
Static Public Member Functions | |
static | newFromKey ($sha1, $repo, $timestamp=false) |
Create a LocalFile from a SHA-1 key Do not call this except from inside a repo class. | |
static | newFromRow ($row, $repo) |
Create a LocalFile from a title Do not call this except from inside a repo class. | |
static | newFromTitle ($title, $repo, $unused=null) |
Create a LocalFile from a title Do not call this except from inside a repo class. | |
static | selectFields () |
Fields in the image table. | |
Public Attributes | |
$attr | |
$bits | |
$dataLoaded | |
$deleted | |
$description | |
$extraDataLoaded | |
$fileExists | |
#@+ | |
$historyLine | |
$historyRes | |
$locked | |
$lockedOwnTrx | |
$major_mime | |
$media_type | |
$metadata | |
$mime | |
$minor_mime | |
$missing | |
LocalRepo | $repo |
#@- | |
$sha1 | |
$size | |
$timestamp | |
$upgraded | |
$user | |
$user_text | |
$width | |
const | CACHE_FIELD_MAX_LEN = 1000 |
const | LOAD_ALL = 1 |
Protected Member Functions | |
loadExtraFromDB () | |
Load lazy file metadata from the DB. | |
purgeThumbList ($dir, $files) | |
Delete a list of thumbnails visible at urls. | |
readOnlyFatalStatus () | |
unprefixRow ($row, $prefix= 'img_') | |
Protected Attributes | |
$repoClass = 'LocalRepo' | |
Required Repository class type. |
Class to represent a local file in the wiki's own database.
Provides methods to retrieve paths (physical, logical, URL), to generate image thumbnails or for uploading.
Note that only the repo object knows what its file class is called. You should never name a file class explictly outside of the repo class. Instead use the repo's factory functions to generate file objects, for example:
RepoGroup::singleton()->getLocalRepo()->newFile( $title );
The convenience functions wfLocalFile() and wfFindFile() should be sufficient in most cases.
Definition at line 46 of file LocalFile.php.
LocalFile::__construct | ( | $ | title, |
$ | repo | ||
) |
Constructor.
Do not call this except from inside a repo class.
Reimplemented from File.
Definition at line 174 of file LocalFile.php.
LocalFile::decodeRow | ( | $ | row, |
$ | prefix = 'img_' |
||
) |
Decode a row from the database (either object or array) to an array with timestamps and MIME types decoded, and the field prefix removed.
$row | |
$prefix | string |
MWException |
Definition at line 420 of file LocalFile.php.
LocalFile::delete | ( | $ | reason, |
$ | suppress = false |
||
) |
Delete all versions of the file.
Moves the files into an archive directory (or deletes them) and removes the database rows.
Cache purging is done; logging is caller's responsibility.
$reason | |
$suppress |
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1549 of file LocalFile.php.
LocalFile::deleteOld | ( | $ | archiveName, |
$ | reason, | ||
$ | suppress = false |
||
) |
Delete an old version of the file.
Moves the file into an archive directory (or deletes it) and removes the database row.
Cache purging is done; logging is caller's responsibility.
$archiveName | String |
$reason | String |
$suppress | Boolean |
MWException | or FSException on database or file store failure |
Definition at line 1607 of file LocalFile.php.
canRender inherited
mustRender inherited allowInlineDisplay inherited isSafeFile inherited isTrustedFile inherited Returns true if the file exists on disk.
Reimplemented from File.
Definition at line 729 of file LocalFile.php.
Referenced by OldLocalFile\isVisible().
LocalFile::getCacheFields | ( | $ | prefix = 'img_' | ) |
$prefix | string |
Reimplemented in OldLocalFile.
Definition at line 289 of file LocalFile.php.
Get the memcached key for the main data for this file, or false if there is no access to the shared cache.
Reimplemented in OldLocalFile.
Definition at line 192 of file LocalFile.php.
LocalFile::getDescription | ( | $ | audience = self::FOR_PUBLIC , |
User $ | user = null |
||
) |
LocalFile::getDescriptionText | ( | $ | lang = null | ) |
Get the HTML text of the description page This is not used by ImagePage for local files, since (among other things) it skips the parser cache.
$lang | Language What language to get description in (Optional) |
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1691 of file LocalFile.php.
isMultipage inherited
pageCount inherited scaleHeight inherited getImageSize inherited Get the URL of the file description page.
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1679 of file LocalFile.php.
LocalFile::getHeight | ( | $ | page = 1 | ) |
Return the height of the image.
$page | int |
Reimplemented from File.
Definition at line 637 of file LocalFile.php.
LocalFile::getHistory | ( | $ | limit = null , |
$ | start = null , |
||
$ | end = null , |
||
$ | inc = true |
||
) |
purgeDescription inherited
purgeEverything inherited
$limit | null |
$start | null |
$end | null |
$inc | bool |
Reimplemented from File.
Definition at line 954 of file LocalFile.php.
LocalFile::getLazyCacheFields | ( | $ | prefix = 'img_' | ) |
Definition at line 312 of file LocalFile.php.
Referenced by OldLocalFile\loadExtraFromDB().
Return the type of the media in the file.
Use the value returned by this function with the MEDIATYPE_xxx constants.
Reimplemented from File.
Definition at line 714 of file LocalFile.php.
Get handler-specific metadata.
Reimplemented from File.
Definition at line 678 of file LocalFile.php.
Returns the mime type of the file.
Reimplemented from File.
Definition at line 704 of file LocalFile.php.
Return the size of the image file, in bytes.
Reimplemented from File.
Definition at line 695 of file LocalFile.php.
LocalFile::getThumbnails | ( | $ | archiveName = false | ) |
getHandler inherited
iconThumb inherited getLastError inherited Get all thumbnail names previously generated for this file
string | bool | $archiveName | Name of an archive file, default false |
Definition at line 783 of file LocalFile.php.
Definition at line 504 of file LocalFile.php.
LocalFile::getUser | ( | $ | type = 'text' | ) |
Returns ID or name of user who uploaded the file.
string | $type | 'text' or 'id' |
Reimplemented from File.
Definition at line 664 of file LocalFile.php.
LocalFile::getWidth | ( | $ | page = 1 | ) |
Return the width of the image.
$page | int |
Reimplemented from File.
Definition at line 610 of file LocalFile.php.
Reimplemented from File.
Definition at line 1756 of file LocalFile.php.
splitMime inherited
getName inherited getTitle inherited getURL inherited getViewURL inherited getPath inherited isVisible inhereted
Reimplemented from File.
Definition at line 596 of file LocalFile.php.
LocalFile::load | ( | $ | flags = 0 | ) |
Load file metadata from cache or DB, unless already loaded.
integer | $flags |
Definition at line 463 of file LocalFile.php.
Referenced by OldLocalFile\getArchiveName(), OldLocalFile\getVisibility(), OldLocalFile\isDeleted(), and OldLocalFile\userCan().
LocalFile::loadExtraFromDB | ( | ) | [protected] |
Load lazy file metadata from the DB.
This covers fields that are sometimes not cached.
Reimplemented in OldLocalFile.
Definition at line 360 of file LocalFile.php.
Try to load file metadata from memcached.
Returns true on success.
Definition at line 202 of file LocalFile.php.
Load file metadata from the DB.
Reimplemented in OldLocalFile.
Definition at line 334 of file LocalFile.php.
Load metadata from the file itself.
Definition at line 280 of file LocalFile.php.
Referenced by OldLocalFile\upgradeRow().
LocalFile::loadFromRow | ( | $ | row, |
$ | prefix = 'img_' |
||
) |
Load file metadata from a DB result row.
Definition at line 445 of file LocalFile.php.
Referenced by OldLocalFile\loadFromDB().
LocalFile::lock | ( | ) |
Start a transaction and lock the image for update Increments a reference counter if the lock is already held.
Definition at line 1768 of file LocalFile.php.
Referenced by OldLocalFile\uploadOld().
Upgrade a row if it needs it.
Definition at line 479 of file LocalFile.php.
LocalFile::migrateThumbFile | ( | $ | thumbName | ) |
getTransformScript inherited
getUnscaledThumb inherited thumbName inherited createThumb inherited transform inherited Fix thumbnail files from 1.4 or before, with extreme prejudice
Enabling this code results in a serious RTT regression for wikis without 404 handling.
Reimplemented from File.
Definition at line 746 of file LocalFile.php.
LocalFile::move | ( | $ | target | ) |
getLinksTo inherited
getExifData inherited isLocal inherited wasDeleted inherited Move file to the new title
Move current, old version and all thumbnails to the new filename. Old file is deleted.
Cache purging is done; checks for validity and logging are caller's responsibility
$target | Title New file name |
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1495 of file LocalFile.php.
static LocalFile::newFromKey | ( | $ | sha1, |
$ | repo, | ||
$ | timestamp = false |
||
) | [static] |
Create a LocalFile from a SHA-1 key Do not call this except from inside a repo class.
string | $sha1 | base-36 SHA-1 |
$repo | LocalRepo | |
string | bool | $timestamp | MW_timestamp (optional) |
Reimplemented in OldLocalFile.
Definition at line 131 of file LocalFile.php.
static LocalFile::newFromRow | ( | $ | row, |
$ | repo | ||
) | [static] |
Create a LocalFile from a title Do not call this except from inside a repo class.
$row | |
$repo |
Reimplemented in OldLocalFile, and ForeignDBFile.
Definition at line 113 of file LocalFile.php.
static LocalFile::newFromTitle | ( | $ | title, |
$ | repo, | ||
$ | unused = null |
||
) | [static] |
Create a LocalFile from a title Do not call this except from inside a repo class.
Note: $unused param is only here to avoid an E_STRICT
$title | |
$repo | |
$unused |
Reimplemented in OldLocalFile, and ForeignDBFile.
Definition at line 100 of file LocalFile.php.
Return the history of this file, line by line.
starts with current version, then old versions. uses $this->historyLine to check which line to return: 0 return line for current version 1 query for old versions, return first one 2, ... return next old version from above query
Reimplemented from File.
Definition at line 1009 of file LocalFile.php.
LocalFile::publish | ( | $ | srcPath, |
$ | flags = 0 , |
||
array $ | options = array() |
||
) |
Move or copy a file to its public location.
If a file exists at the destination, move it to an archive. Returns a FileRepoStatus object with the archive name in the "value" member on success.
The archive name should be passed through to recordUpload for database registration.
string | $srcPath | local filesystem path to the source image |
$flags | Integer: a bitwise combination of: File::DELETE_SOURCE Delete the source file, i.e. move rather than copy | |
array | $options | Optional additional parameters |
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1436 of file LocalFile.php.
LocalFile::publishTo | ( | $ | srcPath, |
$ | dstRel, | ||
$ | flags = 0 , |
||
array $ | options = array() |
||
) |
Move or copy a file to a specified location.
Returns a FileRepoStatus object with the archive name in the "value" member on success.
The archive name should be passed through to recordUpload for database registration.
string | $srcPath | local filesystem path to the source image |
string | $dstRel | target relative path |
$flags | Integer: a bitwise combination of: File::DELETE_SOURCE Delete the source file, i.e. move rather than copy | |
array | $options | Optional additional parameters |
Definition at line 1455 of file LocalFile.php.
Referenced by OldLocalFile\uploadOld().
LocalFile::purgeCache | ( | $ | options = array() | ) |
Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid.
Array | $options | An array potentially with the key forThumbRefresh. |
Reimplemented from File.
Definition at line 834 of file LocalFile.php.
Purge the shared history (OldLocalFile) cache.
Definition at line 816 of file LocalFile.php.
Refresh metadata in memcached, but don't touch thumbnails or squid.
Definition at line 805 of file LocalFile.php.
LocalFile::purgeOldThumbnails | ( | $ | archiveName | ) |
Delete cached transformed files for an archived version only.
string | $archiveName | name of the archived file |
Definition at line 851 of file LocalFile.php.
LocalFile::purgeThumbList | ( | $ | dir, |
$ | files | ||
) | [protected] |
Delete a list of thumbnails visible at urls.
string | $dir | base dir of the files. |
array | $files | of strings: relative filenames (to $dir) |
Definition at line 920 of file LocalFile.php.
LocalFile::purgeThumbnails | ( | $ | options = array() | ) |
Delete cached transformed files for the current version only.
Definition at line 878 of file LocalFile.php.
LocalFile::readOnlyFatalStatus | ( | ) | [protected] |
Definition at line 1821 of file LocalFile.php.
LocalFile::recordUpload | ( | $ | oldver, |
$ | desc, | ||
$ | license = '' , |
||
$ | copyStatus = '' , |
||
$ | source = '' , |
||
$ | watch = false , |
||
$ | timestamp = false , |
||
User $ | user = null |
||
) |
Record a file upload in the upload log and the image table.
$oldver | |
$desc | string |
$license | string |
$copyStatus | string |
$source | string |
$watch | bool |
$timestamp | string|bool |
$user | User object or null to use $wgUser |
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1144 of file LocalFile.php.
LocalFile::recordUpload2 | ( | $ | oldver, |
$ | comment, | ||
$ | pageText, | ||
$ | props = false , |
||
$ | timestamp = false , |
||
$ | user = null |
||
) |
Record a file upload in the upload log and the image table.
$oldver | |
$comment | string |
$pageText | string |
$props | bool|array |
$timestamp | bool|string |
$user | null|User |
Definition at line 1174 of file LocalFile.php.
Reset the history pointer to the first element of the history.
Reimplemented from File.
Definition at line 1046 of file LocalFile.php.
LocalFile::restore | ( | $ | versions = array() , |
$ | unsuppress = false |
||
) |
Restore all or specified deleted revisions to the given file.
Permissions and logging are left to the caller.
May throw database exceptions on error.
array | $versions | set of record ids of deleted items to restore, or empty to restore all revisions. |
$unsuppress | Boolean |
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1645 of file LocalFile.php.
Save the file metadata to memcached.
Definition at line 244 of file LocalFile.php.
static LocalFile::selectFields | ( | ) | [static] |
Fields in the image table.
Reimplemented in OldLocalFile.
Definition at line 151 of file LocalFile.php.
Referenced by LocalRepo\findBySha1(), LocalRepo\findBySha1s(), LocalRepo\findFilesByPrefix(), and ApiQueryAllImages\run().
LocalFile::setProps | ( | $ | info | ) |
Set properties in this object to be equal to those given in the associative array $info.
Only cacheable fields can be set. All fields *must* be set in $info except for getLazyCacheFields().
If 'mime' is given, it will be split into major_mime/minor_mime. If major_mime/minor_mime are given, $this->mime will also be set.
Definition at line 565 of file LocalFile.php.
Decrement the lock reference count.
If the reference count is reduced to zero, commits the transaction and thereby releases the image lock.
Definition at line 1797 of file LocalFile.php.
Referenced by OldLocalFile\uploadOld().
Roll back the DB transaction and mark the image unlocked.
Definition at line 1811 of file LocalFile.php.
LocalFile::unprefixRow | ( | $ | row, |
$ | prefix = 'img_' |
||
) | [protected] |
Row | $row | |
$prefix | string |
Definition at line 396 of file LocalFile.php.
Referenced by OldLocalFile\loadExtraFromDB().
Fix assorted version-related problems with the image row by reloading it from the file.
Reimplemented from File.
Reimplemented in OldLocalFile.
Definition at line 511 of file LocalFile.php.
LocalFile::upload | ( | $ | srcPath, |
$ | comment, | ||
$ | pageText, | ||
$ | flags = 0 , |
||
$ | props = false , |
||
$ | timestamp = false , |
||
$ | user = null |
||
) |
getHashPath inherited
getRel inherited getUrlRel inherited getArchiveRel inherited getArchivePath inherited getThumbPath inherited getArchiveUrl inherited getThumbUrl inherited getArchiveVirtualUrl inherited getThumbVirtualUrl inherited isHashed inherited Upload a file and record it in the DB
string | $srcPath | source storage path, virtual URL, or filesystem path |
string | $comment | upload description |
string | $pageText | text to use for the new description page, if a new description page is created |
$flags | Integer|bool: flags for publish() | |
array | bool | $props | File properties, if known. This can be used to reduce the upload time when uploading virtual URLs for which the file info is already known |
string | bool | $timestamp | timestamp for img_timestamp, or false to use the current time |
$user | User|null: User object or null to use $wgUser |
Definition at line 1082 of file LocalFile.php.
LocalFile::$attr |
Definition at line 53 of file LocalFile.php.
LocalFile::$bits |
Definition at line 53 of file LocalFile.php.
LocalFile::$dataLoaded |
Definition at line 53 of file LocalFile.php.
LocalFile::$deleted |
Definition at line 53 of file LocalFile.php.
LocalFile::$description |
Definition at line 53 of file LocalFile.php.
LocalFile::$extraDataLoaded |
Definition at line 53 of file LocalFile.php.
LocalFile::$fileExists |
LocalFile::$historyLine |
Definition at line 53 of file LocalFile.php.
LocalFile::$historyRes |
Definition at line 53 of file LocalFile.php.
LocalFile::$locked |
Definition at line 53 of file LocalFile.php.
LocalFile::$lockedOwnTrx |
Definition at line 53 of file LocalFile.php.
LocalFile::$major_mime |
Definition at line 53 of file LocalFile.php.
LocalFile::$media_type |
Definition at line 53 of file LocalFile.php.
LocalFile::$metadata |
Definition at line 53 of file LocalFile.php.
LocalFile::$mime |
Definition at line 53 of file LocalFile.php.
LocalFile::$minor_mime |
Definition at line 53 of file LocalFile.php.
LocalFile::$missing |
Definition at line 53 of file LocalFile.php.
LocalRepo LocalFile::$repo |
#@-
Reimplemented from File.
Definition at line 82 of file LocalFile.php.
Referenced by OldLocalFile\__construct(), OldLocalFile\newFromArchiveName(), OldLocalFile\newFromKey(), ForeignDBFile\newFromRow(), OldLocalFile\newFromRow(), ForeignDBFile\newFromTitle(), and OldLocalFile\newFromTitle().
LocalFile::$repoClass = 'LocalRepo' [protected] |
Required Repository class type.
Reimplemented from File.
Definition at line 84 of file LocalFile.php.
LocalFile::$sha1 |
Definition at line 53 of file LocalFile.php.
Referenced by OldLocalFile\newFromKey().
LocalFile::$size |
Definition at line 53 of file LocalFile.php.
LocalFile::$timestamp |
Definition at line 53 of file LocalFile.php.
Referenced by OldLocalFile\newFromKey(), OldLocalFile\recordOldUpload(), and OldLocalFile\uploadOld().
LocalFile::$upgraded |
Definition at line 53 of file LocalFile.php.
LocalFile::$user |
Definition at line 53 of file LocalFile.php.
Referenced by OldLocalFile\recordOldUpload(), OldLocalFile\uploadOld(), and OldLocalFile\userCan().
LocalFile::$user_text |
Definition at line 53 of file LocalFile.php.
LocalFile::$width |
Definition at line 53 of file LocalFile.php.
const LocalFile::CACHE_FIELD_MAX_LEN = 1000 |
Definition at line 47 of file LocalFile.php.
const LocalFile::LOAD_ALL = 1 |
Definition at line 86 of file LocalFile.php.