12use InvalidArgumentException;
29use Shellbox\Command\BoxedCommand;
32use Wikimedia\AtEase\AtEase;
156 protected $fileFactory = [ UnregisteredLocalFile::class,
'newFromTitle' ];
193 || !array_key_exists(
'name', $info )
194 || !array_key_exists(
'backend', $info )
196 throw new InvalidArgumentException( __CLASS__ .
197 " requires an array of options having both 'name' and 'backend' keys.\n" );
201 $this->name = $info[
'name'];
203 $this->backend = $info[
'backend'];
210 $optionalSettings = [
211 'descBaseUrl',
'scriptDirUrl',
'articleUrl',
'fetchDescription',
212 'thumbScriptUrl',
'pathDisclosureProtection',
'descriptionCacheExpiry',
213 'favicon',
'thumbProxyUrl',
'thumbProxySecret',
'disableLocalTransform'
215 foreach ( $optionalSettings as $var ) {
216 if ( isset( $info[$var] ) ) {
217 $this->$var = $info[$var];
224 $this->initialCapital = $info[
'initialCapital'] ?? $localCapitalLinks;
225 if ( $localCapitalLinks && !$this->initialCapital ) {
233 throw new InvalidArgumentException(
234 'File repos with initial capital false are not allowed on wikis where the File ' .
235 'namespace has initial capital true' );
238 $this->url = $info[
'url'] ??
false;
239 $defaultThumbUrl = $this->url ? $this->url .
'/thumb' :
false;
240 $this->thumbUrl = $info[
'thumbUrl'] ?? $defaultThumbUrl;
241 $this->hashLevels = $info[
'hashLevels'] ?? 2;
243 $this->transformVia404 = !empty( $info[
'transformVia404'] );
244 $this->abbrvThreshold = $info[
'abbrvThreshold'] ?? 255;
245 $this->isPrivate = !empty( $info[
'isPrivate'] );
247 $this->zones = $info[
'zones'] ?? [];
248 foreach ( [
'public',
'thumb',
'transcoded',
'temp',
'deleted' ] as $zone ) {
249 if ( !isset( $this->zones[$zone][
'container'] ) ) {
250 $this->zones[$zone][
'container'] =
"{$this->name}-{$zone}";
252 if ( !isset( $this->zones[$zone][
'directory'] ) ) {
253 $this->zones[$zone][
'directory'] =
'';
255 if ( !isset( $this->zones[$zone][
'urlsByExt'] ) ) {
256 $this->zones[$zone][
'urlsByExt'] = [];
262 $this->wanCache = $info[
'wanCache'] ?? WANObjectCache::newEmpty();
281 return $this->backend->getReadOnlyReason();
290 foreach ( (array)$doZones as $zone ) {
292 if ( $root ===
null ) {
293 throw new RuntimeException(
"No '$zone' zone defined in the {$this->name} repo." );
305 return str_starts_with(
$url,
'mwrepo://' );
317 $path =
'mwrepo://' . $this->name;
318 if ( $suffix !==
false ) {
319 $path .=
'/' . rawurlencode( $suffix );
333 if ( in_array( $zone, [
'public',
'thumb',
'transcoded' ] ) ) {
335 if ( $ext !==
null && isset( $this->zones[$zone][
'urlsByExt'][$ext] ) ) {
338 return $this->zones[$zone][
'urlsByExt'][$ext];
339 } elseif ( isset( $this->zones[$zone][
'url'] ) ) {
341 return $this->zones[$zone][
'url'];
351 return $this->thumbUrl;
353 return "{$this->url}/transcoded";
375 if ( !str_starts_with(
$url,
'mwrepo://' ) ) {
376 throw new InvalidArgumentException( __METHOD__ .
': unknown protocol' );
378 $bits = explode(
'/', substr(
$url, 9 ), 3 );
379 if ( count( $bits ) != 3 ) {
380 throw new InvalidArgumentException( __METHOD__ .
": invalid mwrepo URL: $url" );
382 [ $repo, $zone, $rel ] = $bits;
383 if ( $repo !== $this->name ) {
384 throw new InvalidArgumentException( __METHOD__ .
": fetching from a foreign repo is not supported" );
386 $base = $this->getZonePath( $zone );
388 throw new InvalidArgumentException( __METHOD__ .
": invalid zone: $zone" );
391 return $base .
'/' . rawurldecode( $rel );
401 if ( !isset( $this->zones[$zone] ) ) {
402 return [
null, null ];
405 return [ $this->zones[$zone][
'container'], $this->zones[$zone][
'directory'] ];
415 [ $container, $base ] = $this->getZoneLocation( $zone );
416 if ( $container ===
null || $base ===
null ) {
419 $backendName = $this->backend->getName();
424 return "mwstore://$backendName/{$container}{$base}";
438 public function newFile( $title, $time =
false ) {
439 $title = File::normalizeTitle( $title );
444 if ( $this->oldFileFactory ) {
445 return ( $this->oldFileFactory )( $title, $this, $time );
450 return ( $this->fileFactory )( $title, $this );
473 public function findFile( $title, $options = [] ) {
474 if ( !empty( $options[
'private'] ) && !( $options[
'private'] instanceof
Authority ) ) {
475 throw new InvalidArgumentException(
476 __METHOD__ .
' called with the `private` option set to something ' .
477 'other than an Authority object'
481 $title = File::normalizeTitle( $title );
485 if ( isset( $options[
'bypassCache'] ) ) {
486 $options[
'latest'] = $options[
'bypassCache'];
488 $time = $options[
'time'] ??
false;
489 $flags = !empty( $options[
'latest'] ) ? IDBAccessObject::READ_LATEST : 0;
490 # First try the current version of the file to see if it precedes the timestamp
491 $img = $this->newFile( $title );
495 $img->load( $flags );
496 if ( $img->exists() && ( !$time || $img->getTimestamp() == $time ) ) {
499 # Now try an old version of the file
500 if ( $time !==
false ) {
501 $img = $this->newFile( $title, $time );
503 $img->load( $flags );
504 if ( $img->exists() ) {
505 if ( !$img->isDeleted( File::DELETED_FILE ) ) {
509 !empty( $options[
'private'] ) &&
510 $img->userCan( File::DELETED_FILE, $options[
'private'] )
519 if ( !empty( $options[
'ignoreRedirect'] ) ) {
522 $redir = $this->checkRedirect( $title );
523 if ( $redir && $title->getNamespace() ===
NS_FILE ) {
524 $img = $this->newFile( $redir );
528 $img->load( $flags );
529 if ( $img->exists() ) {
530 $img->redirectedFrom( $title->getDBkey() );
558 foreach ( $items as $item ) {
559 if ( is_array( $item ) ) {
560 $title = $item[
'title'];
562 unset( $options[
'title'] );
565 !empty( $options[
'private'] ) &&
566 !( $options[
'private'] instanceof
Authority )
568 $options[
'private'] = RequestContext::getMain()->getAuthority();
574 $file = $this->findFile( $title, $options );
576 $searchName = File::normalizeTitle( $title )->getDBkey();
577 if ( $flags & self::NAME_AND_TIME_ONLY ) {
578 $result[$searchName] = [
579 'title' => $file->getTitle()->getDBkey(),
580 'timestamp' => $file->getTimestamp()
583 $result[$searchName] = $file;
602 if ( !empty( $options[
'private'] ) && !( $options[
'private'] instanceof
Authority ) ) {
603 throw new InvalidArgumentException(
604 __METHOD__ .
' called with the `private` option set to something ' .
605 'other than an Authority object'
609 $time = $options[
'time'] ??
false;
610 # First try to find a matching current version of a file...
611 if ( !$this->fileFactoryKey ) {
614 $img = ( $this->fileFactoryKey )( $sha1, $this, $time );
615 if ( $img && $img->exists() ) {
618 # Now try to find a matching old version of a file...
619 if ( $time !==
false && $this->oldFileFactoryKey ) {
620 $img = ( $this->oldFileFactoryKey )( $sha1, $this, $time );
621 if ( $img && $img->exists() ) {
622 if ( !$img->isDeleted( File::DELETED_FILE ) ) {
626 !empty( $options[
'private'] ) &&
627 $img->userCan( File::DELETED_FILE, $options[
'private'] )
658 foreach ( $hashes as $hash ) {
659 $files = $this->findBySha1( $hash );
660 if ( count( $files ) ) {
661 $result[$hash] = $files;
686 return $this->thumbScriptUrl;
695 return $this->thumbProxyUrl;
704 return $this->thumbProxySecret;
713 return $this->transformVia404;
723 return !$this->disableLocalTransform;
734 $this->initialCapital !=
737 $name = $title->getDBkey();
738 if ( $this->initialCapital ) {
742 $name = $title->getDBkey();
754 return $this->getZonePath(
'public' );
765 return self::getHashPathForLevel( $name, $this->hashLevels );
776 $parts = explode(
'!', $suffix, 2 );
777 $name = $parts[1] ?? $suffix;
778 return self::getHashPathForLevel( $name, $this->hashLevels );
787 if ( $levels == 0 ) {
790 $hash = md5( $name );
792 for ( $i = 1; $i <= $levels; $i++ ) {
793 $path .= substr( $hash, 0, $i ) .
'/';
806 return $this->hashLevels;
825 public function makeUrl( $query =
'', $entry =
'index' ) {
826 if ( $this->scriptDirUrl !==
null ) {
827 return wfAppendQuery(
"{$this->scriptDirUrl}/{$entry}.php", $query );
847 if ( $this->descBaseUrl !==
null ) {
848 # "http://example.com/wiki/File:"
849 return $this->descBaseUrl . $encName;
851 if ( $this->articleUrl !==
null ) {
852 # "http://example.com/wiki/$1"
853 # We use "Image:" as the canonical namespace for
854 # compatibility across all MediaWiki versions.
855 return str_replace(
'$1',
856 "Image:$encName", $this->articleUrl );
858 if ( $this->scriptDirUrl !==
null ) {
859 # "http://example.com/w"
860 # We use "Image:" as the canonical namespace for
861 # compatibility across all MediaWiki versions,
862 # and just sort of hope index.php is right. ;)
863 return $this->makeUrl(
"title=Image:$encName" );
880 $query =
'action=render';
881 if ( $lang !==
null ) {
882 $query .=
'&uselang=' . urlencode( $lang );
884 if ( $this->scriptDirUrl !==
null ) {
885 return $this->makeUrl(
890 $descUrl = $this->getDescriptionUrl( $name );
905 if ( $this->scriptDirUrl !==
null ) {
908 return $this->makeUrl(
'title=MediaWiki:Filepage.css&action=raw&ctype=text/css' );
931 public function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
932 $this->assertWritableRepo();
934 $status = $this->storeBatch( [ [ $srcPath, $dstZone, $dstRel ] ], $flags );
935 if ( $status->successCount == 0 ) {
936 $status->setOK(
false );
956 $this->assertWritableRepo();
958 if ( $flags & self::DELETE_SOURCE ) {
959 throw new InvalidArgumentException(
"DELETE_SOURCE not supported in " . __METHOD__ );
962 $status = $this->newGood();
963 $backend = $this->backend;
967 foreach ( $triplets as [ $src, $dstZone, $dstRel ] ) {
968 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
970 .
"( \$src='$srcPath', \$dstZone='$dstZone', \$dstRel='$dstRel' )"
973 if ( $src instanceof
FSFile ) {
976 $src = $this->resolveToStoragePathIfVirtual( $src );
980 $root = $this->getZonePath( $dstZone );
982 throw new RuntimeException(
"Invalid zone: $dstZone" );
984 if ( !$this->validateFilename( $dstRel ) ) {
985 throw new RuntimeException(
'Validation error in $dstRel' );
987 $dstPath =
"$root/$dstRel";
988 $dstDir = dirname( $dstPath );
990 if ( !$this->initDirectory( $dstDir )->isOK() ) {
991 return $this->newFatal(
'directorycreateerror', $dstDir );
999 'overwrite' => (bool)( $flags & self::OVERWRITE ),
1000 'overwriteSame' => (bool)( $flags & self::OVERWRITE_SAME ),
1005 $opts = [
'force' => true ];
1006 if ( $flags & self::SKIP_LOCKING ) {
1007 $opts[
'nonLocking'] =
true;
1010 return $status->merge( $backend->doOperations( $operations, $opts ) );
1024 $this->assertWritableRepo();
1026 $status = $this->newGood();
1029 foreach ( $files as
$path ) {
1030 if ( is_array(
$path ) ) {
1032 [ $zone, $rel ] =
$path;
1033 $path = $this->getZonePath( $zone ) .
"/$rel";
1036 $path = $this->resolveToStoragePathIfVirtual(
$path );
1038 $operations[] = [
'op' =>
'delete',
'src' =>
$path ];
1041 $opts = [
'force' => true ];
1042 if ( $flags & self::SKIP_LOCKING ) {
1043 $opts[
'nonLocking'] =
true;
1046 return $status->merge( $this->backend->doOperations( $operations, $opts ) );
1067 return $this->quickImportBatch( [ [ $src, $dst, $options ] ] );
1085 $status = $this->newGood();
1087 foreach ( $triples as $triple ) {
1088 [ $src, $dst ] = $triple;
1089 if ( $src instanceof
FSFile ) {
1092 $src = $this->resolveToStoragePathIfVirtual( $src );
1095 $dst = $this->resolveToStoragePathIfVirtual( $dst );
1097 if ( !isset( $triple[2] ) ) {
1099 } elseif ( is_string( $triple[2] ) ) {
1101 $headers = [
'Content-Disposition' => $triple[2] ];
1102 } elseif ( is_array( $triple[2] ) && isset( $triple[2][
'headers'] ) ) {
1103 $headers = $triple[2][
'headers'];
1112 'headers' => $headers
1114 $status->merge( $this->initDirectory( dirname( $dst ) ) );
1117 return $status->merge( $this->backend->doQuickOperations( $operations ) );
1129 return $this->quickPurgeBatch( [
$path ] );
1140 return $this->newGood()->merge(
1141 $this->backend->clean(
1142 [
'dir' => $this->resolveToStoragePathIfVirtual( $dir ) ]
1156 $status = $this->newGood();
1158 foreach ( $paths as
$path ) {
1161 'src' => $this->resolveToStoragePathIfVirtual(
$path ),
1162 'ignoreMissingSource' => true
1165 $status->merge( $this->backend->doQuickOperations( $operations ) );
1181 $this->assertWritableRepo();
1183 $date = MWTimestamp::getInstance()->format(
'YmdHis' );
1184 $hashPath = $this->getHashPath( $originalName );
1185 $dstUrlRel = $hashPath . $date .
'!' . rawurlencode( $originalName );
1186 $virtualUrl = $this->getVirtualUrl(
'temp' ) .
'/' . $dstUrlRel;
1188 $result = $this->quickImport( $srcPath, $virtualUrl );
1189 $result->value = $virtualUrl;
1201 $this->assertWritableRepo();
1203 $temp = $this->getVirtualUrl(
'temp' );
1204 if ( !str_starts_with( $virtualUrl, $temp ) ) {
1205 wfDebug( __METHOD__ .
": Invalid temp virtual URL" );
1210 return $this->quickPurge( $virtualUrl )->isOK();
1222 public function concatenate( array $srcPaths, $dstPath, $flags = 0 ) {
1223 $this->assertWritableRepo();
1225 $status = $this->newGood();
1228 foreach ( $srcPaths as $srcPath ) {
1230 $source = $this->resolveToStoragePathIfVirtual( $srcPath );
1235 $params = [
'srcs' => $sources,
'dst' => $dstPath ];
1236 $status->merge( $this->backend->concatenate( $params ) );
1237 if ( !$status->isOK() ) {
1242 if ( $flags & self::DELETE_SOURCE ) {
1243 $status->merge( $this->quickPurgeBatch( $srcPaths ) );
1247 $status->setResult(
true );
1276 $src, $dstRel, $archiveRel, $flags = 0, array $options = []
1278 $this->assertWritableRepo();
1280 $status = $this->publishBatch(
1281 [ [ $src, $dstRel, $archiveRel, $options ] ], $flags );
1282 if ( $status->successCount == 0 ) {
1283 $status->setOK(
false );
1285 $status->value = $status->value[0] ??
false;
1302 $this->assertWritableRepo();
1304 $backend = $this->backend;
1306 $this->initZones(
'public' );
1308 $status = $this->newGood( [] );
1311 $sourceFSFilesToDelete = [];
1313 foreach ( $ntuples as $ntuple ) {
1314 [ $src, $dstRel, $archiveRel ] = $ntuple;
1315 $srcPath = ( $src instanceof
FSFile ) ? $src->getPath() : $src;
1317 $options = $ntuple[3] ?? [];
1319 $srcPath = $this->resolveToStoragePathIfVirtual( $srcPath );
1320 if ( !$this->validateFilename( $dstRel ) ) {
1321 throw new RuntimeException(
'Validation error in $dstRel' );
1323 if ( !$this->validateFilename( $archiveRel ) ) {
1324 throw new RuntimeException(
'Validation error in $archiveRel' );
1327 $publicRoot = $this->getZonePath(
'public' );
1328 $dstPath =
"$publicRoot/$dstRel";
1329 $archivePath =
"$publicRoot/$archiveRel";
1331 $dstDir = dirname( $dstPath );
1332 $archiveDir = dirname( $archivePath );
1334 if ( !$this->initDirectory( $dstDir )->isOK() ) {
1335 return $this->newFatal(
'directorycreateerror', $dstDir );
1337 if ( !$this->initDirectory( $archiveDir )->isOK() ) {
1338 return $this->newFatal(
'directorycreateerror', $archiveDir );
1342 $headers = $options[
'headers'] ?? [];
1353 'dst' => $archivePath,
1354 'ignoreMissingSource' => true
1360 'op' => ( $flags & self::DELETE_SOURCE ) ?
'move' :
'copy',
1363 'overwrite' =>
true,
1364 'headers' => $headers
1371 'overwrite' =>
true,
1372 'headers' => $headers
1374 if ( $flags & self::DELETE_SOURCE ) {
1375 $sourceFSFilesToDelete[] = $srcPath;
1381 $status->merge( $backend->doOperations( $operations ) );
1383 foreach ( $ntuples as $i => $ntuple ) {
1384 [ , , $archiveRel ] = $ntuple;
1385 $archivePath = $this->getZonePath(
'public' ) .
"/$archiveRel";
1386 if ( $this->fileExists( $archivePath ) ) {
1387 $status->value[$i] =
'archived';
1389 $status->value[$i] =
'new';
1393 foreach ( $sourceFSFilesToDelete as $file ) {
1394 AtEase::suppressWarnings();
1396 AtEase::restoreWarnings();
1410 $path = $this->resolveToStoragePathIfVirtual( $dir );
1413 $params = [
'dir' =>
$path ];
1414 if ( $this->isPrivate
1415 || $container === $this->zones[
'deleted'][
'container']
1416 || $container === $this->zones[
'temp'][
'container']
1418 # Take all available measures to prevent web accessibility of new deleted
1419 # directories, in case the user has not configured offline storage
1420 $params = [
'noAccess' =>
true,
'noListing' => true ] + $params;
1423 return $this->newGood()->merge( $this->backend->prepare( $params ) );
1433 $this->assertWritableRepo();
1435 return $this->newGood()->merge(
1436 $this->backend->clean(
1437 [
'dir' => $this->resolveToStoragePathIfVirtual( $dir ) ]
1449 $result = $this->fileExistsBatch( [ $file ] );
1462 $paths = array_map( $this->resolveToStoragePathIfVirtual( ... ), $files );
1463 $this->backend->preloadFileStat( [
'srcs' => $paths ] );
1466 foreach ( $paths as $key =>
$path ) {
1467 $result[$key] = $this->backend->fileExists( [
'src' =>
$path ] );
1483 public function delete( $srcRel, $archiveRel ) {
1484 $this->assertWritableRepo();
1486 return $this->deleteBatch( [ [ $srcRel, $archiveRel ] ] );
1506 $this->assertWritableRepo();
1509 $this->initZones( [
'public',
'deleted' ] );
1511 $status = $this->newGood();
1513 $backend = $this->backend;
1516 foreach ( $sourceDestPairs as [ $srcRel, $archiveRel ] ) {
1517 if ( !$this->validateFilename( $srcRel ) ) {
1518 throw new RuntimeException( __METHOD__ .
':Validation error in $srcRel' );
1519 } elseif ( !$this->validateFilename( $archiveRel ) ) {
1520 throw new RuntimeException( __METHOD__ .
':Validation error in $archiveRel' );
1523 $publicRoot = $this->getZonePath(
'public' );
1524 $srcPath =
"{$publicRoot}/$srcRel";
1526 $deletedRoot = $this->getZonePath(
'deleted' );
1527 $archivePath =
"{$deletedRoot}/{$archiveRel}";
1528 $archiveDir = dirname( $archivePath );
1531 if ( !$this->initDirectory( $archiveDir )->isGood() ) {
1532 return $this->newFatal(
'directorycreateerror', $archiveDir );
1538 'dst' => $archivePath,
1541 'overwriteSame' =>
true
1548 $opts = [
'force' => true ];
1549 return $status->merge( $backend->doOperations( $operations, $opts ) );
1559 $this->assertWritableRepo();
1570 if ( strlen( $key ) < 31 ) {
1571 throw new InvalidArgumentException(
"Invalid storage key '$key'." );
1574 for ( $i = 0; $i < $this->deletedHashLevels; $i++ ) {
1575 $path .= $key[$i] .
'/';
1589 if ( self::isVirtualUrl(
$path ) ) {
1590 return $this->resolveVirtualUrl(
$path );
1604 $path = $this->resolveToStoragePathIfVirtual( $virtualUrl );
1606 return $this->backend->getLocalCopy( [
'src' =>
$path ] );
1618 $path = $this->resolveToStoragePathIfVirtual( $virtualUrl );
1620 return $this->backend->getLocalReference( [
'src' =>
$path ] );
1635 $path = $this->resolveToStoragePathIfVirtual( $virtualUrl );
1637 return $this->backend->addShellboxInputFile( $command, $boxedName, [
'src' =>
$path ] );
1648 $fsFile = $this->getLocalReference( $virtualUrl );
1651 $props = $mwProps->getPropsFromPath( $fsFile->getPath(),
true );
1653 $props = $mwProps->newPlaceholderProps();
1666 $path = $this->resolveToStoragePathIfVirtual( $virtualUrl );
1668 return $this->backend->getFileTimestamp( [
'src' =>
$path ] );
1678 $path = $this->resolveToStoragePathIfVirtual( $virtualUrl );
1680 return $this->backend->getFileSize( [
'src' =>
$path ] );
1690 $path = $this->resolveToStoragePathIfVirtual( $virtualUrl );
1692 return $this->backend->getFileSha1Base36( [
'src' =>
$path ] );
1705 $path = $this->resolveToStoragePathIfVirtual( $virtualUrl );
1706 $params = [
'src' =>
$path,
'headers' => $headers,
'options' => $optHeaders ];
1709 ob_start(
null, 1_048_576 );
1710 ob_implicit_flush(
true );
1712 $status = $this->newGood()->merge( $this->backend->streamFile( $params ) );
1716 if ( ob_get_status() ) {
1732 $this->enumFilesInStorage( $callback );
1743 $publicRoot = $this->getZonePath(
'public' );
1744 $numDirs = 1 << ( $this->hashLevels * 4 );
1747 for ( $flatIndex = 0; $flatIndex < $numDirs; $flatIndex++ ) {
1748 $hexString = sprintf(
"%0{$this->hashLevels}x", $flatIndex );
1749 $path = $publicRoot;
1750 for ( $hexPos = 0; $hexPos < $this->hashLevels; $hexPos++ ) {
1751 $path .=
'/' . substr( $hexString, 0, $hexPos + 1 );
1753 $iterator = $this->backend->getFileList( [
'dir' =>
$path ] );
1754 if ( $iterator ===
null ) {
1755 throw new RuntimeException( __METHOD__ .
': could not get file listing for ' .
$path );
1757 foreach ( $iterator as $name ) {
1759 $callback(
"{$path}/{$name}" );
1771 if ( strval( $filename ) ==
'' ) {
1783 private function getErrorCleanupFunction() {
1784 switch ( $this->pathDisclosureProtection ) {
1787 $callback = $this->passThrough( ... );
1790 $callback = $this->paranoidClean( ... );
1823 $status = Status::newFatal( $message, ...$parameters );
1824 $status->cleanCallback = $this->getErrorCleanupFunction();
1836 $status = Status::newGood( $value );
1837 $status->cleanCallback = $this->getErrorCleanupFunction();
1872 if ( $this->isLocal() ) {
1877 return wfMessageFallback(
'shared-repo-name-' . $this->name,
'shared-repo' )->text();
1888 if ( strlen( $name ) > $this->abbrvThreshold ) {
1890 $name = ( $ext ==
'' ) ?
'thumbnail' :
"thumbnail.$ext";
1902 return $this->getName() ==
'local';
1932 return $this->wanCache->makeKey(
1933 'filerepo-' . $kClassSuffix,
1949 'name' =>
"{$this->name}-temp",
1950 'backend' => $this->backend,
1955 'container' => $this->zones[
'temp'][
'container'],
1956 'directory' => $this->zones[
'temp'][
'directory']
1959 'container' => $this->zones[
'temp'][
'container'],
1960 'directory' => $this->zones[
'temp'][
'directory'] ==
''
1962 : $this->zones[
'temp'][
'directory'] .
'/thumb'
1965 'container' => $this->zones[
'temp'][
'container'],
1966 'directory' => $this->zones[
'temp'][
'directory'] ==
''
1968 : $this->zones[
'temp'][
'directory'] .
'/transcoded'
1971 'hashLevels' => $this->hashLevels,
2003 'name' => $this->getName(),
2004 'displayname' => $this->getDisplayName(),
2005 'rootUrl' => $this->getZoneUrl(
'public' ),
2006 'local' => $this->isLocal(),
2009 $optionalSettings = [
2017 'descriptionCacheExpiry',
2019 foreach ( $optionalSettings as $k ) {
2020 if ( $this->$k !==
null ) {
2021 $ret[$k] = $this->$k;
2024 if ( $this->favicon !==
null ) {
2027 ->expand( $this->favicon );
2038 return $this->hasSha1Storage;
2046 return $this->supportsSha1URLs;
2051class_alias( FileRepo::class,
'FileRepo' );
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...
MimeMagic helper wrapper.
Group all the pieces relevant to the context of a request into one instance.
A class containing constants representing the names of configuration variables.
const Sitename
Name constant for the Sitename setting, for use with Config::get()
Generic operation result class Has warning/error list, boolean status and arbitrary value.
UploadStash is intended to accomplish a few things:
Interface for objects (potentially) representing an editable wiki page.