MediaWiki
REL1_19
|
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 () | |
Return the bit depth of the file Overridden by LocalFile STUB. | |
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 () | |
Get discription of file revision STUB. | |
getDescriptionText () | |
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 | |
getMediaType () | |
Return the type of the media in the file. | |
getMetadata () | |
Get handler-specific metadata. | |
getMimeType () | |
Returns the mime type of the file. | |
getSha1 () | |
Get the SHA-1 base 36 hash of the file. | |
getSize () | |
Return the size of the image file, in bytes. | |
getThumbnails ($archiveName=false) | |
getHandler inherited | |
getTimestamp () | |
Get the 14-character timestamp of the file upload. | |
getUpgraded () | |
getUser ($type= 'text') | |
Returns ID or name of user who uploaded the file. | |
getWidth ($page=1) | |
Return the width of the image. | |
isMissing () | |
splitMime inherited | |
load () | |
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) | |
Move or copy a file to its public location. | |
publishTo ($srcPath, $dstRel, $flags=0) | |
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) | |
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 | |
$fileExists | |
#@+ | |
$historyLine | |
$historyRes | |
$locked | |
$major_mime | |
$media_type | |
$metadata | |
$mime | |
$minor_mime | |
$missing | |
$sha1 | |
$size | |
$timestamp | |
$upgraded | |
$user | |
$user_text | |
$width | |
Protected Member Functions | |
purgeThumbList ($dir, $files) | |
Delete a list of thumbnails visible at urls. | |
Protected Attributes | |
$repoClass = 'LocalRepo' | |
#@- |
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 31 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 148 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.
Definition at line 290 of file LocalFile.php.
References wfTimestamp().
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 1244 of file LocalFile.php.
References $result, $wgUseSquid, and SquidUpdate\purge().
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 1297 of file LocalFile.php.
References $wgUseSquid, and SquidUpdate\purge().
canRender inherited
mustRender inherited allowInlineDisplay inherited isSafeFile inherited isTrustedFile inherited Returns true if the file exists on disk.
Reimplemented from File.
Definition at line 576 of file LocalFile.php.
Referenced by OldLocalFile\isVisible().
Return the bit depth of the file Overridden by LocalFile STUB.
Reimplemented from File.
Definition at line 536 of file LocalFile.php.
LocalFile::getCacheFields | ( | $ | prefix = 'img_' | ) |
Reimplemented in OldLocalFile.
Definition at line 241 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 164 of file LocalFile.php.
Get discription of file revision STUB.
Reimplemented from File.
Definition at line 1382 of file LocalFile.php.
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.
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1372 of file LocalFile.php.
References $wgParser, and Revision\newFromTitle().
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 1363 of file LocalFile.php.
LocalFile::getHeight | ( | $ | page = 1 | ) |
Return the height of the image.
Returns false on error
Reimplemented from File.
Definition at line 498 of file LocalFile.php.
References $page.
LocalFile::getHistory | ( | $ | limit = null , |
$ | start = null , |
||
$ | end = null , |
||
$ | inc = true |
||
) |
purgeDescription inherited
purgeEverything inherited
Reimplemented from File.
Definition at line 774 of file LocalFile.php.
References $dbr, $limit, $res, OldLocalFile\newFromRow(), OldLocalFile\selectFields(), and wfRunHooks().
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 561 of file LocalFile.php.
Get handler-specific metadata.
Reimplemented from File.
Definition at line 531 of file LocalFile.php.
Returns the mime type of the file.
Reimplemented from File.
Definition at line 552 of file LocalFile.php.
Get the SHA-1 base 36 hash of the file.
Reimplemented from File.
Definition at line 1392 of file LocalFile.php.
References wfReadOnly().
Return the size of the image file, in bytes.
Reimplemented from File.
Definition at line 544 of file LocalFile.php.
LocalFile::getThumbnails | ( | $ | archiveName = false | ) |
getHandler inherited
iconThumb inherited getLastError inherited Get all thumbnail names previously generated for this file
$archiveName | string|false Name of an archive file |
Definition at line 626 of file LocalFile.php.
Get the 14-character timestamp of the file upload.
Reimplemented from File.
Definition at line 1387 of file LocalFile.php.
Definition at line 378 of file LocalFile.php.
LocalFile::getUser | ( | $ | type = 'text' | ) |
Returns ID or name of user who uploaded the file.
$type | string 'text' or 'id' |
Reimplemented from File.
Definition at line 518 of file LocalFile.php.
LocalFile::getWidth | ( | $ | page = 1 | ) |
Return the width of the image.
Returns false on error
Reimplemented from File.
Definition at line 478 of file LocalFile.php.
References $page.
splitMime inherited
getName inherited getTitle inherited getURL inherited getViewURL inherited getPath inherited isVisible inhereted
Reimplemented from File.
Definition at line 465 of file LocalFile.php.
References FileRepo\FILES_ONLY.
LocalFile::load | ( | ) |
Load file metadata from cache or DB, unless already loaded.
Definition at line 340 of file LocalFile.php.
Referenced by OldLocalFile\getArchiveName(), OldLocalFile\getVisibility(), OldLocalFile\isDeleted(), and OldLocalFile\userCan().
Try to load file metadata from memcached.
Returns true on success.
Definition at line 173 of file LocalFile.php.
Load file metadata from the DB.
Reimplemented in OldLocalFile.
Definition at line 264 of file LocalFile.php.
References loadFromRow().
Load metadata from the file itself.
Definition at line 236 of file LocalFile.php.
Referenced by OldLocalFile\upgradeRow().
LocalFile::loadFromRow | ( | $ | row, |
$ | prefix = 'img_' |
||
) |
Load file metadata from a DB result row.
Definition at line 325 of file LocalFile.php.
Referenced by OldLocalFile\loadFromDB(), and 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 1419 of file LocalFile.php.
Referenced by OldLocalFile\uploadOld().
Upgrade a row if it needs it.
Definition at line 353 of file LocalFile.php.
References $wgUpdateCompatibleMetadata, MediaHandler\METADATA_BAD, MediaHandler\METADATA_COMPATIBLE, and wfReadOnly().
LocalFile::migrateThumbFile | ( | $ | thumbName | ) |
getTransformScript inherited
getUnscaledThumb inherited thumbName inherited createThumb inherited transform inherited Fix thumbnail files from 1.4 or before, with extreme prejudice
Reimplemented from File.
Definition at line 590 of file LocalFile.php.
References FileRepo\FILES_ONLY.
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 1205 of file LocalFile.php.
References wfDebugLog().
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.
$sha1 | string base-36 SHA-1 | |
$repo | LocalRepo | |
string | bool | $timestamp | MW_timestamp (optional) |
Reimplemented in OldLocalFile.
Definition at line 106 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 ForeignDBFile, and OldLocalFile.
Definition at line 88 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 ForeignDBFile, and OldLocalFile.
Definition at line 75 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 828 of file LocalFile.php.
LocalFile::publish | ( | $ | srcPath, |
$ | flags = 0 |
||
) |
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.
$srcPath | String: 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 |
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1151 of file LocalFile.php.
LocalFile::publishTo | ( | $ | srcPath, |
$ | dstRel, | ||
$ | flags = 0 |
||
) |
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.
$srcPath | String: local filesystem path to the source image |
$dstRel | String: target relative path |
$flags | Integer: a bitwise combination of: File::DELETE_SOURCE Delete the source file, i.e. move rather than copy |
Definition at line 1169 of file LocalFile.php.
References FileRepo\DELETE_SOURCE, File\DELETE_SOURCE, and wfTimestamp().
Referenced by OldLocalFile\uploadOld().
LocalFile::purgeCache | ( | $ | options = array() | ) |
Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid.
Reimplemented from File.
Definition at line 676 of file LocalFile.php.
References $options, and SquidUpdate\purge().
Purge the shared history (OldLocalFile) cache.
Definition at line 657 of file LocalFile.php.
References $wgMemc.
Refresh metadata in memcached, but don't touch thumbnails or squid.
Definition at line 648 of file LocalFile.php.
LocalFile::purgeOldThumbnails | ( | $ | archiveName | ) |
Delete cached transformed files for an archived version only.
$archiveName | string name of the archived file |
Definition at line 691 of file LocalFile.php.
References $dir, $file, $files, $urls, $wgUseSquid, SquidUpdate\purge(), and wfRunHooks().
Referenced by PurgeDeletedFiles\purgeFromArchiveTable().
LocalFile::purgeThumbList | ( | $ | dir, |
$ | files | ||
) | [protected] |
Delete a list of thumbnails visible at urls.
$dir | string base dir of the files. |
$files | array of strings: relative filenames (to $dir) |
Definition at line 749 of file LocalFile.php.
References $dir, $file, $files, FileRepo\SKIP_LOCKING, and wfDebug().
LocalFile::purgeThumbnails | ( | $ | options = array() | ) |
Delete cached transformed files for the current version only.
Definition at line 714 of file LocalFile.php.
References $dir, $file, $files, $options, $urls, $wgUseSquid, SquidUpdate\purge(), and wfRunHooks().
LocalFile::recordUpload | ( | $ | oldver, |
$ | desc, | ||
$ | license = '' , |
||
$ | copyStatus = '' , |
||
$ | source = '' , |
||
$ | watch = false , |
||
$ | timestamp = false |
||
) |
Record a file upload in the upload log and the image table.
Reimplemented in ForeignDBFile.
Definition at line 927 of file LocalFile.php.
References $license, $wgUser, and SpecialUpload\getInitialPageText().
LocalFile::recordUpload2 | ( | $ | oldver, |
$ | comment, | ||
$ | pageText, | ||
$ | props = false , |
||
$ | timestamp = false , |
||
$ | user = null |
||
) |
Record a file upload in the upload log and the image table.
Definition at line 946 of file LocalFile.php.
References $comment, $user, $wgUser, false, Revision\newNullRevision(), SquidUpdate\purge(), wfDebug(), wfRunHooks(), and wfTimestamp().
Reset the history pointer to the first element of the history.
Reimplemented from File.
Definition at line 865 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.
$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 1332 of file LocalFile.php.
Save the file metadata to memcached.
Definition at line 210 of file LocalFile.php.
static LocalFile::selectFields | ( | ) | [static] |
Fields in the image table.
Reimplemented in OldLocalFile.
Definition at line 125 of file LocalFile.php.
Referenced by LocalRepo\findBySha1(), 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.
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 437 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 1434 of file LocalFile.php.
Referenced by OldLocalFile\uploadOld().
Roll back the DB transaction and mark the image unlocked.
Definition at line 1447 of file LocalFile.php.
Fix assorted version-related problems with the image row by reloading it from the file.
Reimplemented from File.
Reimplemented in OldLocalFile.
Definition at line 385 of file LocalFile.php.
References wfDebug(), wfProfileIn(), wfProfileOut(), and wfReadOnly().
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
$srcPath | String: source storage path or virtual URL |
$comment | String: upload description |
$pageText | String: text to use for the new description page, if a new description page is created |
$flags | Integer: flags for publish() |
$props | Array: 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 |
$timestamp | String: timestamp for img_timestamp, or false to use the current time |
$user | Mixed: User object or null to use $wgUser |
Definition at line 901 of file LocalFile.php.
References $comment, $user, and $wgContLang.
LocalFile::$attr |
Definition at line 36 of file LocalFile.php.
LocalFile::$bits |
Definition at line 36 of file LocalFile.php.
LocalFile::$dataLoaded |
Definition at line 36 of file LocalFile.php.
LocalFile::$deleted |
Definition at line 36 of file LocalFile.php.
LocalFile::$description |
Definition at line 36 of file LocalFile.php.
LocalFile::$fileExists |
LocalFile::$historyLine |
Definition at line 36 of file LocalFile.php.
LocalFile::$historyRes |
Definition at line 36 of file LocalFile.php.
LocalFile::$locked |
Definition at line 36 of file LocalFile.php.
LocalFile::$major_mime |
Definition at line 36 of file LocalFile.php.
LocalFile::$media_type |
Definition at line 36 of file LocalFile.php.
LocalFile::$metadata |
Definition at line 36 of file LocalFile.php.
LocalFile::$mime |
Definition at line 36 of file LocalFile.php.
LocalFile::$minor_mime |
Definition at line 36 of file LocalFile.php.
LocalFile::$missing |
Definition at line 36 of file LocalFile.php.
LocalFile::$repoClass = 'LocalRepo' [protected] |
LocalFile::$sha1 |
Definition at line 36 of file LocalFile.php.
Referenced by OldLocalFile\newFromKey().
LocalFile::$size |
Definition at line 36 of file LocalFile.php.
LocalFile::$timestamp |
Definition at line 36 of file LocalFile.php.
Referenced by OldLocalFile\newFromKey(), OldLocalFile\recordOldUpload(), and OldLocalFile\uploadOld().
LocalFile::$upgraded |
Definition at line 36 of file LocalFile.php.
LocalFile::$user |
Definition at line 36 of file LocalFile.php.
Referenced by OldLocalFile\recordOldUpload(), OldLocalFile\uploadOld(), and OldLocalFile\userCan().
LocalFile::$user_text |
Definition at line 36 of file LocalFile.php.
LocalFile::$width |
Definition at line 36 of file LocalFile.php.