133 protected $fileFactory = [ UnregisteredLocalFile::class,
'newFromTitle' ];
171 || !array_key_exists(
'name', $info )
172 || !array_key_exists(
'backend', $info )
175 " requires an array of options having both 'name' and 'backend' keys.\n" );
179 $this->name = $info[
'name'];
181 $this->backend = $info[
'backend'];
184 MediaWikiServices::getInstance()->getFileBackendGroup()->get( $info[
'backend'] );
188 $optionalSettings = [
189 'descBaseUrl',
'scriptDirUrl',
'articleUrl',
'fetchDescription',
190 'thumbScriptUrl',
'pathDisclosureProtection',
'descriptionCacheExpiry',
191 'favicon',
'thumbProxyUrl',
'thumbProxySecret',
'disableLocalTransform'
193 foreach ( $optionalSettings as $var ) {
194 if ( isset( $info[$var] ) ) {
195 $this->$var = $info[$var];
201 MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized(
NS_FILE );
202 $this->initialCapital = $info[
'initialCapital'] ?? $localCapitalLinks;
203 if ( $localCapitalLinks && !$this->initialCapital ) {
211 throw new InvalidArgumentException(
212 'File repos with initial capital false are not allowed on wikis where the File ' .
213 'namespace has initial capital true' );
216 $this->url = $info[
'url'] ??
false;
217 if ( isset( $info[
'thumbUrl'] ) ) {
218 $this->thumbUrl = $info[
'thumbUrl'];
220 $this->thumbUrl = $this->url ?
"{$this->url}/thumb" :
false;
222 $this->hashLevels = $info[
'hashLevels'] ?? 2;
224 $this->transformVia404 = !empty( $info[
'transformVia404'] );
225 $this->abbrvThreshold = $info[
'abbrvThreshold'] ?? 255;
226 $this->isPrivate = !empty( $info[
'isPrivate'] );
228 $this->zones = $info[
'zones'] ?? [];
229 foreach ( [
'public',
'thumb',
'transcoded',
'temp',
'deleted' ] as $zone ) {
230 if ( !isset( $this->zones[$zone][
'container'] ) ) {
231 $this->zones[$zone][
'container'] =
"{$this->name}-{$zone}";
233 if ( !isset( $this->zones[$zone][
'directory'] ) ) {
234 $this->zones[$zone][
'directory'] =
'';
236 if ( !isset( $this->zones[$zone][
'urlsByExt'] ) ) {
237 $this->zones[$zone][
'urlsByExt'] = [];
243 $this->wanCache = $info[
'wanCache'] ?? WANObjectCache::newEmpty();
262 return $this->backend->getReadOnlyReason();
274 foreach ( (array)$doZones as $zone ) {
276 if ( $root ===
null ) {
277 throw new MWException(
"No '$zone' zone defined in the {$this->name} repo." );
291 return substr(
$url, 0, 9 ) ==
'mwrepo://';
304 if ( $suffix !==
false ) {
305 $path .=
'/' . rawurlencode( $suffix );
319 if ( in_array( $zone, [
'public',
'thumb',
'transcoded' ] ) ) {
321 if (
$ext !==
null && isset( $this->zones[$zone][
'urlsByExt'][
$ext] ) ) {
324 return $this->zones[$zone][
'urlsByExt'][
$ext];
325 } elseif ( isset( $this->zones[$zone][
'url'] ) ) {
327 return $this->zones[$zone][
'url'];
339 return "{$this->url}/transcoded";
361 if ( substr(
$url, 0, 9 ) !=
'mwrepo://' ) {
362 throw new MWException( __METHOD__ .
': unknown protocol' );
364 $bits = explode(
'/', substr(
$url, 9 ), 3 );
365 if ( count( $bits ) != 3 ) {
366 throw new MWException( __METHOD__ .
": invalid mwrepo URL: $url" );
368 list( $repo, $zone, $rel ) = $bits;
369 if ( $repo !== $this->name ) {
370 throw new MWException( __METHOD__ .
": fetching from a foreign repo is not supported" );
374 throw new MWException( __METHOD__ .
": invalid zone: $zone" );
377 return $base .
'/' . rawurldecode( $rel );
387 if ( !isset( $this->zones[$zone] ) ) {
388 return [
null, null ];
391 return [ $this->zones[$zone][
'container'], $this->zones[$zone][
'directory'] ];
402 if ( $container ===
null ||
$base ===
null ) {
405 $backendName = $this->backend->getName();
410 return "mwstore://$backendName/{$container}{$base}";
430 if ( $this->oldFileFactory ) {
431 return call_user_func( $this->oldFileFactory,
$title, $this, $time );
436 return call_user_func( $this->fileFactory,
$title, $this );
460 if ( !empty( $options[
'private'] ) && !( $options[
'private'] instanceof
Authority ) ) {
461 throw new InvalidArgumentException(
462 __METHOD__ .
' called with the `private` option set to something ' .
463 'other than an Authority object'
471 if ( isset( $options[
'bypassCache'] ) ) {
472 $options[
'latest'] = $options[
'bypassCache'];
474 $time = $options[
'time'] ??
false;
475 $flags = !empty( $options[
'latest'] ) ? File::READ_LATEST : 0;
476 # First try the current version of the file to see if it precedes the timestamp
481 $img->load( $flags );
482 if ( $img->exists() && ( !$time || $img->getTimestamp() == $time ) ) {
485 # Now try an old version of the file
486 if ( $time !==
false ) {
489 $img->load( $flags );
490 if ( $img->exists() ) {
491 if ( !$img->isDeleted( File::DELETED_FILE ) ) {
495 !empty( $options[
'private'] ) &&
496 $img->userCan( File::DELETED_FILE, $options[
'private'] )
505 if ( !empty( $options[
'ignoreRedirect'] ) ) {
510 $img = $this->
newFile( $redir );
514 $img->load( $flags );
515 if ( $img->exists() ) {
516 $img->redirectedFrom(
$title->getDBkey() );
544 foreach ( $items as $item ) {
545 if ( is_array( $item ) ) {
548 unset( $options[
'title'] );
551 !empty( $options[
'private'] ) &&
552 !( $options[
'private'] instanceof
Authority )
554 $options[
'private'] = RequestContext::getMain()->getAuthority();
562 $searchName = File::normalizeTitle(
$title )->getDBkey();
563 if ( $flags & self::NAME_AND_TIME_ONLY ) {
564 $result[$searchName] = [
565 'title' =>
$file->getTitle()->getDBkey(),
566 'timestamp' =>
$file->getTimestamp()
569 $result[$searchName] =
$file;
588 if ( !empty( $options[
'private'] ) && !( $options[
'private'] instanceof
Authority ) ) {
589 throw new InvalidArgumentException(
590 __METHOD__ .
' called with the `private` option set to something ' .
591 'other than an Authority object'
595 $time = $options[
'time'] ??
false;
596 # First try to find a matching current version of a file...
597 if ( !$this->fileFactoryKey ) {
600 $img = call_user_func( $this->fileFactoryKey, $sha1, $this, $time );
601 if ( $img && $img->exists() ) {
604 # Now try to find a matching old version of a file...
605 if ( $time !==
false && $this->oldFileFactoryKey ) {
606 $img = call_user_func( $this->oldFileFactoryKey, $sha1, $this, $time );
607 if ( $img && $img->exists() ) {
608 if ( !$img->isDeleted( File::DELETED_FILE ) ) {
612 !empty( $options[
'private'] ) &&
613 $img->userCan( File::DELETED_FILE, $options[
'private'] )
646 if ( count( $files ) ) {
647 $result[$hash] = $files;
720 $this->initialCapital !=
721 MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized(
NS_FILE )
724 if ( $this->initialCapital ) {
725 $name = MediaWikiServices::getInstance()->getContentLanguage()->ucfirst(
$name );
762 $parts = explode(
'!', $suffix, 2 );
763 $name = $parts[1] ?? $suffix;
773 if ( $levels == 0 ) {
776 $hash = md5(
$name );
778 for ( $i = 1; $i <= $levels; $i++ ) {
779 $path .= substr( $hash, 0, $i ) .
'/';
811 public function makeUrl( $query =
'', $entry =
'index' ) {
812 if ( isset( $this->scriptDirUrl ) ) {
813 return wfAppendQuery(
"{$this->scriptDirUrl}/{$entry}.php", $query );
833 if ( $this->descBaseUrl !==
null ) {
834 # "http://example.com/wiki/File:"
835 return $this->descBaseUrl . $encName;
837 if ( $this->articleUrl !==
null ) {
838 # "http://example.com/wiki/$1"
839 # We use "Image:" as the canonical namespace for
840 # compatibility across all MediaWiki versions.
841 return str_replace(
'$1',
842 "Image:$encName", $this->articleUrl );
844 if ( $this->scriptDirUrl !==
null ) {
845 # "http://example.com/w"
846 # We use "Image:" as the canonical namespace for
847 # compatibility across all MediaWiki versions,
848 # and just sort of hope index.php is right. ;)
849 return $this->
makeUrl(
"title=Image:$encName" );
866 $query =
'action=render';
867 if (
$lang !==
null ) {
868 $query .=
'&uselang=' . urlencode(
$lang );
870 if ( isset( $this->scriptDirUrl ) ) {
891 if ( isset( $this->scriptDirUrl ) ) {
894 return $this->
makeUrl(
'title=MediaWiki:Filepage.css&action=raw&ctype=text/css' );
917 public function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
920 $status = $this->
storeBatch( [ [ $srcPath, $dstZone, $dstRel ] ], $flags );
921 if ( $status->successCount == 0 ) {
922 $status->setOK(
false );
945 if ( $flags & self::DELETE_SOURCE ) {
946 throw new InvalidArgumentException(
"DELETE_SOURCE not supported in " . __METHOD__ );
954 foreach ( $triplets as $triplet ) {
955 list( $src, $dstZone, $dstRel ) = $triplet;
956 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
958 .
"( \$src='$srcPath', \$dstZone='$dstZone', \$dstRel='$dstRel' )"
961 if ( $src instanceof
FSFile ) {
973 throw new MWException(
'Validation error in $dstRel' );
975 $dstPath =
"$root/$dstRel";
976 $dstDir = dirname( $dstPath );
979 return $this->
newFatal(
'directorycreateerror', $dstDir );
993 $opts = [
'force' =>
true ];
994 if ( $flags & self::SKIP_LOCKING ) {
995 $opts[
'nonLocking'] =
true;
1017 foreach ( $files as
$path ) {
1018 if ( is_array(
$path ) ) {
1020 list( $zone, $rel ) =
$path;
1026 $operations[] = [
'op' =>
'delete',
'src' =>
$path ];
1029 $opts = [
'force' =>
true ];
1030 if ( $flags & self::SKIP_LOCKING ) {
1031 $opts[
'nonLocking'] =
true;
1034 return $status->merge( $this->backend->doOperations( $operations, $opts ) );
1075 foreach ( $triples as $triple ) {
1076 list( $src, $dst ) = $triple;
1077 if ( $src instanceof
FSFile ) {
1085 if ( !isset( $triple[2] ) ) {
1087 } elseif ( is_string( $triple[2] ) ) {
1089 $headers = [
'Content-Disposition' => $triple[2] ];
1090 } elseif ( is_array( $triple[2] ) && isset( $triple[2][
'headers'] ) ) {
1091 $headers = $triple[2][
'headers'];
1100 'headers' => $headers
1105 return $status->merge( $this->backend->doQuickOperations( $operations ) );
1128 return $this->
newGood()->merge(
1129 $this->backend->clean(
1130 [
'dir' => $this->resolveToStoragePathIfVirtual( $dir ) ]
1146 foreach ( $paths as
$path ) {
1150 'ignoreMissingSource' =>
true
1153 $status->merge( $this->backend->doQuickOperations( $operations ) );
1171 $date = MWTimestamp::getInstance()->format(
'YmdHis' );
1173 $dstUrlRel = $hashPath . $date .
'!' . rawurlencode( $originalName );
1174 $virtualUrl = $this->
getVirtualUrl(
'temp' ) .
'/' . $dstUrlRel;
1176 $result = $this->
quickImport( $srcPath, $virtualUrl );
1177 $result->value = $virtualUrl;
1192 if ( substr( $virtualUrl, 0, strlen( $temp ) ) != $temp ) {
1193 wfDebug( __METHOD__ .
": Invalid temp virtual URL" );
1198 return $this->
quickPurge( $virtualUrl )->isOK();
1210 public function concatenate( array $srcPaths, $dstPath, $flags = 0 ) {
1216 foreach ( $srcPaths as $srcPath ) {
1223 $params = [
'srcs' => $sources,
'dst' => $dstPath ];
1224 $status->merge( $this->backend->concatenate( $params ) );
1225 if ( !$status->isOK() ) {
1230 if ( $flags & self::DELETE_SOURCE ) {
1235 $status->setResult(
true );
1264 $src, $dstRel, $archiveRel, $flags = 0, array $options = []
1269 [ [ $src, $dstRel, $archiveRel, $options ] ], $flags );
1270 if ( $status->successCount == 0 ) {
1271 $status->setOK(
false );
1273 $status->value = $status->value[0] ??
false;
1296 if ( !$status->isOK() ) {
1300 $status = $this->
newGood( [] );
1303 $sourceFSFilesToDelete = [];
1305 foreach ( $ntuples as $ntuple ) {
1306 list( $src, $dstRel, $archiveRel ) = $ntuple;
1307 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
1309 $options = $ntuple[3] ?? [];
1313 throw new MWException(
'Validation error in $dstRel' );
1316 throw new MWException(
'Validation error in $archiveRel' );
1320 $dstPath =
"$publicRoot/$dstRel";
1321 $archivePath =
"$publicRoot/$archiveRel";
1323 $dstDir = dirname( $dstPath );
1324 $archiveDir = dirname( $archivePath );
1327 return $this->
newFatal(
'directorycreateerror', $dstDir );
1330 return $this->
newFatal(
'directorycreateerror', $archiveDir );
1334 $headers = $options[
'headers'] ?? [];
1345 'dst' => $archivePath,
1346 'ignoreMissingSource' =>
true
1355 'overwrite' =>
true,
1356 'headers' => $headers
1363 'overwrite' =>
true,
1364 'headers' => $headers
1366 if ( $flags & self::DELETE_SOURCE ) {
1367 $sourceFSFilesToDelete[] = $srcPath;
1375 foreach ( $ntuples as $i => $ntuple ) {
1376 list( , , $archiveRel ) = $ntuple;
1377 $archivePath = $this->
getZonePath(
'public' ) .
"/$archiveRel";
1379 $status->value[$i] =
'archived';
1381 $status->value[$i] =
'new';
1385 foreach ( $sourceFSFilesToDelete as
$file ) {
1386 Wikimedia\suppressWarnings();
1388 Wikimedia\restoreWarnings();
1405 $params = [
'dir' =>
$path ];
1406 if ( $this->isPrivate
1407 || $container === $this->zones[
'deleted'][
'container']
1408 || $container === $this->zones[
'temp'][
'container']
1410 # Take all available measures to prevent web accessibility of new deleted
1411 # directories, in case the user has not configured offline storage
1412 $params = [
'noAccess' =>
true,
'noListing' =>
true ] + $params;
1415 return $this->
newGood()->merge( $this->backend->prepare( $params ) );
1427 return $this->
newGood()->merge(
1428 $this->backend->clean(
1429 [
'dir' => $this->resolveToStoragePathIfVirtual( $dir ) ]
1453 $paths = array_map( [ $this,
'resolveToStoragePathIfVirtual' ], $files );
1454 $this->backend->preloadFileStat( [
'srcs' => $paths ] );
1457 foreach ( $files as $key =>
$file ) {
1459 $result[$key] = $this->backend->fileExists( [
'src' =>
$path ] );
1475 public function delete( $srcRel, $archiveRel ) {
1478 return $this->
deleteBatch( [ [ $srcRel, $archiveRel ] ] );
1502 $status = $this->
initZones( [
'public',
'deleted' ] );
1503 if ( !$status->isOK() ) {
1512 foreach ( $sourceDestPairs as [ $srcRel, $archiveRel ] ) {
1514 throw new MWException( __METHOD__ .
':Validation error in $srcRel' );
1516 throw new MWException( __METHOD__ .
':Validation error in $archiveRel' );
1520 $srcPath =
"{$publicRoot}/$srcRel";
1523 $archivePath =
"{$deletedRoot}/{$archiveRel}";
1524 $archiveDir = dirname( $archivePath );
1528 return $this->
newFatal(
'directorycreateerror', $archiveDir );
1534 'dst' => $archivePath,
1537 'overwriteSame' =>
true
1544 $opts = [
'force' =>
true ];
1567 if ( strlen( $key ) < 31 ) {
1568 throw new MWException(
"Invalid storage key '$key'." );
1572 $path .= $key[$i] .
'/';
1587 if ( self::isVirtualUrl(
$path ) ) {
1604 return $this->backend->getLocalCopy( [
'src' =>
$path ] );
1618 return $this->backend->getLocalReference( [
'src' =>
$path ] );
1632 $props = $mwProps->getPropsFromPath( $fsFile->getPath(),
true );
1634 $props = $mwProps->newPlaceholderProps();
1649 return $this->backend->getFileTimestamp( [
'src' =>
$path ] );
1661 return $this->backend->getFileSize( [
'src' =>
$path ] );
1673 return $this->backend->getFileSha1Base36( [
'src' =>
$path ] );
1687 $params = [
'src' =>
$path,
'headers' => $headers,
'options' => $optHeaders ];
1690 ob_start(
null, 1048576 );
1691 ob_implicit_flush(
true );
1693 $status = $this->
newGood()->merge( $this->backend->streamFile( $params ) );
1697 if ( ob_get_status() ) {
1725 $numDirs = 1 << ( $this->hashLevels * 4 );
1728 for ( $flatIndex = 0; $flatIndex < $numDirs; $flatIndex++ ) {
1729 $hexString = sprintf(
"%0{$this->hashLevels}x", $flatIndex );
1730 $path = $publicRoot;
1732 $path .=
'/' . substr( $hexString, 0, $hexPos + 1 );
1734 $iterator = $this->backend->getFileList( [
'dir' =>
$path ] );
1735 if ( $iterator ===
null ) {
1736 throw new MWException( __METHOD__ .
': could not get file listing for ' .
$path );
1738 foreach ( $iterator as
$name ) {
1740 call_user_func( $callback,
"{$path}/{$name}" );
1752 if ( strval( $filename ) ==
'' ) {
1765 switch ( $this->pathDisclosureProtection ) {
1768 $callback = [ $this,
'passThrough' ];
1771 $callback = [ $this,
'paranoidClean' ];
1804 $status = Status::newFatal( $message, ...$parameters );
1817 $status = Status::newGood( $value );
1858 return wfMessageFallback(
'shared-repo-name-' . $this->name,
'shared-repo' )->text();
1869 if ( strlen(
$name ) > $this->abbrvThreshold ) {
1871 $name = (
$ext ==
'' ) ?
'thumbnail' :
"thumbnail.$ext";
1883 return $this->
getName() ==
'local';
1913 return $this->wanCache->makeKey(
1914 'filerepo-' . $kClassSuffix,
1930 'name' =>
"{$this->name}-temp",
1931 'backend' => $this->backend,
1936 'container' => $this->zones[
'temp'][
'container'],
1937 'directory' => $this->zones[
'temp'][
'directory']
1940 'container' => $this->zones[
'temp'][
'container'],
1941 'directory' => $this->zones[
'temp'][
'directory'] ==
''
1943 : $this->zones[
'temp'][
'directory'] .
'/thumb'
1946 'container' => $this->zones[
'temp'][
'container'],
1947 'directory' => $this->zones[
'temp'][
'directory'] ==
''
1949 : $this->zones[
'temp'][
'directory'] .
'/transcoded'
1991 $optionalSettings = [
1992 'url',
'thumbUrl',
'initialCapital',
'descBaseUrl',
'scriptDirUrl',
'articleUrl',
1993 'fetchDescription',
'descriptionCacheExpiry',
'favicon'
1995 foreach ( $optionalSettings as $k ) {
1996 if ( isset( $this->$k ) ) {
1997 $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.
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.
checkRedirect( $title)
Checks if there is a redirect named as $title.
getDisplayName()
Get the human-readable name of the repo.
getSharedCacheKey( $kClassSuffix,... $components)
Get a global, repository-qualified, WAN cache key.
getLocalCacheKey( $kClassSuffix,... $components)
Get a site-local, repository-qualified, WAN cache key.
bool $disableLocalTransform
Disable local image scaling.
storeBatch(array $triplets, $flags=0)
Store a batch of files.
enumFiles( $callback)
Call a callback function for every public regular file in the repository.
canTransformLocally()
Returns true if the repository can transform files locally.
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.
getUploadStash(UserIdentity $user=null)
Get an UploadStash associated with this repo.
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.
getNameFromTitle( $title)
Get the name of a file from its title.
invalidateImageRedirect( $title)
Invalidates image redirect cache related to that image Doesn't do anything for repositories that don'...
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.
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.
callable false $oldFileFactory
Override these in the base class.
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()
UploadStash is intended to accomplish a few things:
Multi-datacenter aware caching interface.
Interface for objects (potentially) representing an editable wiki page.
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