MediaWiki  master
LocalRepo Class Reference

A repository that stores files in the local filesystem and registers them in the wiki's own database. More...

Inheritance diagram for LocalRepo:
Collaboration diagram for LocalRepo:

Public Member Functions

 __construct (array $info=null)
 
 checkRedirect (Title $title)
 Checks if there is a redirect named as $title. More...
 
 cleanupBatch (array $files, $flags=0)
 Deletes a batch of files. More...
 
 cleanupDeletedBatch (array $storageKeys)
 Delete files in the deleted directory if they are not referenced in the filearchive table. More...
 
 delete ( $srcRel, $archiveRel)
 Move a file to the deletion archive. More...
 
 deleteBatch (array $sourceDestPairs)
 Move a group of files to the deletion archive. More...
 
 findBySha1 ( $hash)
 Get an array or iterator of file objects for files that have a given SHA-1 content hash. More...
 
 findBySha1s (array $hashes)
 Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashes. More...
 
 findFiles (array $items, $flags=0)
 Find many files at once. More...
 
 findFilesByPrefix ( $prefix, $limit)
 Return an array of files where the name starts with $prefix. More...
 
 getInfo ()
 Return information about the repository. More...
 
 getMasterDB ()
 Get a connection to the master DB. More...
 
 getReplicaDB ()
 Get a connection to the replica DB. More...
 
 getSharedCacheKey ( $kClassSuffix,... $components)
 Get a global, repository-qualified, WAN cache key. More...
 
 invalidateImageRedirect (Title $title)
 Invalidates image redirect cache related to that image. More...
 
 newFileFromRow ( $row)
 
 newFromArchiveName ( $title, $archiveName)
 
 publish ( $src, $dstRel, $archiveRel, $flags=0, array $options=[])
 Copy or move a file either from a storage path, virtual URL, or file system path, into this repository at the specified destination location. More...
 
 publishBatch (array $ntuples, $flags=0)
 Publish a batch of files. More...
 
 store ( $srcPath, $dstZone, $dstRel, $flags=0)
 Store a file to a given destination. More...
 
 storeBatch (array $triplets, $flags=0)
 Store a batch of files. More...
 
