127 protected $fileFactory = [ UnregisteredLocalFile::class,
'newFromTitle' ];
159 || !array_key_exists(
'name', $info )
160 || !array_key_exists(
'backend', $info )
163 " requires an array of options having both 'name' and 'backend' keys.\n" );
167 $this->name = $info[
'name'];
169 $this->backend = $info[
'backend'];
175 $optionalSettings = [
176 'descBaseUrl',
'scriptDirUrl',
'articleUrl',
'fetchDescription',
177 'thumbScriptUrl',
'pathDisclosureProtection',
'descriptionCacheExpiry',
178 'favicon',
'thumbProxyUrl',
'thumbProxySecret',
180 foreach ( $optionalSettings as $var ) {
181 if ( isset( $info[$var] ) ) {
182 $this->$var = $info[$var];
187 $this->initialCapital = $info[
'initialCapital'] ??
188 MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized(
NS_FILE );
189 $this->url = $info[
'url'] ??
false;
190 if ( isset( $info[
'thumbUrl'] ) ) {
191 $this->thumbUrl = $info[
'thumbUrl'];
193 $this->thumbUrl = $this->url ?
"{$this->url}/thumb" :
false;
195 $this->hashLevels = $info[
'hashLevels'] ?? 2;
197 $this->transformVia404 = !empty( $info[
'transformVia404'] );
198 $this->abbrvThreshold = $info[
'abbrvThreshold'] ?? 255;
199 $this->isPrivate = !empty( $info[
'isPrivate'] );
201 $this->zones = $info[
'zones'] ?? [];
202 foreach ( [
'public',
'thumb',
'transcoded',
'temp',
'deleted' ] as $zone ) {
203 if ( !isset( $this->zones[$zone][
'container'] ) ) {
204 $this->zones[$zone][
'container'] =
"{$this->name}-{$zone}";
206 if ( !isset( $this->zones[$zone][
'directory'] ) ) {
207 $this->zones[$zone][
'directory'] =
'';
209 if ( !isset( $this->zones[$zone][
'urlsByExt'] ) ) {
210 $this->zones[$zone][
'urlsByExt'] = [];
216 $this->wanCache = $info[
'wanCache'] ?? WANObjectCache::newEmpty();
235 return $this->backend->getReadOnlyReason();
247 foreach ( (array)$doZones as $zone ) {
249 if ( $root ===
null ) {
250 throw new MWException(
"No '$zone' zone defined in the {$this->name} repo." );
264 return substr(
$url, 0, 9 ) ==
'mwrepo://';
277 if ( $suffix !==
false ) {
278 $path .=
'/' . rawurlencode( $suffix );
292 if ( in_array( $zone, [
'public',
'thumb',
'transcoded' ] ) ) {
294 if (
$ext !==
null && isset( $this->zones[$zone][
'urlsByExt'][
$ext] ) ) {
296 return $this->zones[$zone][
'urlsByExt'][
$ext];
297 } elseif ( isset( $this->zones[$zone][
'url'] ) ) {
299 return $this->zones[$zone][
'url'];
311 return "{$this->url}/transcoded";
333 if ( substr(
$url, 0, 9 ) !=
'mwrepo://' ) {
334 throw new MWException( __METHOD__ .
': unknown protocol' );
336 $bits = explode(
'/', substr(
$url, 9 ), 3 );
337 if ( count( $bits ) != 3 ) {
338 throw new MWException( __METHOD__ .
": invalid mwrepo URL: $url" );
340 list( $repo, $zone, $rel ) = $bits;
341 if ( $repo !== $this->name ) {
342 throw new MWException( __METHOD__ .
": fetching from a foreign repo is not supported" );
346 throw new MWException( __METHOD__ .
": invalid zone: $zone" );
349 return $base .
'/' . rawurldecode( $rel );
359 if ( !isset( $this->zones[$zone] ) ) {
360 return [
null, null ];
363 return [ $this->zones[$zone][
'container'], $this->zones[$zone][
'directory'] ];
374 if ( $container ===
null ||
$base ===
null ) {
377 $backendName = $this->backend->getName();
382 return "mwstore://$backendName/{$container}{$base}";
402 if ( $this->oldFileFactory ) {
403 return call_user_func( $this->oldFileFactory,
$title, $this, $time );
408 return call_user_func( $this->fileFactory,
$title, $this );
434 if ( isset( $options[
'bypassCache'] ) ) {
435 $options[
'latest'] = $options[
'bypassCache'];
437 $time = $options[
'time'] ??
false;
438 $flags = !empty( $options[
'latest'] ) ? File::READ_LATEST : 0;
439 # First try the current version of the file to see if it precedes the timestamp
444 $img->load( $flags );
445 if ( $img->exists() && ( !$time || $img->getTimestamp() == $time ) ) {
448 # Now try an old version of the file
449 if ( $time !==
false ) {
452 $img->load( $flags );
453 if ( $img->exists() ) {
456 } elseif ( !empty( $options[
'private'] ) &&
458 $options[
'private'] instanceof
User ? $options[
'private'] : null
468 if ( !empty( $options[
'ignoreRedirect'] ) ) {
473 $img = $this->
newFile( $redir );
477 $img->load( $flags );
478 if ( $img->exists() ) {
479 $img->redirectedFrom(
$title->getDBkey() );
507 foreach ( $items as $item ) {
508 if ( is_array( $item ) ) {
511 unset( $options[
'title'] );
519 if ( $flags & self::NAME_AND_TIME_ONLY ) {
520 $result[$searchName] = [
521 'title' =>
$file->getTitle()->getDBkey(),
522 'timestamp' =>
$file->getTimestamp()
525 $result[$searchName] =
$file;
543 $time = $options[
'time'] ??
false;
544 # First try to find a matching current version of a file...
545 if ( !$this->fileFactoryKey ) {
548 $img = call_user_func( $this->fileFactoryKey, $sha1, $this, $time );
549 if ( $img && $img->exists() ) {
552 # Now try to find a matching old version of a file...
553 if ( $time !==
false && $this->oldFileFactoryKey ) {
554 $img = call_user_func( $this->oldFileFactoryKey, $sha1, $this, $time );
555 if ( $img && $img->exists() ) {
558 } elseif ( !empty( $options[
'private'] ) &&
560 $options[
'private'] instanceof
User ? $options[
'private'] : null
594 if ( count( $files ) ) {
595 $result[$hash] = $files;
658 $this->initialCapital !=
659 MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized(
NS_FILE )
662 if ( $this->initialCapital ) {
663 $name = MediaWikiServices::getInstance()->getContentLanguage()->ucfirst(
$name );
700 $parts = explode(
'!', $suffix, 2 );
701 $name = $parts[1] ?? $suffix;
711 if ( $levels == 0 ) {
714 $hash = md5(
$name );
716 for ( $i = 1; $i <= $levels; $i++ ) {
717 $path .= substr( $hash, 0, $i ) .
'/';
749 public function makeUrl( $query =
'', $entry =
'index' ) {
750 if ( isset( $this->scriptDirUrl ) ) {
751 return wfAppendQuery(
"{$this->scriptDirUrl}/{$entry}.php", $query );
771 if ( !is_null( $this->descBaseUrl ) ) {
772 # "http://example.com/wiki/File:"
773 return $this->descBaseUrl . $encName;
775 if ( !is_null( $this->articleUrl ) ) {
776 # "http://example.com/wiki/$1"
777 # We use "Image:" as the canonical namespace for
778 # compatibility across all MediaWiki versions.
779 return str_replace(
'$1',
780 "Image:$encName", $this->articleUrl );
782 if ( !is_null( $this->scriptDirUrl ) ) {
783 # "http://example.com/w"
784 # We use "Image:" as the canonical namespace for
785 # compatibility across all MediaWiki versions,
786 # and just sort of hope index.php is right. ;)
787 return $this->
makeUrl(
"title=Image:$encName" );
804 $query =
'action=render';
805 if ( !is_null(
$lang ) ) {
806 $query .=
'&uselang=' . urlencode(
$lang );
808 if ( isset( $this->scriptDirUrl ) ) {
829 if ( isset( $this->scriptDirUrl ) ) {
832 return $this->
makeUrl(
'title=MediaWiki:Filepage.css&action=raw&ctype=text/css' );
855 public function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
858 $status = $this->
storeBatch( [ [ $srcPath, $dstZone, $dstRel ] ], $flags );
859 if ( $status->successCount == 0 ) {
860 $status->setOK(
false );
883 if ( $flags & self::DELETE_SOURCE ) {
884 throw new InvalidArgumentException(
"DELETE_SOURCE not supported in " . __METHOD__ );
892 foreach ( $triplets as $triplet ) {
893 list( $src, $dstZone, $dstRel ) = $triplet;
894 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
896 .
"( \$src='$srcPath', \$dstZone='$dstZone', \$dstRel='$dstRel' )\n"
899 if ( $src instanceof
FSFile ) {
911 throw new MWException(
'Validation error in $dstRel' );
913 $dstPath =
"$root/$dstRel";
914 $dstDir = dirname( $dstPath );
917 return $this->
newFatal(
'directorycreateerror', $dstDir );
931 $opts = [
'force' =>
true ];
932 if ( $flags & self::SKIP_LOCKING ) {
933 $opts[
'nonLocking'] =
true;
956 foreach ( $files as
$path ) {
957 if ( is_array(
$path ) ) {
959 list( $zone, $rel ) =
$path;
965 $operations[] = [
'op' =>
'delete',
'src' =>
$path ];
968 $opts = [
'force' =>
true ];
969 if ( $flags & self::SKIP_LOCKING ) {
970 $opts[
'nonLocking'] =
true;
972 $status->merge( $this->backend->doOperations( $operations, $opts ) );
994 final public function quickImport( $src, $dst, $options =
null ) {
1015 foreach ( $triples as $triple ) {
1016 list( $src, $dst ) = $triple;
1017 if ( $src instanceof
FSFile ) {
1025 if ( !isset( $triple[2] ) ) {
1027 } elseif ( is_string( $triple[2] ) ) {
1029 $headers = [
'Content-Disposition' => $triple[2] ];
1030 } elseif ( is_array( $triple[2] ) && isset( $triple[2][
'headers'] ) ) {
1031 $headers = $triple[2][
'headers'];
1040 'headers' => $headers
1044 $status->merge( $this->backend->doQuickOperations( $operations ) );
1070 $status->merge( $this->backend->clean(
1071 [
'dir' => $this->resolveToStoragePathIfVirtual( $dir ) ] ) );
1087 foreach ( $paths as
$path ) {
1091 'ignoreMissingSource' =>
true
1094 $status->merge( $this->backend->doQuickOperations( $operations ) );
1112 $date = MWTimestamp::getInstance()->format(
'YmdHis' );
1114 $dstUrlRel = $hashPath . $date .
'!' . rawurlencode( $originalName );
1115 $virtualUrl = $this->
getVirtualUrl(
'temp' ) .
'/' . $dstUrlRel;
1117 $result = $this->
quickImport( $srcPath, $virtualUrl );
1118 $result->value = $virtualUrl;
1133 if ( substr( $virtualUrl, 0, strlen( $temp ) ) != $temp ) {
1134 wfDebug( __METHOD__ .
": Invalid temp virtual URL\n" );
1139 return $this->
quickPurge( $virtualUrl )->isOK();
1151 public function concatenate( array $srcPaths, $dstPath, $flags = 0 ) {
1157 foreach ( $srcPaths as $srcPath ) {
1164 $params = [
'srcs' => $sources,
'dst' => $dstPath ];
1165 $status->merge( $this->backend->concatenate( $params ) );
1166 if ( !$status->isOK() ) {
1171 if ( $flags & self::DELETE_SOURCE ) {
1176 $status->setResult(
true );
1205 $src, $dstRel, $archiveRel, $flags = 0, array $options = []
1210 [ [ $src, $dstRel, $archiveRel, $options ] ], $flags );
1211 if ( $status->successCount == 0 ) {
1212 $status->setOK(
false );
1214 $status->value = $status->value[0] ??
false;
1237 if ( !$status->isOK() ) {
1241 $status = $this->
newGood( [] );
1244 $sourceFSFilesToDelete = [];
1246 foreach ( $ntuples as $ntuple ) {
1247 list( $src, $dstRel, $archiveRel ) = $ntuple;
1248 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
1250 $options = $ntuple[3] ?? [];
1254 throw new MWException(
'Validation error in $dstRel' );
1257 throw new MWException(
'Validation error in $archiveRel' );
1261 $dstPath =
"$publicRoot/$dstRel";
1262 $archivePath =
"$publicRoot/$archiveRel";
1264 $dstDir = dirname( $dstPath );
1265 $archiveDir = dirname( $archivePath );
1268 return $this->
newFatal(
'directorycreateerror', $dstDir );
1271 return $this->
newFatal(
'directorycreateerror', $archiveDir );
1275 $headers = $options[
'headers'] ?? [];
1286 'dst' => $archivePath,
1287 'ignoreMissingSource' =>
true
1296 'overwrite' =>
true,
1297 'headers' => $headers
1304 'overwrite' =>
true,
1305 'headers' => $headers
1307 if ( $flags & self::DELETE_SOURCE ) {
1308 $sourceFSFilesToDelete[] = $srcPath;
1316 foreach ( $ntuples as $i => $ntuple ) {
1317 list( , , $archiveRel ) = $ntuple;
1318 $archivePath = $this->
getZonePath(
'public' ) .
"/$archiveRel";
1320 $status->value[$i] =
'archived';
1322 $status->value[$i] =
'new';
1326 foreach ( $sourceFSFilesToDelete as
$file ) {
1327 Wikimedia\suppressWarnings();
1329 Wikimedia\restoreWarnings();
1346 $params = [
'dir' =>
$path ];
1347 if ( $this->isPrivate
1348 || $container === $this->zones[
'deleted'][
'container']
1349 || $container === $this->zones[
'temp'][
'container']
1351 # Take all available measures to prevent web accessibility of new deleted
1352 # directories, in case the user has not configured offline storage
1353 $params = [
'noAccess' =>
true,
'noListing' =>
true ] + $params;
1357 $status->merge( $this->backend->prepare( $params ) );
1372 $status->merge( $this->backend->clean(
1373 [
'dir' => $this->resolveToStoragePathIfVirtual( $dir ) ] ) );
1397 $paths = array_map( [ $this,
'resolveToStoragePathIfVirtual' ], $files );
1398 $this->backend->preloadFileStat( [
'srcs' => $paths ] );
1401 foreach ( $files as $key =>
$file ) {
1403 $result[$key] = $this->backend->fileExists( [
'src' =>
$path ] );
1419 public function delete( $srcRel, $archiveRel ) {
1422 return $this->
deleteBatch( [ [ $srcRel, $archiveRel ] ] );
1446 $status = $this->
initZones( [
'public',
'deleted' ] );
1447 if ( !$status->isOK() ) {
1456 foreach ( $sourceDestPairs as $pair ) {
1457 list( $srcRel, $archiveRel ) = $pair;
1459 throw new MWException( __METHOD__ .
':Validation error in $srcRel' );
1461 throw new MWException( __METHOD__ .
':Validation error in $archiveRel' );
1465 $srcPath =
"{$publicRoot}/$srcRel";
1468 $archivePath =
"{$deletedRoot}/{$archiveRel}";
1469 $archiveDir = dirname( $archivePath );
1473 return $this->
newFatal(
'directorycreateerror', $archiveDir );
1479 'dst' => $archivePath,
1482 'overwriteSame' =>
true
1489 $opts = [
'force' =>
true ];
1514 if ( strlen( $key ) < 31 ) {
1515 throw new MWException(
"Invalid storage key '$key'." );
1519 $path .= $key[$i] .
'/';
1534 if ( self::isVirtualUrl(
$path ) ) {
1551 return $this->backend->getLocalCopy( [
'src' =>
$path ] );
1565 return $this->backend->getLocalReference( [
'src' =>
$path ] );
1579 $props = $mwProps->getPropsFromPath( $fsFile->getPath(),
true );
1581 $props = $mwProps->newPlaceholderProps();
1596 return $this->backend->getFileTimestamp( [
'src' =>
$path ] );
1608 return $this->backend->getFileSize( [
'src' =>
$path ] );
1620 return $this->backend->getFileSha1Base36( [
'src' =>
$path ] );
1634 $params = [
'src' =>
$path,
'headers' => $headers,
'options' => $optHeaders ];
1637 ob_start(
null, 1048576 );
1638 ob_implicit_flush(
true );
1641 $status->merge( $this->backend->streamFile( $params ) );
1645 if ( ob_get_status() ) {
1673 $numDirs = 1 << ( $this->hashLevels * 4 );
1676 for ( $flatIndex = 0; $flatIndex < $numDirs; $flatIndex++ ) {
1677 $hexString = sprintf(
"%0{$this->hashLevels}x", $flatIndex );
1678 $path = $publicRoot;
1680 $path .=
'/' . substr( $hexString, 0, $hexPos + 1 );
1682 $iterator = $this->backend->getFileList( [
'dir' =>
$path ] );
1683 foreach ( $iterator as
$name ) {
1685 call_user_func( $callback,
"{$path}/{$name}" );
1697 if ( strval( $filename ) ==
'' ) {
1710 switch ( $this->pathDisclosureProtection ) {
1713 $callback = [ $this,
'passThrough' ];
1716 $callback = [ $this,
'paranoidClean' ];
1748 $status = Status::newFatal( ...func_get_args() );
1761 $status = Status::newGood( $value );
1802 return wfMessageFallback(
'shared-repo-name-' . $this->name,
'shared-repo' )->text();
1813 if ( strlen(
$name ) > $this->abbrvThreshold ) {
1815 $name = (
$ext ==
'' ) ?
'thumbnail' :
"thumbnail.$ext";
1827 return $this->
getName() ==
'local';
1850 $args = func_get_args();
1853 return $this->wanCache->makeKey( ...
$args );
1866 'name' =>
"{$this->name}-temp",
1867 'backend' => $this->backend,
1872 'container' => $this->zones[
'temp'][
'container'],
1873 'directory' => $this->zones[
'temp'][
'directory']
1876 'container' => $this->zones[
'temp'][
'container'],
1877 'directory' => $this->zones[
'temp'][
'directory'] ==
''
1879 : $this->zones[
'temp'][
'directory'] .
'/thumb'
1882 'container' => $this->zones[
'temp'][
'container'],
1883 'directory' => $this->zones[
'temp'][
'directory'] ==
''
1885 : $this->zones[
'temp'][
'directory'] .
'/transcoded'
1927 $optionalSettings = [
1928 'url',
'thumbUrl',
'initialCapital',
'descBaseUrl',
'scriptDirUrl',
'articleUrl',
1929 'fetchDescription',
'descriptionCacheExpiry',
'favicon'
1931 foreach ( $optionalSettings as $k ) {
1932 if ( isset( $this->$k ) ) {
1933 $ret[$k] = $this->$k;
$wgSitename
Name of the site.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
wfMessageFallback(... $keys)
This function accepts multiple message keys and returns a message instance for the first message whic...
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Class representing a non-directory file on the file system.
Base class for all file backend classes (including multi-write backends).
static isStoragePath( $path)
Check if a given path is a "mwstore://" path.
static splitStoragePath( $storagePath)
Split a storage path into a backend name, a container name, and a relative file path.
static extensionFromPath( $path, $case='lowercase')
Get the final extension from a storage or FS path.
doOperations(array $ops, array $opts=[])
This is the main entry point into the backend for write operations.
static isPathTraversalFree( $path)
Check if a relative path has no directory traversals.
Base class for file repositories.
string $pathDisclosureProtection
May be 'paranoid' to remove all parameters from error messages, 'none' to leave the paths in unchange...
getTempHashPath( $suffix)
Get a relative path including trailing slash, e.g.
int $hashLevels
The number of directory levels for hash-based division of files.
getTempRepo()
Get a temporary private FileRepo associated with this repo.
cleanupDeletedBatch(array $storageKeys)
Delete files in the deleted directory if they are not referenced in the filearchive table.
getLocalCacheKey()
Get a key for this repo in the local cache domain.
resolveVirtualUrl( $url)
Get the backend storage path corresponding to a virtual URL.
nameForThumb( $name)
Get the portion of the file that contains the origin file name.
publishBatch(array $ntuples, $flags=0)
Publish a batch of files.
findFiles(array $items, $flags=0)
Find many files at once.
getThumbProxyUrl()
Get the URL thumb.php requests are being proxied to.
getZoneLocation( $zone)
The the storage container and base path of a zone.
string $favicon
The URL of the repo's favicon, if any.
fileExists( $file)
Checks existence of a file.
getFileSha1( $virtualUrl)
Get the sha1 (base 36) of a file with a given virtual URL/storage path.
quickImportBatch(array $triples)
Import a batch of files from the local file system into the repo.
assertWritableRepo()
Throw an exception if this repo is read-only by design.
getRootDirectory()
Get the public zone root storage directory of the repository.
supportsSha1URLs()
Returns whether or not repo supports having originals SHA-1s in the thumb URLs.
newGood( $value=null)
Create a new good result.
findFilesByPrefix( $prefix, $limit)
Return an array of files where the name starts with $prefix.
getHashLevels()
Get the number of hash directory levels.
string $thumbProxySecret
Secret key to pass as an X-Swift-Secret header to the proxied thumb service.
streamFileWithStatus( $virtualUrl, $headers=[], $optHeaders=[])
Attempt to stream a file with the given virtual URL/storage path.
getName()
Get the name of this repository, as specified by $info['name]' to the constructor.
store( $srcPath, $dstZone, $dstRel, $flags=0)
Store a file to a given destination.
findFile( $title, $options=[])
Find an instance of the named file created at the specified time Returns false if the file does not e...
callable false $oldFileFactoryKey
Override these in the base class.
getVirtualUrl( $suffix=false)
Get a URL referring to this repository, with the private mwrepo protocol.
quickPurge( $path)
Purge a file from the repo.
quickPurgeBatch(array $paths)
Purge a batch of files from the repo.
passThrough( $param)
Path disclosure protection function.
static getHashPathForLevel( $name, $levels)
array $zones
Map of zones to config.
callable false $fileFactoryKey
Override these in the base class.
getUploadStash(User $user=null)
Get an UploadStash associated with this repo.
getDisplayName()
Get the human-readable name of the repo.
getSharedCacheKey()
Get a key on the primary cache for this repository.
storeBatch(array $triplets, $flags=0)
Store a batch of files.
enumFiles( $callback)
Call a callback function for every public regular file in the repository.
hasSha1Storage()
Returns whether or not storage is SHA-1 based.
cleanupBatch(array $files, $flags=0)
Deletes a batch of files.
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 repositor...
initDirectory( $dir)
Creates a directory with the appropriate zone permissions.
int $abbrvThreshold
File names over this size will use the short form of thumbnail names.
makeUrl( $query='', $entry='index')
Make an url to this repo.
findBySha1s(array $hashes)
Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashe...
string $thumbProxyUrl
URL of where to proxy thumb.php requests to.
concatenate(array $srcPaths, $dstPath, $flags=0)
Concatenate a list of temporary files into a target file location.
fileExistsBatch(array $files)
Checks existence of an array of files.
int $descriptionCacheExpiry
paranoidClean( $param)
Path disclosure protection function.
initZones( $doZones=[])
Check if a single zone or list of zones is defined for usage.
string $thumbUrl
The base thumbnail URL.
getFileProps( $virtualUrl)
Get properties of a file with a given virtual URL/storage path.
isLocal()
Returns true if this the local file repository.
getZonePath( $zone)
Get the storage path corresponding to one of the zones.
getDescriptionUrl( $name)
Get the URL of an image description page.
cleanDir( $dir)
Deletes a directory if empty.
resolveToStoragePathIfVirtual( $path)
If a path is a virtual URL, resolve it to a storage path.
getDeletedHashPath( $key)
Get a relative path for a deletion archive key, e.g.
getFileSize( $virtualUrl)
Get the size of a file with a given virtual URL/storage path.
getThumbProxySecret()
Get the secret key for the proxied thumb service.
bool $fetchDescription
Whether to fetch commons image description pages and display them on the local wiki.
string false $url
Public zone URL.
callable $fileFactory
Override these in the base class.
static isVirtualUrl( $url)
Determine if a string is an mwrepo:// URL.
getDescriptionStylesheetUrl()
Get the URL of the stylesheet to apply to description pages.
bool $transformVia404
Whether to skip media file transformation on parse and rely on a 404 handler instead.
getFileTimestamp( $virtualUrl)
Get the timestamp of a file with a given virtual URL/storage path.
checkRedirect(Title $title)
Checks if there is a redirect named as $title.
bool $isPrivate
Whether all zones should be private (e.g.
string $scriptDirUrl
URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g.
string $descBaseUrl
URL of image description pages, e.g.
getZoneUrl( $zone, $ext=null)
Get the URL corresponding to one of the four basic zones.
newFatal( $message)
Create a new fatal error.
getReadOnlyReason()
Get an explanatory message if this repo is read-only.
newFile( $title, $time=false)
Create a new File object from the local repository.
storeTemp( $originalName, $srcPath)
Pick a random name in the temp zone and store a file to it.
quickCleanDir( $dir)
Deletes a directory if empty.
canTransformVia404()
Returns true if the repository can transform files via a 404 handler.
enumFilesInStorage( $callback)
Call a callback function for every public file in the repository.
validateFilename( $filename)
Determine if a relative path is valid, i.e.
findFileFromKey( $sha1, $options=[])
Find an instance of the file with this key, created at the specified time Returns false if the file d...
int $deletedHashLevels
The number of directory levels for hash-based division of deleted files.
string $thumbScriptUrl
URL of thumb.php.
backendSupportsUnicodePaths()
__construct(array $info=null)
bool $initialCapital
Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames impl...
getLocalCopy( $virtualUrl)
Get a local FS copy of a file with a given virtual URL/storage path.
deleteBatch(array $sourceDestPairs)
Move a group of files to the deletion archive.
getErrorCleanupFunction()
Get a callback function to use for cleaning error message parameters.
getHashPath( $name)
Get a relative path including trailing slash, e.g.
getNameFromTitle(Title $title)
Get the name of a file from its title object.
callable false $oldFileFactory
Override these in the base class.
invalidateImageRedirect(Title $title)
Invalidates image redirect cache related to that image Doesn't do anything for repositories that don'...
quickImport( $src, $dst, $options=null)
Import a file from the local file system into the repo.
string $articleUrl
Equivalent to $wgArticlePath, e.g.
getDescriptionRenderUrl( $name, $lang=null)
Get the URL of the content-only fragment of the description page.
freeTemp( $virtualUrl)
Remove a temporary file or mark it for garbage collection.
findBySha1( $hash)
Get an array or iterator of file objects for files that have a given SHA-1 content hash.
getBackend()
Get the file backend instance.
getInfo()
Return information about the repository.
getThumbScriptUrl()
Get the URL of thumb.php.
getLocalReference( $virtualUrl)
Get a local FS file with a given virtual URL/storage path.
static normalizeTitle( $title, $exception=false)
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
MimeMagic helper wrapper.
FileRepo for temporary files created via FileRepo::getTempRepo()
Represents a title within MediaWiki.
UploadStash is intended to accomplish a few things:
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Multi-datacenter aware caching interface.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!is_readable( $file)) $ext
if(!isset( $args[0])) $lang