129 protected $fileFactory = [ UnregisteredLocalFile::class,
'newFromTitle' ];
164 || !array_key_exists(
'name', $info )
165 || !array_key_exists(
'backend', $info )
168 " requires an array of options having both 'name' and 'backend' keys.\n" );
172 $this->name = $info[
'name'];
174 $this->backend = $info[
'backend'];
177 MediaWikiServices::getInstance()->getFileBackendGroup()->get( $info[
'backend'] );
181 $optionalSettings = [
182 'descBaseUrl',
'scriptDirUrl',
'articleUrl',
'fetchDescription',
183 'thumbScriptUrl',
'pathDisclosureProtection',
'descriptionCacheExpiry',
184 'favicon',
'thumbProxyUrl',
'thumbProxySecret',
186 foreach ( $optionalSettings as $var ) {
187 if ( isset( $info[$var] ) ) {
188 $this->$var = $info[$var];
194 MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized(
NS_FILE );
195 $this->initialCapital = $info[
'initialCapital'] ?? $localCapitalLinks;
196 if ( $localCapitalLinks && !$this->initialCapital ) {
204 throw new InvalidArgumentException(
205 'File repos with initial capital false are not allowed on wikis where the File ' .
206 'namespace has initial capital true' );
209 $this->url = $info[
'url'] ??
false;
210 if ( isset( $info[
'thumbUrl'] ) ) {
211 $this->thumbUrl = $info[
'thumbUrl'];
213 $this->thumbUrl = $this->url ?
"{$this->url}/thumb" :
false;
215 $this->hashLevels = $info[
'hashLevels'] ?? 2;
217 $this->transformVia404 = !empty( $info[
'transformVia404'] );
218 $this->abbrvThreshold = $info[
'abbrvThreshold'] ?? 255;
219 $this->isPrivate = !empty( $info[
'isPrivate'] );
221 $this->zones = $info[
'zones'] ?? [];
222 foreach ( [
'public',
'thumb',
'transcoded',
'temp',
'deleted' ] as $zone ) {
223 if ( !isset( $this->zones[$zone][
'container'] ) ) {
224 $this->zones[$zone][
'container'] =
"{$this->name}-{$zone}";
226 if ( !isset( $this->zones[$zone][
'directory'] ) ) {
227 $this->zones[$zone][
'directory'] =
'';
229 if ( !isset( $this->zones[$zone][
'urlsByExt'] ) ) {
230 $this->zones[$zone][
'urlsByExt'] = [];
236 $this->wanCache = $info[
'wanCache'] ?? WANObjectCache::newEmpty();
255 return $this->backend->getReadOnlyReason();
267 foreach ( (array)$doZones as $zone ) {
269 if ( $root ===
null ) {
270 throw new MWException(
"No '$zone' zone defined in the {$this->name} repo." );
284 return substr(
$url, 0, 9 ) ==
'mwrepo://';
297 if ( $suffix !==
false ) {
298 $path .=
'/' . rawurlencode( $suffix );
312 if ( in_array( $zone, [
'public',
'thumb',
'transcoded' ] ) ) {
314 if (
$ext !==
null && isset( $this->zones[$zone][
'urlsByExt'][
$ext] ) ) {
316 return $this->zones[$zone][
'urlsByExt'][
$ext];
317 } elseif ( isset( $this->zones[$zone][
'url'] ) ) {
319 return $this->zones[$zone][
'url'];
331 return "{$this->url}/transcoded";
353 if ( substr(
$url, 0, 9 ) !=
'mwrepo://' ) {
354 throw new MWException( __METHOD__ .
': unknown protocol' );
356 $bits = explode(
'/', substr(
$url, 9 ), 3 );
357 if ( count( $bits ) != 3 ) {
358 throw new MWException( __METHOD__ .
": invalid mwrepo URL: $url" );
360 list( $repo, $zone, $rel ) = $bits;
361 if ( $repo !== $this->name ) {
362 throw new MWException( __METHOD__ .
": fetching from a foreign repo is not supported" );
366 throw new MWException( __METHOD__ .
": invalid zone: $zone" );
369 return $base .
'/' . rawurldecode( $rel );
379 if ( !isset( $this->zones[$zone] ) ) {
380 return [
null, null ];
383 return [ $this->zones[$zone][
'container'], $this->zones[$zone][
'directory'] ];
394 if ( $container ===
null ||
$base ===
null ) {
397 $backendName = $this->backend->getName();
402 return "mwstore://$backendName/{$container}{$base}";
422 if ( $this->oldFileFactory ) {
423 return call_user_func( $this->oldFileFactory,
$title, $this, $time );
428 return call_user_func( $this->fileFactory,
$title, $this );
454 if ( isset( $options[
'bypassCache'] ) ) {
455 $options[
'latest'] = $options[
'bypassCache'];
457 $time = $options[
'time'] ??
false;
458 $flags = !empty( $options[
'latest'] ) ? File::READ_LATEST : 0;
459 # First try the current version of the file to see if it precedes the timestamp
464 $img->load( $flags );
465 if ( $img->exists() && ( !$time || $img->getTimestamp() == $time ) ) {
468 # Now try an old version of the file
469 if ( $time !==
false ) {
472 $img->load( $flags );
473 if ( $img->exists() ) {
475 if ( !$img->isDeleted( File::DELETED_FILE ) ) {
477 } elseif ( !empty( $options[
'private'] ) &&
478 $img->userCan( File::DELETED_FILE,
479 $options[
'private'] instanceof
User ? $options[
'private'] : $wgUser
489 if ( !empty( $options[
'ignoreRedirect'] ) ) {
494 $img = $this->
newFile( $redir );
498 $img->load( $flags );
499 if ( $img->exists() ) {
500 $img->redirectedFrom(
$title->getDBkey() );
528 foreach ( $items as $item ) {
529 if ( is_array( $item ) ) {
532 unset( $options[
'title'] );
539 $searchName = File::normalizeTitle(
$title )->getDBkey();
540 if ( $flags & self::NAME_AND_TIME_ONLY ) {
541 $result[$searchName] = [
542 'title' =>
$file->getTitle()->getDBkey(),
543 'timestamp' =>
$file->getTimestamp()
546 $result[$searchName] =
$file;
564 $time = $options[
'time'] ??
false;
565 # First try to find a matching current version of a file...
566 if ( !$this->fileFactoryKey ) {
569 $img = call_user_func( $this->fileFactoryKey, $sha1, $this, $time );
570 if ( $img && $img->exists() ) {
573 # Now try to find a matching old version of a file...
574 if ( $time !==
false && $this->oldFileFactoryKey ) {
575 $img = call_user_func( $this->oldFileFactoryKey, $sha1, $this, $time );
576 if ( $img && $img->exists() ) {
578 if ( !$img->isDeleted( File::DELETED_FILE ) ) {
580 } elseif ( !empty( $options[
'private'] ) &&
581 $img->userCan( File::DELETED_FILE,
582 $options[
'private'] instanceof
User ? $options[
'private'] : $wgUser
616 if ( count( $files ) ) {
617 $result[$hash] = $files;
680 $this->initialCapital !=
681 MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized(
NS_FILE )
684 if ( $this->initialCapital ) {
685 $name = MediaWikiServices::getInstance()->getContentLanguage()->ucfirst(
$name );
722 $parts = explode(
'!', $suffix, 2 );
723 $name = $parts[1] ?? $suffix;
733 if ( $levels == 0 ) {
736 $hash = md5(
$name );
738 for ( $i = 1; $i <= $levels; $i++ ) {
739 $path .= substr( $hash, 0, $i ) .
'/';
771 public function makeUrl( $query =
'', $entry =
'index' ) {
772 if ( isset( $this->scriptDirUrl ) ) {
773 return wfAppendQuery(
"{$this->scriptDirUrl}/{$entry}.php", $query );
793 if ( $this->descBaseUrl !==
null ) {
794 # "http://example.com/wiki/File:"
795 return $this->descBaseUrl . $encName;
797 if ( $this->articleUrl !==
null ) {
798 # "http://example.com/wiki/$1"
799 # We use "Image:" as the canonical namespace for
800 # compatibility across all MediaWiki versions.
801 return str_replace(
'$1',
802 "Image:$encName", $this->articleUrl );
804 if ( $this->scriptDirUrl !==
null ) {
805 # "http://example.com/w"
806 # We use "Image:" as the canonical namespace for
807 # compatibility across all MediaWiki versions,
808 # and just sort of hope index.php is right. ;)
809 return $this->
makeUrl(
"title=Image:$encName" );
826 $query =
'action=render';
827 if (
$lang !==
null ) {
828 $query .=
'&uselang=' . urlencode(
$lang );
830 if ( isset( $this->scriptDirUrl ) ) {
851 if ( isset( $this->scriptDirUrl ) ) {
854 return $this->
makeUrl(
'title=MediaWiki:Filepage.css&action=raw&ctype=text/css' );
877 public function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
880 $status = $this->
storeBatch( [ [ $srcPath, $dstZone, $dstRel ] ], $flags );
881 if ( $status->successCount == 0 ) {
882 $status->setOK(
false );
905 if ( $flags & self::DELETE_SOURCE ) {
906 throw new InvalidArgumentException(
"DELETE_SOURCE not supported in " . __METHOD__ );
914 foreach ( $triplets as $triplet ) {
915 list( $src, $dstZone, $dstRel ) = $triplet;
916 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
918 .
"( \$src='$srcPath', \$dstZone='$dstZone', \$dstRel='$dstRel' )"
921 if ( $src instanceof
FSFile ) {
933 throw new MWException(
'Validation error in $dstRel' );
935 $dstPath =
"$root/$dstRel";
936 $dstDir = dirname( $dstPath );
939 return $this->
newFatal(
'directorycreateerror', $dstDir );
953 $opts = [
'force' =>
true ];
954 if ( $flags & self::SKIP_LOCKING ) {
955 $opts[
'nonLocking'] =
true;
978 foreach ( $files as
$path ) {
979 if ( is_array(
$path ) ) {
981 list( $zone, $rel ) =
$path;
987 $operations[] = [
'op' =>
'delete',
'src' =>
$path ];
990 $opts = [
'force' =>
true ];
991 if ( $flags & self::SKIP_LOCKING ) {
992 $opts[
'nonLocking'] =
true;
994 $status->merge( $this->backend->doOperations( $operations, $opts ) );
1037 foreach ( $triples as $triple ) {
1038 list( $src, $dst ) = $triple;
1039 if ( $src instanceof
FSFile ) {
1047 if ( !isset( $triple[2] ) ) {
1049 } elseif ( is_string( $triple[2] ) ) {
1051 $headers = [
'Content-Disposition' => $triple[2] ];
1052 } elseif ( is_array( $triple[2] ) && isset( $triple[2][
'headers'] ) ) {
1053 $headers = $triple[2][
'headers'];
1062 'headers' => $headers
1066 $status->merge( $this->backend->doQuickOperations( $operations ) );
1092 $status->merge( $this->backend->clean(
1093 [
'dir' => $this->resolveToStoragePathIfVirtual( $dir ) ] ) );
1109 foreach ( $paths as
$path ) {
1113 'ignoreMissingSource' =>
true
1116 $status->merge( $this->backend->doQuickOperations( $operations ) );
1134 $date = MWTimestamp::getInstance()->format(
'YmdHis' );
1136 $dstUrlRel = $hashPath . $date .
'!' . rawurlencode( $originalName );
1137 $virtualUrl = $this->
getVirtualUrl(
'temp' ) .
'/' . $dstUrlRel;
1139 $result = $this->
quickImport( $srcPath, $virtualUrl );
1140 $result->value = $virtualUrl;
1155 if ( substr( $virtualUrl, 0, strlen( $temp ) ) != $temp ) {
1156 wfDebug( __METHOD__ .
": Invalid temp virtual URL" );
1161 return $this->
quickPurge( $virtualUrl )->isOK();
1173 public function concatenate( array $srcPaths, $dstPath, $flags = 0 ) {
1179 foreach ( $srcPaths as $srcPath ) {
1186 $params = [
'srcs' => $sources,
'dst' => $dstPath ];
1187 $status->merge( $this->backend->concatenate( $params ) );
1188 if ( !$status->isOK() ) {
1193 if ( $flags & self::DELETE_SOURCE ) {
1198 $status->setResult(
true );
1227 $src, $dstRel, $archiveRel, $flags = 0, array $options = []
1232 [ [ $src, $dstRel, $archiveRel, $options ] ], $flags );
1233 if ( $status->successCount == 0 ) {
1234 $status->setOK(
false );
1236 $status->value = $status->value[0] ??
false;
1259 if ( !$status->isOK() ) {
1263 $status = $this->
newGood( [] );
1266 $sourceFSFilesToDelete = [];
1268 foreach ( $ntuples as $ntuple ) {
1269 list( $src, $dstRel, $archiveRel ) = $ntuple;
1270 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
1272 $options = $ntuple[3] ?? [];
1276 throw new MWException(
'Validation error in $dstRel' );
1279 throw new MWException(
'Validation error in $archiveRel' );
1283 $dstPath =
"$publicRoot/$dstRel";
1284 $archivePath =
"$publicRoot/$archiveRel";
1286 $dstDir = dirname( $dstPath );
1287 $archiveDir = dirname( $archivePath );
1290 return $this->
newFatal(
'directorycreateerror', $dstDir );
1293 return $this->
newFatal(
'directorycreateerror', $archiveDir );
1297 $headers = $options[
'headers'] ?? [];
1308 'dst' => $archivePath,
1309 'ignoreMissingSource' =>
true
1318 'overwrite' =>
true,
1319 'headers' => $headers
1326 'overwrite' =>
true,
1327 'headers' => $headers
1329 if ( $flags & self::DELETE_SOURCE ) {
1330 $sourceFSFilesToDelete[] = $srcPath;
1338 foreach ( $ntuples as $i => $ntuple ) {
1339 list( , , $archiveRel ) = $ntuple;
1340 $archivePath = $this->
getZonePath(
'public' ) .
"/$archiveRel";
1342 $status->value[$i] =
'archived';
1344 $status->value[$i] =
'new';
1348 foreach ( $sourceFSFilesToDelete as
$file ) {
1349 Wikimedia\suppressWarnings();
1351 Wikimedia\restoreWarnings();
1368 $params = [
'dir' =>
$path ];
1369 if ( $this->isPrivate
1370 || $container === $this->zones[
'deleted'][
'container']
1371 || $container === $this->zones[
'temp'][
'container']
1373 # Take all available measures to prevent web accessibility of new deleted
1374 # directories, in case the user has not configured offline storage
1375 $params = [
'noAccess' =>
true,
'noListing' =>
true ] + $params;
1379 $status->merge( $this->backend->prepare( $params ) );
1394 $status->merge( $this->backend->clean(
1395 [
'dir' => $this->resolveToStoragePathIfVirtual( $dir ) ] ) );
1419 $paths = array_map( [ $this,
'resolveToStoragePathIfVirtual' ], $files );
1420 $this->backend->preloadFileStat( [
'srcs' => $paths ] );
1423 foreach ( $files as $key =>
$file ) {
1425 $result[$key] = $this->backend->fileExists( [
'src' =>
$path ] );
1441 public function delete( $srcRel, $archiveRel ) {
1444 return $this->
deleteBatch( [ [ $srcRel, $archiveRel ] ] );
1468 $status = $this->
initZones( [
'public',
'deleted' ] );
1469 if ( !$status->isOK() ) {
1478 foreach ( $sourceDestPairs as $pair ) {
1479 list( $srcRel, $archiveRel ) = $pair;
1481 throw new MWException( __METHOD__ .
':Validation error in $srcRel' );
1483 throw new MWException( __METHOD__ .
':Validation error in $archiveRel' );
1487 $srcPath =
"{$publicRoot}/$srcRel";
1490 $archivePath =
"{$deletedRoot}/{$archiveRel}";
1491 $archiveDir = dirname( $archivePath );
1495 return $this->
newFatal(
'directorycreateerror', $archiveDir );
1501 'dst' => $archivePath,
1504 'overwriteSame' =>
true
1511 $opts = [
'force' =>
true ];
1536 if ( strlen( $key ) < 31 ) {
1537 throw new MWException(
"Invalid storage key '$key'." );
1541 $path .= $key[$i] .
'/';
1556 if ( self::isVirtualUrl(
$path ) ) {
1573 return $this->backend->getLocalCopy( [
'src' =>
$path ] );
1587 return $this->backend->getLocalReference( [
'src' =>
$path ] );
1601 $props = $mwProps->getPropsFromPath( $fsFile->getPath(),
true );
1603 $props = $mwProps->newPlaceholderProps();
1618 return $this->backend->getFileTimestamp( [
'src' =>
$path ] );
1630 return $this->backend->getFileSize( [
'src' =>
$path ] );
1642 return $this->backend->getFileSha1Base36( [
'src' =>
$path ] );
1656 $params = [
'src' =>
$path,
'headers' => $headers,
'options' => $optHeaders ];
1659 ob_start(
null, 1048576 );
1660 ob_implicit_flush(
true );
1663 $status->merge( $this->backend->streamFile( $params ) );
1667 if ( ob_get_status() ) {
1695 $numDirs = 1 << ( $this->hashLevels * 4 );
1698 for ( $flatIndex = 0; $flatIndex < $numDirs; $flatIndex++ ) {
1699 $hexString = sprintf(
"%0{$this->hashLevels}x", $flatIndex );
1700 $path = $publicRoot;
1702 $path .=
'/' . substr( $hexString, 0, $hexPos + 1 );
1704 $iterator = $this->backend->getFileList( [
'dir' =>
$path ] );
1705 if ( $iterator ===
null ) {
1706 throw new MWException( __METHOD__ .
': could not get file listing for ' .
$path );
1708 foreach ( $iterator as
$name ) {
1710 call_user_func( $callback,
"{$path}/{$name}" );
1722 if ( strval( $filename ) ==
'' ) {
1735 switch ( $this->pathDisclosureProtection ) {
1738 $callback = [ $this,
'passThrough' ];
1741 $callback = [ $this,
'paranoidClean' ];
1774 $status = Status::newFatal( $message, ...$parameters );
1787 $status = Status::newGood( $value );
1828 return wfMessageFallback(
'shared-repo-name-' . $this->name,
'shared-repo' )->text();
1839 if ( strlen(
$name ) > $this->abbrvThreshold ) {
1841 $name = (
$ext ==
'' ) ?
'thumbnail' :
"thumbnail.$ext";
1853 return $this->
getName() ==
'local';
1880 return $this->wanCache->makeKey( ...
$args );
1893 'name' =>
"{$this->name}-temp",
1894 'backend' => $this->backend,
1899 'container' => $this->zones[
'temp'][
'container'],
1900 'directory' => $this->zones[
'temp'][
'directory']
1903 'container' => $this->zones[
'temp'][
'container'],
1904 'directory' => $this->zones[
'temp'][
'directory'] ==
''
1906 : $this->zones[
'temp'][
'directory'] .
'/thumb'
1909 'container' => $this->zones[
'temp'][
'container'],
1910 'directory' => $this->zones[
'temp'][
'directory'] ==
''
1912 : $this->zones[
'temp'][
'directory'] .
'/transcoded'
1954 $optionalSettings = [
1955 'url',
'thumbUrl',
'initialCapital',
'descBaseUrl',
'scriptDirUrl',
'articleUrl',
1956 'fetchDescription',
'descriptionCacheExpiry',
'favicon'
1958 foreach ( $optionalSettings as $k ) {
1959 if ( isset( $this->$k ) ) {
1960 $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...
getSharedCacheKey(... $args)
Get a key on the primary cache for this repository.
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.
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.
newFatal( $message,... $parameters)
Create a new fatal error.
getThumbProxyUrl()
Get the URL thumb.php requests are being proxied to.
getZoneLocation( $zone)
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.
getLocalCacheKey(... $args)
Get a key for this repo in the local cache domain.
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.
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.
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