- Public Member Functions inherited from FileRepo
 backendSupportsUnicodePaths ()
 
 canTransformVia404 ()
 Returns true if the repository can transform files via a 404 handler. More...
 
 cleanDir ( $dir)
 Deletes a directory if empty. More...
 
 concatenate (array $srcPaths, $dstPath, $flags=0)
 Concatenate a list of temporary files into a target file location. More...
 
 enumFiles ( $callback)
 Call a callback function for every public regular file in the repository. More...
 
 fileExists ( $file)
 Checks existence of a file. More...
 
 fileExistsBatch (array $files)
 Checks existence of an array of files. More...
 
 findFile ( $title, $options=[])
 Find an instance of the named file created at the specified time Returns false if the file does not exist. More...
 
 findFileFromKey ( $sha1, $options=[])
 Find an instance of the file with this key, created at the specified time Returns false if the file does not exist. More...
 
 freeTemp ( $virtualUrl)
 Remove a temporary file or mark it for garbage collection. More...
 
 getBackend ()
 Get the file backend instance. More...
 
 getDeletedHashPath ( $key)
 Get a relative path for a deletion archive key, e.g. More...
 
 getDescriptionRenderUrl ( $name, $lang=null)
 Get the URL of the content-only fragment of the description page. More...
 
 getDescriptionStylesheetUrl ()
 Get the URL of the stylesheet to apply to description pages. More...
 
 getDescriptionUrl ( $name)
 Get the URL of an image description page. More...
 
 getDisplayName ()
 Get the human-readable name of the repo. More...
 
 getFileProps ( $virtualUrl)
 Get properties of a file with a given virtual URL/storage path. More...
 
 getFileSha1 ( $virtualUrl)
 Get the sha1 (base 36) of a file with a given virtual URL/storage path. More...
 
 getFileSize ( $virtualUrl)
 Get the size of a file with a given virtual URL/storage path. More...
 
 getFileTimestamp ( $virtualUrl)
 Get the timestamp of a file with a given virtual URL/storage path. More...
 
 getHashLevels ()
 Get the number of hash directory levels. More...
 
 getHashPath ( $name)
 Get a relative path including trailing slash, e.g. More...
 
 getLocalCacheKey ( $kClassSuffix,... $components)
 Get a site-local, repository-qualified, WAN cache key. More...
 
 getLocalCopy ( $virtualUrl)
 Get a local FS copy of a file with a given virtual URL/storage path. More...
 
 getLocalReference ( $virtualUrl)
 Get a local FS file with a given virtual URL/storage path. More...
 
 getName ()
 Get the name of this repository, as specified by $info['name]' to the constructor. More...
 
 getNameFromTitle (Title $title)
 Get the name of a file from its title object. More...
 
 getReadOnlyReason ()
 Get an explanatory message if this repo is read-only. More...
 
 getRootDirectory ()
 Get the public zone root storage directory of the repository. More...
 
 getTempHashPath ( $suffix)
 Get a relative path including trailing slash, e.g. More...
 
 getTempRepo ()
 Get a temporary private FileRepo associated with this repo. More...
 
 getThumbProxySecret ()
 Get the secret key for the proxied thumb service. More...
 
 getThumbProxyUrl ()
 Get the URL thumb.php requests are being proxied to. More...
 
 getThumbScriptUrl ()
 Get the URL of thumb.php. More...
 
 getUploadStash (User $user=null)
 Get an UploadStash associated with this repo. More...
 
 getVirtualUrl ( $suffix=false)
 Get a URL referring to this repository, with the private mwrepo protocol. More...
 
 getZonePath ( $zone)
 Get the storage path corresponding to one of the zones. More...
 
 getZoneUrl ( $zone, $ext=null)
 Get the URL corresponding to one of the four basic zones. More...
 
 hasSha1Storage ()
 Returns whether or not storage is SHA-1 based. More...
 
 isLocal ()
 Returns true if this the local file repository. More...
 
 makeUrl ( $query='', $entry='index')
 Make an url to this repo. More...
 
 nameForThumb ( $name)
 Get the portion of the file that contains the origin file name. More...
 
 newFatal ( $message,... $parameters)
 Create a new fatal error. More...
 
 newFile ( $title, $time=false)
 Create a new File object from the local repository. More...
 
 newGood ( $value=null)
 Create a new good result. More...
 
 paranoidClean ( $param)
 Path disclosure protection function. More...
 
 passThrough ( $param)
 Path disclosure protection function. More...
 
 quickCleanDir ( $dir)
 Deletes a directory if empty. More...
 
 quickImport ( $src, $dst, $options=null)
 Import a file from the local file system into the repo. More...
 
 quickImportBatch (array $triples)
 Import a batch of files from the local file system into the repo. More...
 
 quickPurge ( $path)
 Purge a file from the repo. More...
 
 quickPurgeBatch (array $paths)
 Purge a batch of files from the repo. More...
 
 resolveVirtualUrl ( $url)
 Get the backend storage path corresponding to a virtual URL. More...
 
 storeTemp ( $originalName, $srcPath)
 Pick a random name in the temp zone and store a file to it. More...
 
 streamFileWithStatus ( $virtualUrl, $headers=[], $optHeaders=[])
 Attempt to stream a file with the given virtual URL/storage path. More...
 
 supportsSha1URLs ()
 Returns whether or not repo supports having originals SHA-1s in the thumb URLs. More...
 
 validateFilename ( $filename)
 Determine if a relative path is valid, i.e. More...
 

Static Public Member Functions

static getHashFromKey ( $key)
 Gets the SHA1 hash from a storage key. More...
 
- Static Public Member Functions inherited from FileRepo
static isVirtualUrl ( $url)
 Determine if a string is an mwrepo:// URL. More...
 

Protected Member Functions

 deletedFileHasKey ( $key, $lock=null)
 Check if a deleted (filearchive) file has this sha1 key. More...
 
 getDBFactory ()
 Get a callback to get a DB handle given an index (DB_REPLICA/DB_MASTER) More...
 
 hasAcessibleSharedCache ()
 Check whether the repo has a shared cache, accessible from the current site context. More...
 
 hiddenFileHasKey ( $key, $lock=null)
 Check if a hidden (revision delete) file has this sha1 key. More...
 
 skipWriteOperationIfSha1 ( $function, array $args)
 Skips the write operation if storage is sha1-based, executes it normally otherwise. More...
 
- Protected Member Functions inherited from FileRepo
 assertWritableRepo ()
 Throw an exception if this repo is read-only by design. More...
 
 enumFilesInStorage ( $callback)
 Call a callback function for every public file in the repository. More...
 
 getZoneLocation ( $zone)
 The storage container and base path of a zone. More...
 
 initDirectory ( $dir)
 Creates a directory with the appropriate zone permissions. More...
 
 initZones ( $doZones=[])
 Check if a single zone or list of zones is defined for usage. More...
 
 resolveToStoragePathIfVirtual ( $path)
 If a path is a virtual URL, resolve it to a storage path. More...
 

Protected Attributes

string $dbDomain
 DB domain of the repo wiki. More...
 
callable $fileFactory = [ LocalFile::class, 'newFromTitle' ]
 
callable $fileFactoryKey = [ LocalFile::class, 'newFromKey' ]
 
callable $fileFromRowFactory = [ LocalFile::class, 'newFromRow' ]
 
bool $hasAccessibleSharedCache
 Whether shared cache keys are exposed/accessible. More...
 
callable $oldFileFactory = [ OldLocalFile::class, 'newFromTitle' ]
 
callable $oldFileFactoryKey = [ OldLocalFile::class, 'newFromKey' ]
 
callable $oldFileFromRowFactory = [ OldLocalFile::class, 'newFromRow' ]
 
- Protected Attributes inherited from FileRepo
int $abbrvThreshold
 File names over this size will use the short form of thumbnail names. More...
 
string $articleUrl
 Equivalent to $wgArticlePath, e.g. More...
 
FileBackend $backend
 
int $deletedHashLevels
 The number of directory levels for hash-based division of deleted files. More...
 
string $descBaseUrl
 URL of image description pages, e.g. More...
 
string $favicon
 The URL of the repo's favicon, if any. More...
 
callable $fileFactory = [ UnregisteredLocalFile::class, 'newFromTitle' ]
 Override these in the base class. More...
 
callable false $fileFactoryKey = false
 Override these in the base class. More...
 
int $hashLevels
 The number of directory levels for hash-based division of files. More...
 
bool $hasSha1Storage = false
 
bool $initialCapital
 Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames implicitly start with a capital letter. More...
 
bool $isPrivate
 Whether all zones should be private (e.g. More...
 
callable false $oldFileFactory = false
 Override these in the base class. More...
 
callable false $oldFileFactoryKey = false
 Override these in the base class. More...
 
string $pathDisclosureProtection = 'simple'
 May be 'paranoid' to remove all parameters from error messages, 'none' to leave the paths in unchanged, or 'simple' to replace paths with placeholders. More...
 
string $scriptDirUrl
 URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g. More...
 
bool $supportsSha1URLs = false
 
string $thumbProxySecret
 Secret key to pass as an X-Swift-Secret header to the proxied thumb service. More...
 
string $thumbProxyUrl
 URL of where to proxy thumb.php requests to. More...
 
string $thumbScriptUrl
 URL of thumb.php. More...
 
string $thumbUrl
 The base thumbnail URL. More...
 
bool $transformVia404
 Whether to skip media file transformation on parse and rely on a 404 handler instead. More...
 
string false $url
 Public zone URL. More...
 
WANObjectCache $wanCache
 
array $zones = []
 Map of zones to config. More...
 

Additional Inherited Members

- Public Attributes inherited from FileRepo
int $descriptionCacheExpiry
 
bool $fetchDescription
 Whether to fetch commons image description pages and display them on the local wiki. More...
 
string $name
 
const DELETE_SOURCE = 1
 
const NAME_AND_TIME_ONLY = 1
 
const OVERWRITE = 2
 
const OVERWRITE_SAME = 4
 
const SKIP_LOCKING = 8
 
- Static Protected Member Functions inherited from FileRepo
static getHashPathForLevel ( $name, $levels)
 

Detailed Description

A repository that stores files in the local filesystem and registers them in the wiki's own database.

This is the most commonly used repository class.

@method LocalFile|null newFile( $title, $time = false )

Definition at line 37 of file LocalRepo.php.

Constructor & Destructor Documentation

◆ __construct()

LocalRepo::__construct ( array  $info = null)
See also
Documentation of info options at $wgLocalFileRepo
Parameters
array | null$info
Exceptions
MWException-assert array $info

Reimplemented from FileRepo.

Definition at line 56 of file LocalRepo.php.

References WikiMap\getCurrentWikiDbDomain(), getDBFactory(), and FileRepo\hasSha1Storage().

Member Function Documentation

◆ checkRedirect()

LocalRepo::checkRedirect ( Title  $title)

Checks if there is a redirect named as $title.

Parameters
Title$titleTitle of file
Returns
bool|Title

Reimplemented from FileRepo.

Definition at line 204 of file LocalRepo.php.

References $dbr, $title, FileRepo\getLocalCacheKey(), getReplicaDB(), getSharedCacheKey(), Title\makeTitle(), Title\newFromText(), File\normalizeTitle(), and NS_FILE.

Referenced by findFiles().

◆ cleanupBatch()

LocalRepo::cleanupBatch ( array  $files,
  $flags = 0 
)

Deletes a batch of files.

Each file can be a (zone, rel) pair, virtual url, storage path. It will try to delete each file, but ignores any errors that may occur.

Parameters
string[]$filesList of files to delete
int$flagsBitwise combination of the following flags: self::SKIP_LOCKING Skip any file locking when doing the deletions
Returns
Status

Reimplemented from FileRepo.

Definition at line 564 of file LocalRepo.php.

References skipWriteOperationIfSha1().

◆ cleanupDeletedBatch()

LocalRepo::cleanupDeletedBatch ( array  $storageKeys)

Delete files in the deleted directory if they are not referenced in the filearchive table.

This needs to be done in the repo because it needs to interleave database locks with file operations, which is potentially a remote operation.

Parameters
string[]$storageKeys
Returns
Status

Reimplemented from FileRepo.

Definition at line 107 of file LocalRepo.php.

References FileRepo\$backend, $path, deletedFileHasKey(), FileBackend\doOperation(), FileRepo\getDeletedHashPath(), getMasterDB(), FileRepo\getZonePath(), FileRepo\hasSha1Storage(), hiddenFileHasKey(), FileRepo\newGood(), StatusValue\newGood(), and wfDebug().

◆ delete()

LocalRepo::delete (   $srcRel,
  $archiveRel 
)

Move a file to the deletion archive.

If no valid deletion archive exists, this may either delete the file or throw an exception, depending on the preference of the repository

Parameters
mixed$srcRelRelative path for the file to be deleted
mixed$archiveRelRelative path for the archive location. Relative to a private archive directory.
Returns
Status

Reimplemented from FileRepo.

Definition at line 582 of file LocalRepo.php.

References skipWriteOperationIfSha1().

◆ deleteBatch()

LocalRepo::deleteBatch ( array  $sourceDestPairs)

Move a group of files to the deletion archive.

If no valid deletion archive is configured, this may either delete the file or throw an exception, depending on the preference of the repository.

The overwrite policy is determined by the repository – currently LocalRepo assumes a naming scheme in the deleted zone based on content hash, as opposed to the public zone which is assumed to be unique.

Parameters
array$sourceDestPairsArray of source/destination pairs. Each element is a two-element array containing the source file path relative to the public root in the first element, and the archive file path relative to the deleted zone root in the second element.
Exceptions
MWException
Returns
Status

Reimplemented from FileRepo.

Definition at line 586 of file LocalRepo.php.

References skipWriteOperationIfSha1().

◆ deletedFileHasKey()

LocalRepo::deletedFileHasKey (   $key,
  $lock = null 
)
protected

Check if a deleted (filearchive) file has this sha1 key.

Parameters
string$keyFile storage key (base-36 sha1 key with file extension)
string | null$lockUse "lock" to lock the row via FOR UPDATE
Returns
bool File with this key is in use

Definition at line 150 of file LocalRepo.php.

References getMasterDB().

Referenced by cleanupDeletedBatch().

◆ findBySha1()

LocalRepo::findBySha1 (   $hash)

Get an array or iterator of file objects for files that have a given SHA-1 content hash.

Parameters
string$hashA sha1 hash to look for
Returns
LocalFile[]

Reimplemented from FileRepo.

Definition at line 390 of file LocalRepo.php.

References $dbr, $res, LocalFile\getQueryInfo(), getReplicaDB(), and newFileFromRow().

◆ findBySha1s()

LocalRepo::findBySha1s ( array  $hashes)

Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashes.

Overrides generic implementation in FileRepo for performance reason

Parameters
string[]$hashesAn array of hashes
Returns
array[] An Array of arrays or iterators of file objects and the hash as key

Reimplemented from FileRepo.

Definition at line 420 of file LocalRepo.php.

References $dbr, $file, $hashes, $res, LocalFile\getQueryInfo(), getReplicaDB(), and newFileFromRow().

◆ findFiles()

LocalRepo::findFiles ( array  $items,
  $flags = 0 
)

Find many files at once.

Parameters
array$itemsAn array of titles, or an array of findFile() options with the "title" option giving the title. Example:

$findItem = [ 'title' => $title, 'private' => true ]; $findBatch = [ $findItem ]; $repo->findFiles( $findBatch );

No title should appear in $items twice, as the result use titles as keys

Parameters
int$flagsSupports:
  • FileRepo::NAME_AND_TIME_ONLY : return a (search title => (title,timestamp)) map. The search title uses the input titles; the other is the final post-redirect title. All titles are returned as string DB keys and the inner array is associative.
Returns
array Map of (file name => File objects) for matches

Reimplemented from FileRepo.

Definition at line 251 of file LocalRepo.php.

References $dbr, $file, $res, $title, checkRedirect(), File\DELETED_FILE, getInfo(), RequestContext\getMain(), FileRepo\getNameFromTitle(), LocalFile\getQueryInfo(), OldLocalFile\getQueryInfo(), getReplicaDB(), LIST_AND, LIST_OR, FileRepo\NAME_AND_TIME_ONLY, FileRepo\newFile(), newFileFromRow(), File\normalizeTitle(), and NS_FILE.

◆ findFilesByPrefix()

LocalRepo::findFilesByPrefix (   $prefix,
  $limit 
)

Return an array of files where the name starts with $prefix.

Parameters
string$prefixThe prefix to search for
int$limitThe maximum amount of files to return
Returns
LocalFile[]

Reimplemented from FileRepo.

Definition at line 453 of file LocalRepo.php.

References $dbr, $res, LocalFile\getQueryInfo(), getReplicaDB(), and newFileFromRow().

◆ getDBFactory()

LocalRepo::getDBFactory ( )
protected

Get a callback to get a DB handle given an index (DB_REPLICA/DB_MASTER)

Returns
Closure

Reimplemented in ForeignDBViaLBRepo, and ForeignDBRepo.

Definition at line 497 of file LocalRepo.php.

References wfGetDB().

Referenced by __construct().

◆ getHashFromKey()

static LocalRepo::getHashFromKey (   $key)
static

Gets the SHA1 hash from a storage key.

Parameters
string$key
Returns
string

Definition at line 190 of file LocalRepo.php.

Referenced by PopulateFilearchiveSha1\doDBUpdates(), LocalFileRestoreBatch\execute(), DeleteArchivedFiles\execute(), hiddenFileHasKey(), and ArchivedFile\loadFromRow().

◆ getInfo()

LocalRepo::getInfo ( )

Return information about the repository.

Returns
array
Since
1.22

Reimplemented from FileRepo.

Reimplemented in ForeignDBViaLBRepo, and ForeignDBRepo.

Definition at line 548 of file LocalRepo.php.

References $wgFavicon, and wfExpandUrl().

Referenced by findFiles().

◆ getMasterDB()

LocalRepo::getMasterDB ( )

Get a connection to the master DB.

Returns
IDatabase

Reimplemented in ForeignDBViaLBRepo, and ForeignDBRepo.

Definition at line 489 of file LocalRepo.php.

References DB_MASTER, and wfGetDB().

Referenced by cleanupDeletedBatch(), deletedFileHasKey(), hiddenFileHasKey(), and invalidateImageRedirect().

◆ getReplicaDB()

LocalRepo::getReplicaDB ( )

Get a connection to the replica DB.

Returns
IDatabase

Reimplemented in ForeignDBViaLBRepo, and ForeignDBRepo.

Definition at line 481 of file LocalRepo.php.

References DB_REPLICA, and wfGetDB().

Referenced by FindOrphanedFiles\checkFiles(), checkRedirect(), findBySha1(), findBySha1s(), findFiles(), findFilesByPrefix(), and PurgeChangedFiles\purgeFromArchiveTable().

◆ getSharedCacheKey()

LocalRepo::getSharedCacheKey (   $kClassSuffix,
  $components 
)

Get a global, repository-qualified, WAN cache key.

This might be called from either the site context of the wiki that owns the repo or the site context of another wiki that simply has access to the repo. This returns false if the repository's cache is not accessible from the current site context.

Parameters
string$kClassSuffixKey collection name suffix (added to this repo class)
mixed...$components Additional key components
Returns
string|false

Reimplemented from FileRepo.

Definition at line 513 of file LocalRepo.php.

References FileRepo\getName(), and hasAcessibleSharedCache().

Referenced by checkRedirect(), and invalidateImageRedirect().

◆ hasAcessibleSharedCache()

LocalRepo::hasAcessibleSharedCache ( )
protected

Check whether the repo has a shared cache, accessible from the current site context.

Returns
bool
Since
1.35

Definition at line 509 of file LocalRepo.php.

References $hasAccessibleSharedCache.

Referenced by getSharedCacheKey().

◆ hiddenFileHasKey()

LocalRepo::hiddenFileHasKey (   $key,
  $lock = null 
)
protected

Check if a hidden (revision delete) file has this sha1 key.

Parameters
string$keyFile storage key (base-36 sha1 key with file extension)
string | null$lockUse "lock" to lock the row via FOR UPDATE
Returns
bool File with this key is in use

Definition at line 168 of file LocalRepo.php.

References $ext, File\DELETED_FILE, getHashFromKey(), getMasterDB(), and File\normalizeExtension().

Referenced by cleanupDeletedBatch().

◆ invalidateImageRedirect()

LocalRepo::invalidateImageRedirect ( Title  $title)

Invalidates image redirect cache related to that image.

Parameters
Title$titleTitle of page
Returns
void

Reimplemented from FileRepo.

Definition at line 530 of file LocalRepo.php.

References $title, getMasterDB(), and getSharedCacheKey().

◆ newFileFromRow()

LocalRepo::newFileFromRow (   $row)
Exceptions
MWException
Parameters
stdClass$row
Returns
LocalFile

Definition at line 78 of file LocalRepo.php.

Referenced by findBySha1(), findBySha1s(), findFiles(), and findFilesByPrefix().

◆ newFromArchiveName()

LocalRepo::newFromArchiveName (   $title,
  $archiveName 
)
Parameters
Title$title
string$archiveName
Returns
OldLocalFile

Definition at line 93 of file LocalRepo.php.

References $title, and OldLocalFile\newFromArchiveName().

Referenced by FindOrphanedFiles\checkFiles(), and PurgeChangedFiles\purgeFromArchiveTable().

◆ publish()

LocalRepo::publish (   $src,
  $dstRel,
  $archiveRel,
  $flags = 0,
array  $options = [] 
)

Copy or move a file either from a storage path, virtual URL, or file system path, into this repository at the specified destination location.

Returns a Status object. On success, the value contains "new" or "archived", to indicate whether the file was new with that name.

Using FSFile/TempFSFile can improve performance via caching. Using TempFSFile can further improve performance by signalling that it is safe to touch the source file or write extended attribute metadata to it directly.

Options to $options include:

  • headers : name/value map of HTTP headers to use in response to GET/HEAD requests
Parameters
string | FSFile$srcThe source file system path, storage path, or URL
string$dstRelThe destination relative path
string$archiveRelThe relative path where the existing file is to be archived, if there is one. Relative to the public zone root.
int$flagsBitfield, may be FileRepo::DELETE_SOURCE to indicate that the source file should be deleted if possible
array$optionsOptional additional parameters
Returns
Status

Reimplemented from FileRepo.

Definition at line 568 of file LocalRepo.php.

References skipWriteOperationIfSha1().

◆ publishBatch()

LocalRepo::publishBatch ( array  $ntuples,
  $flags = 0 
)

Publish a batch of files.

See also
FileRepo::publish()
Parameters
array$ntuples(source, dest, archive) triplets or (source, dest, archive, options) 4-tuples as per publish().
int$flagsBitfield, may be FileRepo::DELETE_SOURCE to indicate that the source files should be deleted if possible
Exceptions
MWException
Returns
Status

Reimplemented from FileRepo.

Definition at line 578 of file LocalRepo.php.

References skipWriteOperationIfSha1().

◆ skipWriteOperationIfSha1()

LocalRepo::skipWriteOperationIfSha1 (   $function,
array  $args 
)
protected

Skips the write operation if storage is sha1-based, executes it normally otherwise.

Parameters
string$function
array$args
Returns
Status

Definition at line 597 of file LocalRepo.php.

References $args, FileRepo\assertWritableRepo(), FileRepo\hasSha1Storage(), StatusValue\newGood(), and wfDebug().

Referenced by cleanupBatch(), delete(), deleteBatch(), publish(), publishBatch(), store(), and storeBatch().

◆ store()

LocalRepo::store (   $srcPath,
  $dstZone,
  $dstRel,
  $flags = 0 
)

Store a file to a given destination.

Using FSFile/TempFSFile can improve performance via caching. Using TempFSFile can further improve performance by signalling that it is safe to touch the source file or write extended attribute metadata to it directly.

Parameters
string | FSFile$srcPathSource file system path, storage path, or virtual URL
string$dstZoneDestination zone
string$dstRelDestination relative path
int$flagsBitwise combination of the following flags: self::OVERWRITE Overwrite an existing destination file instead of failing self::OVERWRITE_SAME Overwrite the file if the destination exists and has the same contents as the source self::SKIP_LOCKING Skip any file locking when doing the store
Returns
Status

Reimplemented from FileRepo.

Definition at line 556 of file LocalRepo.php.

References skipWriteOperationIfSha1().

◆ storeBatch()

LocalRepo::storeBatch ( array  $triplets,
  $flags = 0 
)

Store a batch of files.

See also
FileRepo::store()
Parameters
array$triplets(src, dest zone, dest rel) triplets as per store()
int$flagsBitwise combination of the following flags: self::OVERWRITE Overwrite an existing destination file instead of failing self::OVERWRITE_SAME Overwrite the file if the destination exists and has the same contents as the source self::SKIP_LOCKING Skip any file locking when doing the store
Exceptions
MWException
Returns
Status

Reimplemented from FileRepo.

Definition at line 560 of file LocalRepo.php.

References skipWriteOperationIfSha1().

Member Data Documentation

◆ $dbDomain

string LocalRepo::$dbDomain
protected

DB domain of the repo wiki.

Definition at line 52 of file LocalRepo.php.

Referenced by ForeignDBRepo\__construct().

◆ $fileFactory

callable LocalRepo::$fileFactory = [ LocalFile::class, 'newFromTitle' ]
protected

Definition at line 39 of file LocalRepo.php.

◆ $fileFactoryKey

callable LocalRepo::$fileFactoryKey = [ LocalFile::class, 'newFromKey' ]
protected

Definition at line 41 of file LocalRepo.php.

◆ $fileFromRowFactory

callable LocalRepo::$fileFromRowFactory = [ LocalFile::class, 'newFromRow' ]
protected

Definition at line 43 of file LocalRepo.php.

◆ $hasAccessibleSharedCache

bool LocalRepo::$hasAccessibleSharedCache
protected

Whether shared cache keys are exposed/accessible.

Definition at line 54 of file LocalRepo.php.

Referenced by hasAcessibleSharedCache().

◆ $oldFileFactory

callable LocalRepo::$oldFileFactory = [ OldLocalFile::class, 'newFromTitle' ]
protected

Definition at line 47 of file LocalRepo.php.

◆ $oldFileFactoryKey

callable LocalRepo::$oldFileFactoryKey = [ OldLocalFile::class, 'newFromKey' ]
protected

Definition at line 49 of file LocalRepo.php.

◆ $oldFileFromRowFactory

callable LocalRepo::$oldFileFromRowFactory = [ OldLocalFile::class, 'newFromRow' ]
protected

Definition at line 45 of file LocalRepo.php.


The documentation for this class was generated from the following file: