[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/filerepo/file/ -> LocalFile.php (summary)

Local file in the wiki's own database. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 3034 lines (84 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 4 classes

LocalFile:: (64 methods):
  newFromTitle()
  newFromRow()
  newFromKey()
  selectFields()
  __construct()
  getCacheKey()
  loadFromCache()
  saveToCache()
  loadFromFile()
  getCacheFields()
  getLazyCacheFields()
  loadFromDB()
  loadExtraFromDB()
  loadFieldsWithTimestamp()
  unprefixRow()
  decodeRow()
  loadFromRow()
  load()
  maybeUpgradeRow()
  getUpgraded()
  upgradeRow()
  setProps()
  isMissing()
  getWidth()
  getHeight()
  getUser()
  getMetadata()
  getBitDepth()
  getSize()
  getMimeType()
  getMediaType()
  exists()
  getThumbnails()
  purgeMetadataCache()
  purgeHistory()
  purgeCache()
  purgeOldThumbnails()
  purgeThumbnails()
  purgeThumbList()
  getHistory()
  nextHistoryLine()
  resetHistory()
  upload()
  recordUpload()
  recordUpload2()
  publish()
  publishTo()
  move()
  delete()
  deleteOld()
  restore()
  getDescriptionUrl()
  getDescriptionText()
  getDescription()
  getTimestamp()
  getSha1()
  isCacheable()
  lock()
  unlock()
  markVolatile()
  isVolatile()
  unlockAndRollback()
  readOnlyFatalStatus()
  __destruct()

LocalFileDeleteBatch:: (10 methods):
  __construct()
  addCurrent()
  addOld()
  addOlds()
  getOldRels()
  getHashes()
  doDBInserts()
  doDBDeletes()
  execute()
  removeNonexistentFiles()

LocalFileRestoreBatch:: (9 methods):
  __construct()
  addId()
  addIds()
  addAll()
  execute()
  removeNonexistentFiles()
  removeNonexistentFromCleanup()
  cleanup()
  cleanupFailedBatch()

LocalFileMoveBatch:: (9 methods):
  __construct()
  addCurrent()
  addOlds()
  execute()
  doDBUpdates()
  getMoveTriplets()
  removeNonexistentFiles()
  cleanupTarget()
  cleanupSource()


Class: LocalFile  - X-Ref

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.

newFromTitle( $title, $repo, $unused = null )   X-Ref
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

param: Title $title
param: FileRepo $repo
param: null $unused
return: LocalFile

newFromRow( $row, $repo )   X-Ref
Create a LocalFile from a title
Do not call this except from inside a repo class.

param: stdClass $row
param: FileRepo $repo
return: LocalFile

newFromKey( $sha1, $repo, $timestamp = false )   X-Ref
Create a LocalFile from a SHA-1 key
Do not call this except from inside a repo class.

param: string $sha1 Base-36 SHA-1
param: LocalRepo $repo
param: string|bool $timestamp MW_timestamp (optional)
return: bool|LocalFile

selectFields()   X-Ref
Fields in the image table

return: array

__construct( $title, $repo )   X-Ref
Constructor.
Do not call this except from inside a repo class.

param: Title $title
param: FileRepo $repo

getCacheKey()   X-Ref
Get the memcached key for the main data for this file, or false if
there is no access to the shared cache.

return: string|bool

loadFromCache()   X-Ref
Try to load file metadata from memcached. Returns true on success.

return: bool

saveToCache()   X-Ref
Save the file metadata to memcached


loadFromFile()   X-Ref
Load metadata from the file itself


getCacheFields( $prefix = 'img_' )   X-Ref

param: string $prefix
return: array

getLazyCacheFields( $prefix = 'img_' )   X-Ref

param: string $prefix
return: array

loadFromDB( $flags = 0 )   X-Ref
Load file metadata from the DB

param: int $flags

loadExtraFromDB()   X-Ref
Load lazy file metadata from the DB.
This covers fields that are sometimes not cached.


loadFieldsWithTimestamp( $dbr, $fname )   X-Ref

param: DatabaseBase $dbr
param: string $fname
return: array|bool

unprefixRow( $row, $prefix = 'img_' )   X-Ref

param: array $row Row
param: string $prefix
return: array

decodeRow( $row, $prefix = 'img_' )   X-Ref
Decode a row from the database (either object or array) to an array
with timestamps and MIME types decoded, and the field prefix removed.

param: object $row
param: string $prefix
return: array

loadFromRow( $row, $prefix = 'img_' )   X-Ref
Load file metadata from a DB result row

param: object $row
param: string $prefix

load( $flags = 0 )   X-Ref
Load file metadata from cache or DB, unless already loaded

param: int $flags

maybeUpgradeRow()   X-Ref
Upgrade a row if it needs it


getUpgraded()   X-Ref
No description

upgradeRow()   X-Ref
Fix assorted version-related problems with the image row by reloading it from the file


setProps( $info )   X-Ref
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.

param: array $info

isMissing()   X-Ref

return: bool

getWidth( $page = 1 )   X-Ref
Return the width of the image

param: int $page
return: int

getHeight( $page = 1 )   X-Ref
Return the height of the image

param: int $page
return: int

getUser( $type = 'text' )   X-Ref
Returns ID or name of user who uploaded the file

param: string $type 'text' or 'id'
return: int|string

getMetadata()   X-Ref
Get handler-specific metadata

return: string

getBitDepth()   X-Ref

return: int

getSize()   X-Ref
Returns the size of the image file, in bytes

return: int

getMimeType()   X-Ref
Returns the MIME type of the file.

return: string

getMediaType()   X-Ref
Returns the type of the media in the file.
Use the value returned by this function with the MEDIATYPE_xxx constants.

return: string

exists()   X-Ref
Returns true if the file exists on disk.

return: bool Whether file exist on disk.

getThumbnails( $archiveName = false )   X-Ref
Get all thumbnail names previously generated for this file

param: string|bool $archiveName Name of an archive file, default false
return: array First element is the base dir, then files in that base dir.

purgeMetadataCache()   X-Ref
Refresh metadata in memcached, but don't touch thumbnails or squid


purgeHistory()   X-Ref
Purge the shared history (OldLocalFile) cache.


purgeCache( $options = array()   X-Ref
Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid.

param: array $options An array potentially with the key forThumbRefresh.

purgeOldThumbnails( $archiveName )   X-Ref
Delete cached transformed files for an archived version only.

param: string $archiveName Name of the archived file

purgeThumbnails( $options = array()   X-Ref
Delete cached transformed files for the current version only.

param: array $options

purgeThumbList( $dir, $files )   X-Ref
Delete a list of thumbnails visible at urls

param: string $dir Base dir of the files.
param: array $files Array of strings: relative filenames (to $dir)

getHistory( $limit = null, $start = null, $end = null, $inc = true )   X-Ref

param: int $limit Optional: Limit to number of results
param: int $start Optional: Timestamp, start from
param: int $end Optional: Timestamp, end at
param: bool $inc
return: array

nextHistoryLine()   X-Ref
Returns 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

return: bool

resetHistory()   X-Ref
Reset the history pointer to the first element of the history


upload( $srcPath, $comment, $pageText, $flags = 0, $props = false,$timestamp = false, $user = null)   X-Ref
Upload a file and record it in the DB

param: string $srcPath Source storage path, virtual URL, or filesystem path
param: string $comment Upload description
param: string $pageText Text to use for the new description page,
param: int|bool $flags Flags for publish()
param: array|bool $props File properties, if known. This can be used to
param: string|bool $timestamp Timestamp for img_timestamp, or false to use the
param: User|null $user User object or null to use $wgUser
return: FileRepoStatus On success, the value member contains the

recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '',$watch = false, $timestamp = false, User $user = null )   X-Ref
Record a file upload in the upload log and the image table

param: string $oldver
param: string $desc
param: string $license
param: string $copyStatus
param: string $source
param: bool $watch
param: string|bool $timestamp
param: User|null $user User object or null to use $wgUser
return: bool

recordUpload2( $oldver, $comment, $pageText, $props = false, $timestamp = false,$user = null)   X-Ref
Record a file upload in the upload log and the image table

param: string $oldver
param: string $comment
param: string $pageText
param: bool|array $props
param: string|bool $timestamp
param: null|User $user
return: bool

publish( $srcPath, $flags = 0, array $options = array()   X-Ref
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.

param: string $srcPath Local filesystem path to the source image
param: int $flags A bitwise combination of:
param: array $options Optional additional parameters
return: FileRepoStatus On success, the value member contains the

publishTo( $srcPath, $dstRel, $flags = 0, array $options = array()   X-Ref
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.

param: string $srcPath Local filesystem path to the source image
param: string $dstRel Target relative path
param: int $flags A bitwise combination of:
param: array $options Optional additional parameters
return: FileRepoStatus On success, the value member contains the

move( $target )   X-Ref
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

param: Title $target New file name
return: FileRepoStatus

delete( $reason, $suppress = false, $user = null )   X-Ref
No description

deleteOld( $archiveName, $reason, $suppress = false, $user = null )   X-Ref
No description

restore( $versions = array()   X-Ref
Restore all or specified deleted revisions to the given file.
Permissions and logging are left to the caller.

May throw database exceptions on error.

param: array $versions Set of record ids of deleted items to restore,
param: bool $unsuppress
return: FileRepoStatus

getDescriptionUrl()   X-Ref
Get the URL of the file description page.

return: string

getDescriptionText( $lang = null )   X-Ref
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.

param: Language $lang What language to get description in (Optional)
return: bool|mixed

getDescription( $audience = self::FOR_PUBLIC, User $user = null )   X-Ref

param: int $audience
param: User $user
return: string

getTimestamp()   X-Ref

return: bool|string

getSha1()   X-Ref

return: string

isCacheable()   X-Ref

return: bool Whether to cache in RepoGroup (this avoids OOMs)

lock()   X-Ref
Start a transaction and lock the image for update
Increments a reference counter if the lock is already held

return: bool Success

unlock()   X-Ref
Decrement the lock reference count. If the reference count is reduced to zero, commits
the transaction and thereby releases the image lock.


markVolatile()   X-Ref
Mark a file as about to be changed

This sets a cache key that alters master/slave DB loading behavior

return: bool Success

isVolatile()   X-Ref
Check if a file is about to be changed or has been changed recently

return: bool Whether the file is volatile

unlockAndRollback()   X-Ref
Roll back the DB transaction and mark the image unlocked


readOnlyFatalStatus()   X-Ref

return: Status

__destruct()   X-Ref
Clean up any dangling locks


Class: LocalFileDeleteBatch  - X-Ref

Helper class for file deletion

__construct( File $file, $reason = '', $suppress = false, $user = null )   X-Ref

param: File $file
param: string $reason
param: bool $suppress
param: User|null $user

addCurrent()   X-Ref
No description

addOld( $oldName )   X-Ref

param: string $oldName

addOlds()   X-Ref
Add the old versions of the image to the batch

return: array List of archive names from old versions

getOldRels()   X-Ref

return: array

getHashes()   X-Ref

return: array

doDBInserts()   X-Ref
No description

doDBDeletes()   X-Ref
No description

execute()   X-Ref
Run the transaction

return: FileRepoStatus

removeNonexistentFiles( $batch )   X-Ref
Removes non-existent files from a deletion batch.

param: array $batch
return: Status

Class: LocalFileRestoreBatch  - X-Ref

Helper class for file undeletion

__construct( File $file, $unsuppress = false )   X-Ref

param: File $file
param: bool $unsuppress

addId( $fa_id )   X-Ref
Add a file by ID

param: int $fa_id

addIds( $ids )   X-Ref
Add a whole lot of files by ID

param: int[] $ids

addAll()   X-Ref
Add all revisions of the file


execute()   X-Ref
Run the transaction, except the cleanup batch.
The cleanup batch should be run in a separate transaction, because it locks different
rows and there's no need to keep the image row locked while it's acquiring those locks
The caller may have its own transaction open.
So we save the batch and let the caller call cleanup()

return: FileRepoStatus

removeNonexistentFiles( $triplets )   X-Ref
Removes non-existent files from a store batch.

param: array $triplets
return: Status

removeNonexistentFromCleanup( $batch )   X-Ref
Removes non-existent files from a cleanup batch.

param: array $batch
return: array

cleanup()   X-Ref
Delete unused files in the deleted zone.
This should be called from outside the transaction in which execute() was called.

return: FileRepoStatus

cleanupFailedBatch( $storeStatus, $storeBatch )   X-Ref
Cleanup a failed batch. The batch was only partially successful, so
rollback by removing all items that were succesfully copied.

param: Status $storeStatus
param: array $storeBatch

Class: LocalFileMoveBatch  - X-Ref

Helper class for file movement

__construct( File $file, Title $target )   X-Ref

param: File $file
param: Title $target

addCurrent()   X-Ref
Add the current image to the batch


addOlds()   X-Ref
Add the old versions of the image to the batch

return: array List of archive names from old versions

execute()   X-Ref
Perform the move.

return: FileRepoStatus

doDBUpdates()   X-Ref
Do the database updates and return a new FileRepoStatus indicating how
many rows where updated.

return: FileRepoStatus

getMoveTriplets()   X-Ref
Generate triplets for FileRepo::storeBatch().

return: array

removeNonexistentFiles( $triplets )   X-Ref
Removes non-existent files from move batch.

param: array $triplets
return: Status

cleanupTarget( $triplets )   X-Ref
Cleanup a partially moved array of triplets by deleting the target
files. Called if something went wrong half way.

param: array $triplets

cleanupSource( $triplets )   X-Ref
Cleanup a fully moved array of triplets by deleting the source files.
Called at the end of the move process if everything else went ok.

param: array $triplets



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1