Go to the documentation of this file.
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'] = [];
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 );
451 if ( !empty( $options[
'private'] ) && !( $options[
'private'] instanceof
User ) ) {
452 throw new InvalidArgumentException(
453 __METHOD__ .
' called with the `private` option set to something ' .
454 'other than a User object'
462 if ( isset( $options[
'bypassCache'] ) ) {
463 $options[
'latest'] = $options[
'bypassCache'];
465 $time = $options[
'time'] ??
false;
466 $flags = !empty( $options[
'latest'] ) ? File::READ_LATEST : 0;
467 # First try the current version of the file to see if it precedes the timestamp
472 $img->load( $flags );
473 if ( $img->exists() && ( !$time || $img->getTimestamp() == $time ) ) {
476 # Now try an old version of the file
477 if ( $time !==
false ) {
480 $img->load( $flags );
481 if ( $img->exists() ) {
486 !empty( $options[
'private'] ) &&
496 if ( !empty( $options[
'ignoreRedirect'] ) ) {
501 $img = $this->
newFile( $redir );
505 $img->load( $flags );
506 if ( $img->exists() ) {
507 $img->redirectedFrom(
$title->getDBkey() );
535 foreach ( $items as $item ) {
536 if ( is_array( $item ) ) {
539 unset( $options[
'title'] );
542 !empty( $options[
'private'] ) &&
543 !( $options[
'private'] instanceof
User )
554 if ( $flags & self::NAME_AND_TIME_ONLY ) {
555 $result[$searchName] = [
556 'title' =>
$file->getTitle()->getDBkey(),
557 'timestamp' =>
$file->getTimestamp()
560 $result[$searchName] =
$file;
579 if ( !empty( $options[
'private'] ) && !( $options[
'private'] instanceof
User ) ) {
580 throw new InvalidArgumentException(
581 __METHOD__ .
' called with the `private` option set to something ' .
582 'other than a User object'
586 $time = $options[
'time'] ??
false;
587 # First try to find a matching current version of a file...
588 if ( !$this->fileFactoryKey ) {
591 $img = call_user_func( $this->fileFactoryKey, $sha1, $this, $time );
592 if ( $img && $img->exists() ) {
595 # Now try to find a matching old version of a file...
596 if ( $time !==
false && $this->oldFileFactoryKey ) {
597 $img = call_user_func( $this->oldFileFactoryKey, $sha1, $this, $time );
598 if ( $img && $img->exists() ) {
603 !empty( $options[
'private'] ) &&
637 if ( count( $files ) ) {
638 $result[$hash] = $files;
701 $this->initialCapital !=
702 MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized(
NS_FILE )
705 if ( $this->initialCapital ) {
706 $name = MediaWikiServices::getInstance()->getContentLanguage()->ucfirst(
$name );
743 $parts = explode(
'!', $suffix, 2 );
744 $name = $parts[1] ?? $suffix;
754 if ( $levels == 0 ) {
757 $hash = md5(
$name );
759 for ( $i = 1; $i <= $levels; $i++ ) {
760 $path .= substr( $hash, 0, $i ) .
'/';
792 public function makeUrl( $query =
'', $entry =
'index' ) {
793 if ( isset( $this->scriptDirUrl ) ) {
794 return wfAppendQuery(
"{$this->scriptDirUrl}/{$entry}.php", $query );
814 if ( $this->descBaseUrl !==
null ) {
815 # "http://example.com/wiki/File:"
816 return $this->descBaseUrl . $encName;
818 if ( $this->articleUrl !==
null ) {
819 # "http://example.com/wiki/$1"
820 # We use "Image:" as the canonical namespace for
821 # compatibility across all MediaWiki versions.
822 return str_replace(
'$1',
823 "Image:$encName", $this->articleUrl );
825 if ( $this->scriptDirUrl !==
null ) {
826 # "http://example.com/w"
827 # We use "Image:" as the canonical namespace for
828 # compatibility across all MediaWiki versions,
829 # and just sort of hope index.php is right. ;)
830 return $this->
makeUrl(
"title=Image:$encName" );
847 $query =
'action=render';
848 if (
$lang !==
null ) {
849 $query .=
'&uselang=' . urlencode(
$lang );
851 if ( isset( $this->scriptDirUrl ) ) {
872 if ( isset( $this->scriptDirUrl ) ) {
875 return $this->
makeUrl(
'title=MediaWiki:Filepage.css&action=raw&ctype=text/css' );
898 public function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
901 $status = $this->
storeBatch( [ [ $srcPath, $dstZone, $dstRel ] ], $flags );
902 if ( $status->successCount == 0 ) {
903 $status->setOK(
false );
926 if ( $flags & self::DELETE_SOURCE ) {
927 throw new InvalidArgumentException(
"DELETE_SOURCE not supported in " . __METHOD__ );
935 foreach ( $triplets as $triplet ) {
936 list( $src, $dstZone, $dstRel ) = $triplet;
937 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
939 .
"( \$src='$srcPath', \$dstZone='$dstZone', \$dstRel='$dstRel' )"
942 if ( $src instanceof
FSFile ) {
954 throw new MWException(
'Validation error in $dstRel' );
956 $dstPath =
"$root/$dstRel";
957 $dstDir = dirname( $dstPath );
960 return $this->
newFatal(
'directorycreateerror', $dstDir );
969 'overwriteSame' => ( $flags & self::OVERWRITE_SAME ) ?
true :
false,
974 $opts = [
'force' =>
true ];
975 if ( $flags & self::SKIP_LOCKING ) {
976 $opts[
'nonLocking'] =
true;
999 foreach ( $files as
$path ) {
1000 if ( is_array(
$path ) ) {
1002 list( $zone, $rel ) =
$path;
1008 $operations[] = [
'op' =>
'delete',
'src' =>
$path ];
1011 $opts = [
'force' =>
true ];
1012 if ( $flags & self::SKIP_LOCKING ) {
1013 $opts[
'nonLocking'] =
true;
1015 $status->merge( $this->backend->doOperations( $operations, $opts ) );
1058 foreach ( $triples as $triple ) {
1059 list( $src, $dst ) = $triple;
1060 if ( $src instanceof
FSFile ) {
1068 if ( !isset( $triple[2] ) ) {
1070 } elseif ( is_string( $triple[2] ) ) {
1072 $headers = [
'Content-Disposition' => $triple[2] ];
1073 } elseif ( is_array( $triple[2] ) && isset( $triple[2][
'headers'] ) ) {
1074 $headers = $triple[2][
'headers'];
1083 'headers' => $headers
1087 $status->merge( $this->backend->doQuickOperations( $operations ) );
1113 $status->merge( $this->backend->clean(
1114 [
'dir' => $this->resolveToStoragePathIfVirtual( $dir ) ] ) );
1130 foreach ( $paths as
$path ) {
1134 'ignoreMissingSource' =>
true
1137 $status->merge( $this->backend->doQuickOperations( $operations ) );
1157 $dstUrlRel = $hashPath . $date .
'!' . rawurlencode( $originalName );
1158 $virtualUrl = $this->
getVirtualUrl(
'temp' ) .
'/' . $dstUrlRel;
1160 $result = $this->
quickImport( $srcPath, $virtualUrl );
1161 $result->value = $virtualUrl;
1176 if ( substr( $virtualUrl, 0, strlen( $temp ) ) != $temp ) {
1177 wfDebug( __METHOD__ .
": Invalid temp virtual URL" );
1182 return $this->
quickPurge( $virtualUrl )->isOK();
1194 public function concatenate( array $srcPaths, $dstPath, $flags = 0 ) {
1200 foreach ( $srcPaths as $srcPath ) {
1207 $params = [
'srcs' => $sources,
'dst' => $dstPath ];
1208 $status->merge( $this->backend->concatenate( $params ) );
1209 if ( !$status->isOK() ) {
1214 if ( $flags & self::DELETE_SOURCE ) {
1219 $status->setResult(
true );
1248 $src, $dstRel, $archiveRel, $flags = 0, array $options = []
1253 [ [ $src, $dstRel, $archiveRel, $options ] ], $flags );
1254 if ( $status->successCount == 0 ) {
1255 $status->setOK(
false );
1257 $status->value = $status->value[0] ??
false;
1280 if ( !$status->isOK() ) {
1284 $status = $this->
newGood( [] );
1287 $sourceFSFilesToDelete = [];
1289 foreach ( $ntuples as $ntuple ) {
1290 list( $src, $dstRel, $archiveRel ) = $ntuple;
1291 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
1293 $options = $ntuple[3] ?? [];
1297 throw new MWException(
'Validation error in $dstRel' );
1300 throw new MWException(
'Validation error in $archiveRel' );
1304 $dstPath =
"$publicRoot/$dstRel";
1305 $archivePath =
"$publicRoot/$archiveRel";
1307 $dstDir = dirname( $dstPath );
1308 $archiveDir = dirname( $archivePath );
1311 return $this->
newFatal(
'directorycreateerror', $dstDir );
1314 return $this->
newFatal(
'directorycreateerror', $archiveDir );
1318 $headers = $options[
'headers'] ?? [];
1329 'dst' => $archivePath,
1330 'ignoreMissingSource' =>
true
1339 'overwrite' =>
true,
1340 'headers' => $headers
1347 'overwrite' =>
true,
1348 'headers' => $headers
1350 if ( $flags & self::DELETE_SOURCE ) {
1351 $sourceFSFilesToDelete[] = $srcPath;
1359 foreach ( $ntuples as $i => $ntuple ) {
1360 list( , , $archiveRel ) = $ntuple;
1361 $archivePath = $this->
getZonePath(
'public' ) .
"/$archiveRel";
1363 $status->value[$i] =
'archived';
1365 $status->value[$i] =
'new';
1369 foreach ( $sourceFSFilesToDelete as
$file ) {
1370 Wikimedia\suppressWarnings();
1372 Wikimedia\restoreWarnings();
1389 $params = [
'dir' =>
$path ];
1390 if ( $this->isPrivate
1391 || $container === $this->zones[
'deleted'][
'container']
1392 || $container === $this->zones[
'temp'][
'container']
1394 # Take all available measures to prevent web accessibility of new deleted
1395 # directories, in case the user has not configured offline storage
1396 $params = [
'noAccess' =>
true,
'noListing' =>
true ] + $params;
1400 $status->merge( $this->backend->prepare( $params ) );
1415 $status->merge( $this->backend->clean(
1416 [
'dir' => $this->resolveToStoragePathIfVirtual( $dir ) ] ) );
1440 $paths = array_map( [ $this,
'resolveToStoragePathIfVirtual' ], $files );
1441 $this->backend->preloadFileStat( [
'srcs' => $paths ] );
1444 foreach ( $files as $key =>
$file ) {
1446 $result[$key] = $this->backend->fileExists( [
'src' =>
$path ] );
1462 public function delete( $srcRel, $archiveRel ) {
1465 return $this->
deleteBatch( [ [ $srcRel, $archiveRel ] ] );
1489 $status = $this->
initZones( [
'public',
'deleted' ] );
1490 if ( !$status->isOK() ) {
1499 foreach ( $sourceDestPairs as [ $srcRel, $archiveRel ] ) {
1501 throw new MWException( __METHOD__ .
':Validation error in $srcRel' );
1503 throw new MWException( __METHOD__ .
':Validation error in $archiveRel' );
1507 $srcPath =
"{$publicRoot}/$srcRel";
1510 $archivePath =
"{$deletedRoot}/{$archiveRel}";
1511 $archiveDir = dirname( $archivePath );
1515 return $this->
newFatal(
'directorycreateerror', $archiveDir );
1521 'dst' => $archivePath,
1524 'overwriteSame' =>
true
1531 $opts = [
'force' =>
true ];
1556 if ( strlen( $key ) < 31 ) {
1557 throw new MWException(
"Invalid storage key '$key'." );
1561 $path .= $key[$i] .
'/';
1576 if ( self::isVirtualUrl(
$path ) ) {
1593 return $this->backend->getLocalCopy( [
'src' =>
$path ] );
1607 return $this->backend->getLocalReference( [
'src' =>
$path ] );
1621 $props = $mwProps->getPropsFromPath( $fsFile->getPath(),
true );
1623 $props = $mwProps->newPlaceholderProps();
1638 return $this->backend->getFileTimestamp( [
'src' =>
$path ] );
1650 return $this->backend->getFileSize( [
'src' =>
$path ] );
1662 return $this->backend->getFileSha1Base36( [
'src' =>
$path ] );
1676 $params = [
'src' =>
$path,
'headers' => $headers,
'options' => $optHeaders ];
1679 ob_start(
null, 1048576 );
1680 ob_implicit_flush(
true );
1683 $status->merge( $this->backend->streamFile( $params ) );
1687 if ( ob_get_status() ) {
1715 $numDirs = 1 << ( $this->hashLevels * 4 );
1718 for ( $flatIndex = 0; $flatIndex < $numDirs; $flatIndex++ ) {
1719 $hexString = sprintf(
"%0{$this->hashLevels}x", $flatIndex );
1720 $path = $publicRoot;
1722 $path .=
'/' . substr( $hexString, 0, $hexPos + 1 );
1724 $iterator = $this->backend->getFileList( [
'dir' =>
$path ] );
1725 if ( $iterator ===
null ) {
1726 throw new MWException( __METHOD__ .
': could not get file listing for ' .
$path );
1728 foreach ( $iterator as
$name ) {
1730 call_user_func( $callback,
"{$path}/{$name}" );
1742 if ( strval( $filename ) ==
'' ) {
1755 switch ( $this->pathDisclosureProtection ) {
1758 $callback = [ $this,
'passThrough' ];
1761 $callback = [ $this,
'paranoidClean' ];
1848 return wfMessageFallback(
'shared-repo-name-' . $this->name,
'shared-repo' )->text();
1859 if ( strlen(
$name ) > $this->abbrvThreshold ) {
1861 $name = (
$ext ==
'' ) ?
'thumbnail' :
"thumbnail.$ext";
1873 return $this->
getName() ==
'local';
1903 return $this->wanCache->makeKey(
1904 'filerepo-' . $kClassSuffix,
1920 'name' =>
"{$this->name}-temp",
1921 'backend' => $this->backend,
1926 'container' => $this->zones[
'temp'][
'container'],
1927 'directory' => $this->zones[
'temp'][
'directory']
1930 'container' => $this->zones[
'temp'][
'container'],
1931 'directory' => $this->zones[
'temp'][
'directory'] ==
''
1933 : $this->zones[
'temp'][
'directory'] .
'/thumb'
1936 'container' => $this->zones[
'temp'][
'container'],
1937 'directory' => $this->zones[
'temp'][
'directory'] ==
''
1939 : $this->zones[
'temp'][
'directory'] .
'/transcoded'
1942 'hashLevels' => $this->hashLevels,
1981 $optionalSettings = [
1982 'url',
'thumbUrl',
'initialCapital',
'descBaseUrl',
'scriptDirUrl',
'articleUrl',
1983 'fetchDescription',
'descriptionCacheExpiry',
'favicon'
1985 foreach ( $optionalSettings as $k ) {
1986 if ( isset( $this->$k ) ) {
1987 $ret[$k] = $this->$k;
static splitStoragePath( $storagePath)
Split a storage path into a backend name, a container name, and a relative file path.
doOperations(array $ops, array $opts=[])
This is the main entry point into the backend for write operations.
getReadOnlyReason()
Get an explanatory message if this repo is read-only.
initZones( $doZones=[])
Check if a single zone or list of zones is defined for usage.
wfMessageFallback(... $keys)
This function accepts multiple message keys and returns a message instance for the first message whic...
passThrough( $param)
Path disclosure protection function.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
findBySha1( $hash)
Get an array or iterator of file objects for files that have a given SHA-1 content hash.
getThumbScriptUrl()
Get the URL of thumb.php.
newGood( $value=null)
Create a new good result.
getDescriptionRenderUrl( $name, $lang=null)
Get the URL of the content-only fragment of the description page.
Base class for all file backend classes (including multi-write backends).
int $deletedHashLevels
The number of directory levels for hash-based division of deleted files.
enumFilesInStorage( $callback)
Call a callback function for every public file in the repository.
string $favicon
The URL of the repo's favicon, if any.
bool $isPrivate
Whether all zones should be private (e.g.
validateFilename( $filename)
Determine if a relative path is valid, i.e.
getRootDirectory()
Get the public zone root storage directory of the repository.
callable false $fileFactoryKey
Override these in the base class.
if(!isset( $args[0])) $lang
getVirtualUrl( $suffix=false)
Get a URL referring to this repository, with the private mwrepo protocol.
makeUrl( $query='', $entry='index')
Make an url to this repo.
callable false $oldFileFactory
Override these in the base class.
storeBatch(array $triplets, $flags=0)
Store a batch of files.
string $pathDisclosureProtection
May be 'paranoid' to remove all parameters from error messages, 'none' to leave the paths in unchange...
streamFileWithStatus( $virtualUrl, $headers=[], $optHeaders=[])
Attempt to stream a file with the given virtual URL/storage path.
getTempRepo()
Get a temporary private FileRepo associated with this repo.
resolveToStoragePathIfVirtual( $path)
If a path is a virtual URL, resolve it to a storage path.
getInfo()
Return information about the repository.
UploadStash is intended to accomplish a few things:
int $descriptionCacheExpiry
getName()
Get the name of this repository, as specified by $info['name]' to the constructor.
string $thumbUrl
The base thumbnail URL.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
quickImportBatch(array $triples)
Import a batch of files from the local file system into the repo.
static extensionFromPath( $path, $case='lowercase')
Get the final extension from a storage or FS path.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
static getHashPathForLevel( $name, $levels)
getZoneUrl( $zone, $ext=null)
Get the URL corresponding to one of the four basic zones.
callable false $oldFileFactoryKey
Override these in the base class.
getZonePath( $zone)
Get the storage path corresponding to one of the zones.
getLocalReference( $virtualUrl)
Get a local FS file with a given virtual URL/storage path.
getZoneLocation( $zone)
The storage container and base path of a zone.
bool $initialCapital
Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames impl...
static normalizeTitle( $title, $exception=false)
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
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...
getDescriptionStylesheetUrl()
Get the URL of the stylesheet to apply to description pages.
fileExistsBatch(array $files)
Checks existence of an array of files.
Base class for file repositories.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
static newEmpty()
Get an instance that wraps EmptyBagOStuff.
freeTemp( $virtualUrl)
Remove a temporary file or mark it for garbage collection.
findFiles(array $items, $flags=0)
Find many files at once.
quickPurge( $path)
Purge a file from the repo.
hasSha1Storage()
Returns whether or not storage is SHA-1 based.
findFileFromKey( $sha1, $options=[])
Find an instance of the file with this key, created at the specified time Returns false if the file d...
newFile( $title, $time=false)
Create a new File object from the local repository.
enumFiles( $callback)
Call a callback function for every public regular file in the repository.
checkRedirect(Title $title)
Checks if there is a redirect named as $title.
quickImport( $src, $dst, $options=null)
Import a file from the local file system into the repo.
static isStoragePath( $path)
Check if a given path is a "mwstore://" path.
getUploadStash(User $user=null)
Get an UploadStash associated with this repo.
string $thumbScriptUrl
URL of thumb.php.
findFilesByPrefix( $prefix, $limit)
Return an array of files where the name starts with $prefix.
array $zones
Map of zones to config.
paranoidClean( $param)
Path disclosure protection function.
getDescriptionUrl( $name)
Get the URL of an image description page.
getThumbProxySecret()
Get the secret key for the proxied thumb service.
store( $srcPath, $dstZone, $dstRel, $flags=0)
Store a file to a given destination.
getSharedCacheKey( $kClassSuffix,... $components)
Get a global, repository-qualified, WAN cache key.
static getInstance( $ts=false)
Get a timestamp instance in GMT.
MimeMagic helper wrapper.
nameForThumb( $name)
Get the portion of the file that contains the origin file name.
invalidateImageRedirect(Title $title)
Invalidates image redirect cache related to that image Doesn't do anything for repositories that don'...
getThumbProxyUrl()
Get the URL thumb.php requests are being proxied to.
getLocalCopy( $virtualUrl)
Get a local FS copy of a file with a given virtual URL/storage path.
FileRepo for temporary files created via FileRepo::getTempRepo()
cleanupBatch(array $files, $flags=0)
Deletes a batch of files.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
fileExists( $file)
Checks existence of a file.
getFileSha1( $virtualUrl)
Get the sha1 (base 36) of a file with a given virtual URL/storage path.
backendSupportsUnicodePaths()
newFatal( $message,... $parameters)
Create a new fatal error.
getNameFromTitle(Title $title)
Get the name of a file from its title object.
getLocalCacheKey( $kClassSuffix,... $components)
Get a site-local, repository-qualified, WAN cache key.
getDisplayName()
Get the human-readable name of the repo.
findFile( $title, $options=[])
Find an instance of the named file created at the specified time Returns false if the file does not e...
static newGood( $value=null)
Factory function for good results.
storeTemp( $originalName, $srcPath)
Pick a random name in the temp zone and store a file to it.
publishBatch(array $ntuples, $flags=0)
Publish a batch of files.
Multi-datacenter aware caching interface.
$wgSitename
Name of the site.
string $scriptDirUrl
URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g.
string $articleUrl
Equivalent to $wgArticlePath, e.g.
getHashLevels()
Get the number of hash directory levels.
initDirectory( $dir)
Creates a directory with the appropriate zone permissions.
Class representing a non-directory file on the file system.
getBackend()
Get the file backend instance.
static getMain()
Get the RequestContext object associated with the main request.
callable $fileFactory
Override these in the base class.
quickPurgeBatch(array $paths)
Purge a batch of files from the repo.
getFileSize( $virtualUrl)
Get the size of a file with a given virtual URL/storage path.
isLocal()
Returns true if this the local file repository.
string $thumbProxySecret
Secret key to pass as an X-Swift-Secret header to the proxied thumb service.
getHashPath( $name)
Get a relative path including trailing slash, e.g.
getErrorCleanupFunction()
Get a callback function to use for cleaning error message parameters.
Represents a title within MediaWiki.
__construct(array $info=null)
findBySha1s(array $hashes)
Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashe...
getTempHashPath( $suffix)
Get a relative path including trailing slash, e.g.
string $descBaseUrl
URL of image description pages, e.g.
quickCleanDir( $dir)
Deletes a directory if empty.
static isVirtualUrl( $url)
Determine if a string is an mwrepo:// URL.
getFileTimestamp( $virtualUrl)
Get the timestamp of a file with a given virtual URL/storage path.
concatenate(array $srcPaths, $dstPath, $flags=0)
Concatenate a list of temporary files into a target file location.
deleteBatch(array $sourceDestPairs)
Move a group of files to the deletion archive.
resolveVirtualUrl( $url)
Get the backend storage path corresponding to a virtual URL.
static isPathTraversalFree( $path)
Check if a relative path has no directory traversals.
cleanDir( $dir)
Deletes a directory if empty.
if(!is_readable( $file)) $ext
getFileProps( $virtualUrl)
Get properties of a file with a given virtual URL/storage path.
int $abbrvThreshold
File names over this size will use the short form of thumbnail names.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
bool $transformVia404
Whether to skip media file transformation on parse and rely on a 404 handler instead.
supportsSha1URLs()
Returns whether or not repo supports having originals SHA-1s in the thumb URLs.
int $hashLevels
The number of directory levels for hash-based division of files.
getDeletedHashPath( $key)
Get a relative path for a deletion archive key, e.g.
assertWritableRepo()
Throw an exception if this repo is read-only by design.
cleanupDeletedBatch(array $storageKeys)
Delete files in the deleted directory if they are not referenced in the filearchive table.
string false $url
Public zone URL.
canTransformVia404()
Returns true if the repository can transform files via a 404 handler.
bool $fetchDescription
Whether to fetch commons image description pages and display them on the local wiki.
string $thumbProxyUrl
URL of where to proxy thumb.php requests to.