72 parent::__construct( $config );
73 $this->mimeCallback = isset( $config[
'mimeCallback'] )
74 ? $config[
'mimeCallback']
77 $this->memCache = WANObjectCache::newEmpty();
79 $this->expensiveCache =
new ProcessCacheLRU( self::CACHE_EXPENSIVE_SIZE );
294 if ( $nsrc !== $ndst &&
$status->isOK() ) {
319 if ( count(
$params[
'headers'] ) ) {
358 $start_time = microtime(
true );
360 $sec = microtime(
true ) - $start_time;
362 $this->logger->error( get_class( $this ) .
"-{$this->name}" .
363 " failed to concatenate " . count(
$params[
'srcs'] ) .
" file(s) [$sec sec]" );
381 MediaWiki\suppressWarnings();
382 $ok = ( is_file( $tmpPath ) && filesize( $tmpPath ) == 0 );
383 MediaWiki\restoreWarnings();
385 $status->fatal(
'backend-fail-opentemp', $tmpPath );
392 foreach ( $fsFiles
as $path => &$fsFile ) {
405 $tmpHandle = fopen( $tmpPath,
'ab' );
406 if ( $tmpHandle ===
false ) {
407 $status->fatal(
'backend-fail-opentemp', $tmpPath );
413 foreach ( $fsFiles
as $virtualSource => $fsFile ) {
415 $sourceHandle = fopen( $fsFile->getPath(),
'rb' );
416 if ( $sourceHandle ===
false ) {
417 fclose( $tmpHandle );
418 $status->fatal(
'backend-fail-read', $virtualSource );
423 if ( !stream_copy_to_stream( $sourceHandle, $tmpHandle ) ) {
424 fclose( $sourceHandle );
425 fclose( $tmpHandle );
426 $status->fatal(
'backend-fail-writetemp', $tmpPath );
430 fclose( $sourceHandle );
432 if ( !fclose( $tmpHandle ) ) {
433 $status->fatal(
'backend-fail-closetemp', $tmpPath );
448 if (
$dir ===
null ) {
454 if ( $shard !==
null ) {
457 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
483 if (
$dir ===
null ) {
489 if ( $shard !==
null ) {
492 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
518 if (
$dir ===
null ) {
524 if ( $shard !==
null ) {
527 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
555 if ( $subDirsRel !==
null ) {
556 foreach ( $subDirsRel
as $subDirRel ) {
557 $subDir =
$params[
'dir'] .
"/{$subDirRel}";
560 unset( $subDirsRel );
565 if (
$dir ===
null ) {
572 $filesLockEx = [
$params[
'dir'] ];
578 if ( $shard !==
null ) {
582 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
608 return ( $stat ===
null ) ? null : (bool)$stat;
615 return $stat ? $stat[
'mtime'] :
false;
622 return $stat ? $stat[
'size'] :
false;
627 if (
$path ===
null ) {
631 $latest = !empty(
$params[
'latest'] );
632 if ( !$latest && !$this->cheapCache->has(
$path,
'stat', self::CACHE_TTL ) ) {
635 if ( $this->cheapCache->has(
$path,
'stat', self::CACHE_TTL ) ) {
636 $stat = $this->cheapCache->get(
$path,
'stat' );
639 if ( is_array( $stat ) ) {
640 if ( !$latest || $stat[
'latest'] ) {
643 } elseif ( in_array( $stat, [
'NOT_EXIST',
'NOT_EXIST_LATEST' ] ) ) {
644 if ( !$latest || $stat ===
'NOT_EXIST_LATEST' ) {
650 if ( is_array( $stat ) ) {
652 $stat[
'latest'] = isset( $stat[
'latest'] ) ? $stat[
'latest'] : $latest;
653 $this->cheapCache->set(
$path,
'stat', $stat );
655 if ( isset( $stat[
'sha1'] ) ) {
656 $this->cheapCache->set(
$path,
'sha1',
657 [
'hash' => $stat[
'sha1'],
'latest' => $latest ] );
659 if ( isset( $stat[
'xattr'] ) ) {
661 $this->cheapCache->set(
$path,
'xattr',
662 [
'map' => $stat[
'xattr'],
'latest' => $latest ] );
664 } elseif ( $stat ===
false ) {
665 $this->cheapCache->set(
$path,
'stat', $latest ?
'NOT_EXIST_LATEST' :
'NOT_EXIST' );
666 $this->cheapCache->set(
$path,
'xattr', [
'map' =>
false,
'latest' => $latest ] );
667 $this->cheapCache->set(
$path,
'sha1', [
'hash' =>
false,
'latest' => $latest ] );
668 $this->logger->debug( __METHOD__ .
": File $path does not exist.\n" );
670 $this->logger->warning( __METHOD__ .
": Could not stat file $path.\n" );
699 MediaWiki\suppressWarnings();
700 $contents[
$path] = $fsFile ? file_get_contents( $fsFile->getPath() ) :
false;
701 MediaWiki\restoreWarnings();
709 if (
$path ===
null ) {
713 $latest = !empty(
$params[
'latest'] );
714 if ( $this->cheapCache->has(
$path,
'xattr', self::CACHE_TTL ) ) {
715 $stat = $this->cheapCache->get(
$path,
'xattr' );
718 if ( !$latest || $stat[
'latest'] ) {
724 $this->cheapCache->set(
$path,
'xattr', [
'map' => $fields,
'latest' => $latest ] );
735 return [
'headers' => [],
'metadata' => [] ];
740 if (
$path ===
null ) {
744 $latest = !empty(
$params[
'latest'] );
745 if ( $this->cheapCache->has(
$path,
'sha1', self::CACHE_TTL ) ) {
746 $stat = $this->cheapCache->get(
$path,
'sha1' );
749 if ( !$latest || $stat[
'latest'] ) {
750 return $stat[
'hash'];
754 $this->cheapCache->set(
$path,
'sha1', [
'hash' => $hash,
'latest' => $latest ] );
769 return $fsFile->getSha1Base36();
787 $latest = !empty(
$params[
'latest'] );
791 if (
$path ===
null ) {
792 $fsFiles[$src] =
null;
793 } elseif ( $this->expensiveCache->has(
$path,
'localRef' ) ) {
794 $val = $this->expensiveCache->get(
$path,
'localRef' );
797 if ( !$latest || $val[
'latest'] ) {
798 $fsFiles[$src] = $val[
'object'];
803 $params[
'srcs'] = array_diff(
$params[
'srcs'], array_keys( $fsFiles ) );
805 $fsFiles[
$path] = $fsFile;
807 $this->expensiveCache->set(
$path,
'localRef',
808 [
'object' => $fsFile,
'latest' => $latest ] );
854 $params[
'options'] = isset(
$params[
'options'] ) ?
$params[
'options'] : [];
858 if ( ( empty(
$params[
'headless'] ) ||
$params[
'headers'] ) && headers_sent() ) {
859 print "Headers already sent, terminating.\n";
886 'obResetFunc' => $this->obResetFunc,
887 'streamMimeFunc' => $this->streamMimeFunc
905 if (
$dir ===
null ) {
908 if ( $shard !==
null ) {
911 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
919 } elseif ( $exists ===
null ) {
940 if (
$dir ===
null ) {
943 if ( $shard !==
null ) {
947 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
970 if (
$dir ===
null ) {
973 if ( $shard !==
null ) {
977 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
1011 'store' =>
'StoreFileOp',
1012 'copy' =>
'CopyFileOp',
1013 'move' =>
'MoveFileOp',
1014 'delete' =>
'DeleteFileOp',
1015 'create' =>
'CreateFileOp',
1016 'describe' =>
'DescribeFileOp',
1017 'null' =>
'NullFileOp'
1022 foreach ( $ops
as $operation ) {
1023 $opName = $operation[
'op'];
1024 if ( isset( $supportedOps[$opName] ) ) {
1025 $class = $supportedOps[$opName];
1029 $performOps[] =
new $class( $this,
$params, $this->logger );
1050 $paths = [
'sh' => [],
'ex' => [] ];
1051 foreach ( $performOps
as $fileOp ) {
1052 $paths[
'sh'] = array_merge( $paths[
'sh'], $fileOp->storagePathsRead() );
1053 $paths[
'ex'] = array_merge( $paths[
'ex'], $fileOp->storagePathsChanged() );
1056 $paths[
'sh'] = array_diff( $paths[
'sh'], $paths[
'ex'] );
1058 $paths[
'sh'] = array_merge( $paths[
'sh'], array_map(
'dirname', $paths[
'ex'] ) );
1077 $ops = array_map( [ $this,
'sanitizeOpHeaders' ], $ops );
1083 if ( empty( $opts[
'nonLocking'] ) ) {
1095 if ( empty( $opts[
'preserveCache'] ) ) {
1101 foreach ( $performOps
as $performOp ) {
1102 $paths = array_merge( $paths, $performOp->storagePathsRead() );
1103 $paths = array_merge( $paths, $performOp->storagePathsChanged() );
1107 $this->cheapCache->resize( max( 2 * count( $paths ), self::CACHE_CHEAP_SIZE ) );
1112 $ok = $this->
preloadFileStat( [
'srcs' => $paths,
'latest' =>
true ] );
1120 $subStatus = $this->
newStatus(
'backend-fail-internal', $this->
name );
1121 foreach ( $ops
as $i => $op ) {
1122 $subStatus->success[$i] =
false;
1123 ++$subStatus->failCount;
1125 $this->logger->error( get_class( $this ) .
"-{$this->name} " .
1126 " stat failure; aborted operations: " . FormatJson::encode( $ops ) );
1131 $status->success = $subStatus->success;
1134 $this->cheapCache->resize( self::CACHE_CHEAP_SIZE );
1144 $ops = array_map( [ $this,
'sanitizeOpHeaders' ], $ops );
1149 $supportedOps = [
'create',
'store',
'copy',
'move',
'delete',
'describe',
'null' ];
1151 $async = ( $this->parallelize ===
'implicit' && count( $ops ) > 1 );
1155 $fileOpHandles = [];
1156 $curFileOpHandles = [];
1159 if ( !in_array(
$params[
'op'], $supportedOps ) ) {
1160 throw new FileBackendError(
"Operation '{$params['op']}' is not supported." );
1162 $method =
$params[
'op'] .
'Internal';
1163 $subStatus = $this->$method( [
'async' => $async ] +
$params );
1165 if ( count( $curFileOpHandles ) >= $maxConcurrency ) {
1166 $fileOpHandles[] = $curFileOpHandles;
1167 $curFileOpHandles = [];
1169 $curFileOpHandles[$index] = $subStatus->value;
1171 $statuses[$index] = $subStatus;
1174 if ( count( $curFileOpHandles ) ) {
1175 $fileOpHandles[] = $curFileOpHandles;
1178 foreach ( $fileOpHandles
as $fileHandleBatch ) {
1182 foreach ( $statuses
as $index => $subStatus ) {
1184 if ( $subStatus->isOK() ) {
1185 $status->success[$index] =
true;
1188 $status->success[$index] =
false;
1209 foreach ( $fileOpHandles
as $fileOpHandle ) {
1211 throw new InvalidArgumentException(
"Got a non-FileBackendStoreOpHandle object." );
1212 } elseif ( $fileOpHandle->backend->getName() !== $this->getName() ) {
1213 throw new InvalidArgumentException(
1214 "Got a FileBackendStoreOpHandle for the wrong backend." );
1218 foreach ( $fileOpHandles
as $fileOpHandle ) {
1219 $fileOpHandle->closeResources();
1234 if ( count( $fileOpHandles ) ) {
1235 throw new LogicException(
"Backend does not support asynchronous operations." );
1253 static $longs = [
'content-disposition' ];
1255 if ( isset( $op[
'headers'] ) ) {
1259 $maxHVLen = in_array(
$name, $longs ) ? INF : 255;
1260 if ( strlen(
$name ) > 255 || strlen(
$value ) > $maxHVLen ) {
1261 trigger_error(
"Header '$name: $value' is too long." );
1266 $op[
'headers'] = $newHeaders;
1276 $fullConts[] = $fullCont;
1284 if ( is_array( $paths ) ) {
1285 $paths = array_map(
'FileBackend::normalizeStoragePath', $paths );
1286 $paths = array_filter( $paths,
'strlen' );
1288 if ( $paths ===
null ) {
1289 $this->cheapCache->clear();
1290 $this->expensiveCache->clear();
1293 $this->cheapCache->clear(
$path );
1294 $this->expensiveCache->clear(
$path );
1314 $params[
'concurrency'] = ( $this->parallelize !==
'off' ) ? $this->concurrency : 1;
1316 if ( $stats ===
null ) {
1320 $latest = !empty(
$params[
'latest'] );
1321 foreach ( $stats
as $path => $stat ) {
1323 if (
$path ===
null ) {
1326 if ( is_array( $stat ) ) {
1328 $stat[
'latest'] = isset( $stat[
'latest'] ) ? $stat[
'latest'] : $latest;
1329 $this->cheapCache->set(
$path,
'stat', $stat );
1331 if ( isset( $stat[
'sha1'] ) ) {
1332 $this->cheapCache->set(
$path,
'sha1',
1333 [
'hash' => $stat[
'sha1'],
'latest' => $latest ] );
1335 if ( isset( $stat[
'xattr'] ) ) {
1337 $this->cheapCache->set(
$path,
'xattr',
1338 [
'map' => $stat[
'xattr'],
'latest' => $latest ] );
1340 } elseif ( $stat ===
false ) {
1341 $this->cheapCache->set(
$path,
'stat',
1342 $latest ?
'NOT_EXIST_LATEST' :
'NOT_EXIST' );
1343 $this->cheapCache->set(
$path,
'xattr',
1344 [
'map' =>
false,
'latest' => $latest ] );
1345 $this->cheapCache->set(
$path,
'sha1',
1346 [
'hash' =>
false,
'latest' => $latest ] );
1347 $this->logger->debug( __METHOD__ .
": File $path does not exist.\n" );
1350 $this->logger->warning( __METHOD__ .
": Could not stat file $path.\n" );
1413 return (
bool)preg_match(
'/^[a-z0-9][a-z0-9-_.]{0,199}$/i', $container );
1431 if ( $backend === $this->
name ) {
1433 if ( $relPath !==
null && self::isValidShortContainerName( $shortCont ) ) {
1438 if ( $relPath !==
null ) {
1441 if ( self::isValidContainerName( $container ) ) {
1444 if ( $container !==
null ) {
1445 return [ $container, $relPath, $cShard ];
1452 return [
null,
null, null ];
1472 if ( $cShard !==
null && substr( $relPath, -1 ) !==
'/' ) {
1473 return [ $container, $relPath ];
1476 return [
null, null ];
1489 if ( $levels == 1 || $levels == 2 ) {
1491 $char = (
$base == 36 ) ?
'[0-9a-z]' :
'[0-9a-f]';
1494 if ( $levels === 1 ) {
1495 $hashDirRegex =
'(' . $char .
')';
1498 $hashDirRegex = $char .
'/(' . $char .
'{2})';
1500 $hashDirRegex =
'(' . $char .
')/(' . $char .
')';
1507 if ( preg_match(
"!^(?:[^/]{2,}/)*$hashDirRegex(?:/|$)!", $relPath, $m ) ) {
1508 return '.' . implode(
'', array_slice( $m, 1 ) );
1528 return ( $shard !==
null );
1540 if ( isset( $this->shardViaHashLevels[$container] ) ) {
1541 $config = $this->shardViaHashLevels[$container];
1542 $hashLevels = (int)$config[
'levels'];
1543 if ( $hashLevels == 1 || $hashLevels == 2 ) {
1544 $hashBase = (int)$config[
'base'];
1545 if ( $hashBase == 16 || $hashBase == 36 ) {
1546 return [ $hashLevels, $hashBase, $config[
'repeat'] ];
1551 return [ 0, 0,
false ];
1563 if ( $digits > 0 ) {
1564 $numShards = pow(
$base, $digits );
1565 for ( $index = 0; $index < $numShards; $index++ ) {
1566 $shards[] =
'.' . Wikimedia\base_convert( $index, 10,
$base, $digits );
1580 if ( $this->domainId !=
'' ) {
1581 return "{$this->domainId}-$container";
1610 return $relStoragePath;
1620 return "filebackend:{$this->name}:{$this->domainId}:container:{$container}";
1630 $this->memCache->set( $this->
containerCacheKey( $container ), $val, 14 * 86400 );
1640 if ( !$this->memCache->delete( $this->containerCacheKey( $container ), 300 ) ) {
1641 trigger_error(
"Unable to delete stat cache for container $container." );
1658 foreach ( $items
as $item ) {
1659 if ( self::isStoragePath( $item ) ) {
1661 } elseif ( is_string( $item ) ) {
1668 if ( $fullCont !==
null ) {
1675 $values = $this->memCache->getMulti( array_keys( $contNames ) );
1676 foreach ( $values
as $cacheKey => $val ) {
1677 $contInfo[$contNames[$cacheKey]] = $val;
1701 return "filebackend:{$this->name}:{$this->domainId}:file:" . sha1(
$path );
1714 if (
$path ===
null ) {
1718 $ttl = $this->memCache->adaptiveTTL( $mtime, 7 * 86400, 300, .1 );
1721 $this->memCache->set( $key, $val, $ttl );
1734 if (
$path ===
null ) {
1737 if ( !$this->memCache->delete( $this->fileCacheKey(
$path ), 300 ) ) {
1738 trigger_error(
"Unable to delete stat cache for file $path." );
1755 foreach ( $items
as $item ) {
1756 if ( self::isStoragePath( $item ) ) {
1761 $paths = array_filter( $paths,
'strlen' );
1765 if ( $rel !==
null ) {
1770 $values = $this->memCache->getMulti( array_keys( $pathNames ) );
1771 foreach ( $values
as $cacheKey => $val ) {
1772 $path = $pathNames[$cacheKey];
1773 if ( is_array( $val ) ) {
1774 $val[
'latest'] =
false;
1775 $this->cheapCache->set(
$path,
'stat', $val );
1776 if ( isset( $val[
'sha1'] ) ) {
1777 $this->cheapCache->set(
$path,
'sha1',
1778 [
'hash' => $val[
'sha1'],
'latest' =>
false ] );
1780 if ( isset( $val[
'xattr'] ) ) {
1782 $this->cheapCache->set(
$path,
'xattr',
1783 [
'map' => $val[
'xattr'],
'latest' =>
false ] );
1797 $newXAttr = [
'headers' => [],
'metadata' => [] ];
1800 $newXAttr[
'headers'][strtolower(
$name )] =
$value;
1804 $newXAttr[
'metadata'][strtolower(
$name )] =
$value;
1817 $opts[
'concurrency'] = 1;
1818 if ( $this->parallelize ===
'implicit' ) {
1819 if ( !isset( $opts[
'parallelize'] ) || $opts[
'parallelize'] ) {
1822 } elseif ( $this->parallelize ===
'explicit' ) {
1823 if ( !empty( $opts[
'parallelize'] ) ) {
1840 if ( $this->mimeCallback ) {
1841 return call_user_func_array( $this->mimeCallback, func_get_args() );
1845 if ( $fsPath !==
null && function_exists(
'finfo_file' ) ) {
1846 $finfo = finfo_open( FILEINFO_MIME_TYPE );
1847 $mime = finfo_file( $finfo, $fsPath );
1848 finfo_close( $finfo );
1851 return is_string(
$mime ) ?
$mime :
'unknown/unknown';
1877 array_map(
'fclose', $this->resourcesToClose );
1918 $iter =
new AppendIterator();
1919 foreach ( $suffixes
as $suffix ) {
1920 $iter->append( $this->
listFromShard( $this->container . $suffix ) );
1923 parent::__construct( $iter );
1927 $rel = $this->getInnerIterator()->current();
1928 $path = $this->params[
'dir'] .
"/{$rel}";
1929 if ( $this->backend->isSingleShardPathInternal(
$path ) ) {
1931 } elseif ( isset( $this->multiShardPaths[$rel] ) ) {
1935 $this->multiShardPaths[$rel] = 1;
1943 $this->multiShardPaths = [];
1960 $list = $this->backend->getDirectoryListInternal(
1962 if ( $list ===
null ) {
1963 return new ArrayIterator( [] );
1965 return is_array( $list ) ?
new ArrayIterator( $list ) : $list;
1975 $list = $this->backend->getFileListInternal(
1977 if ( $list ===
null ) {
1978 return new ArrayIterator( [] );
1980 return is_array( $list ) ?
new ArrayIterator( $list ) : $list;
interface is intended to be more or less compatible with the PHP memcached client.
static convert( $style=TS_UNIX, $ts)
Convert a timestamp string to a given format.
A BagOStuff object with no objects in it.
static placeholderProps()
Placeholder file properties to use for files that don't exist.
File backend exception for checked exceptions (e.g.
FileBackendStore helper class for performing asynchronous file operations.
closeResources()
Close all open file handles.
FileBackendStore $backend
Iterator for listing directories.
listFromShard( $container)
Get the list for a given container shard.
Iterator for listing regular files.
listFromShard( $container)
Get the list for a given container shard.
FileBackendStore helper function to handle listings that span container shards.
__construct(FileBackendStore $backend, $container, $dir, array $suffixes, array $params)
string $container
Full container name.
string $directory
Resolved relative path.
FileBackendStore $backend
listFromShard( $container)
Get the list for a given container shard.
Base class for all backends using particular storage medium.
preloadFileStat(array $params)
Preload file stat information (concurrently if possible) into in-process cache.
containerCacheKey( $container)
Get the cache key for a container.
doGetLocalReferenceMulti(array $params)
resolveContainerName( $container)
Resolve a container name, checking if it's allowed by the backend.
static normalizeXAttributes(array $xattr)
Normalize file headers/metadata to the FileBackend::getFileXAttributes() format.
getLocalReferenceMulti(array $params)
Like getLocalReference() except it takes an array of storage paths and returns a map of storage paths...
setFileCache( $path, array $val)
Set the cached stat info for a file path.
moveInternal(array $params)
Move a file from one storage path to another in the backend.
setContainerCache( $container, array $val)
Set the cached info for a container.
isPathUsableInternal( $storagePath)
Check if a file can be created or changed at a given storage path.
doGetFileContentsMulti(array $params)
doStreamFile(array $params)
const CACHE_EXPENSIVE_SIZE
getFileTimestamp(array $params)
Get the last-modified timestamp of the file at a storage path.
doGetLocalCopyMulti(array $params)
getScopedLocksForOps(array $ops, StatusValue $status)
Get an array of scoped locks needed for a batch of file operations.
doQuickOperationsInternal(array $ops)
doCleanInternal( $container, $dir, array $params)
callable $mimeCallback
Method to get the MIME type of files.
getPathsToLockForOpsInternal(array $performOps)
Get a list of storage paths to lock for a list of operations Returns an array with LockManager::LOCK_...
executeOpHandlesInternal(array $fileOpHandles)
Execute a list of FileBackendStoreOpHandle handles in parallel.
doPrepareInternal( $container, $dir, array $params)
concatenate(array $params)
Concatenate a list of storage files into a single file system file.
storeInternal(array $params)
Store a file into the backend from a file on disk.
getFileProps(array $params)
Get the properties of the file at a storage path in the backend.
getDirectoryList(array $params)
Get an iterator to list all directories under a storage directory.
resolveStoragePath( $storagePath)
Splits a storage path into an internal container name, an internal relative file name,...
copyInternal(array $params)
Copy a file from one storage path to another in the backend.
doStoreInternal(array $params)
directoriesAreVirtual()
Is this a key/value store where directories are just virtual? Virtual directories exists in so much a...
doGetFileStat(array $params)
getFileStat(array $params)
Get quick information about a file at a storage path in the backend.
resolveStoragePathReal( $storagePath)
Like resolveStoragePath() except null values are returned if the container is sharded and the shard c...
clearCache(array $paths=null)
Invalidate any in-process file stat and property cache.
doPublishInternal( $container, $dir, array $params)
doGetFileStatMulti(array $params)
Get file stat information (concurrently if possible) for several files.
ProcessCacheLRU $expensiveCache
Map of paths to large (RAM/disk) cache items.
getFileSha1Base36(array $params)
Get a SHA-1 hash of the file at a storage path in the backend.
static isValidContainerName( $container)
Check if a full container name is valid.
getFileListInternal( $container, $dir, array $params)
Do not call this function from places outside FileBackend.
doCopyInternal(array $params)
getLocalCopyMulti(array $params)
Like getLocalCopy() except it takes an array of storage paths and returns a map of storage paths to T...
getFileContentsMulti(array $params)
Like getFileContents() except it takes an array of storage paths and returns a map of storage paths t...
doClearCache(array $paths=null)
Clears any additional stat caches for storage paths.
fullContainerName( $container)
Get the full container name, including the wiki ID prefix.
primeFileCache(array $items)
Do a batch lookup from cache for file stats for all paths used in a list of storage paths or FileOp o...
doOperationsInternal(array $ops, array $opts)
isSingleShardPathInternal( $storagePath)
Check if a storage path maps to a single shard.
directoryExists(array $params)
Check if a directory exists at a given storage path.
doDeleteInternal(array $params)
getContainerSuffixes( $container)
Get a list of full container shard suffixes for a container.
primeContainerCache(array $items)
Do a batch lookup from cache for container stats for all containers used in a list of container names...
sanitizeOpHeaders(array $op)
Normalize and filter HTTP headers from a file operation.
doDescribeInternal(array $params)
doGetFileSha1Base36(array $params)
deleteInternal(array $params)
Delete a file at the storage path.
doPrimeContainerCache(array $containerInfo)
Fill the backend-specific process cache given an array of resolved container names and their correspo...
doMoveInternal(array $params)
maxFileSizeInternal()
Get the maximum allowable file size given backend medium restrictions and basic performance constrain...
describeInternal(array $params)
Alter metadata for a file at the storage path.
streamFile(array $params)
Stream the file at a storage path in the backend.
getOperationsInternal(array $ops)
Return a list of FileOp objects from a list of operations.
deleteFileCache( $path)
Delete the cached stat info for a file path.
setConcurrencyFlags(array $opts)
Set the 'concurrency' option from a list of operation options.
getFileXAttributes(array $params)
Get metadata about a file at a storage path in the backend.
getContentType( $storagePath, $content, $fsPath)
Get the content type to use in HEAD/GET requests for a file.
ProcessCacheLRU $cheapCache
Map of paths to small (RAM/disk) cache items.
preloadCache(array $paths)
Preload persistent file stat cache and property cache into in-process cache.
resolveContainerPath( $container, $relStoragePath)
Resolve a relative storage path, checking if it's allowed by the backend.
doDirectoryExists( $container, $dir, array $params)
getFileHttpUrl(array $params)
__construct(array $config)
doGetFileXAttributes(array $params)
doExecuteOpHandlesInternal(array $fileOpHandles)
nullInternal(array $params)
No-op file operation that does nothing.
getFileSize(array $params)
Get the size (bytes) of a file at a storage path in the backend.
array $shardViaHashLevels
Map of container names to sharding config.
fileCacheKey( $path)
Get the cache key for a file path.
doConcatenate(array $params)
doSecureInternal( $container, $dir, array $params)
doCreateInternal(array $params)
fileExists(array $params)
Check if a file exists at a storage path in the backend.
getDirectoryListInternal( $container, $dir, array $params)
Do not call this function from places outside FileBackend.
static isValidShortContainerName( $container)
Check if a short container name is valid.
getContainerHashLevels( $container)
Get the sharding config for a container.
getContainerShard( $container, $relPath)
Get the container name shard suffix for a given path.
deleteContainerCache( $container)
Delete the cached info for a container.
createInternal(array $params)
Create a file in the backend with the given contents.
getFileList(array $params)
Get an iterator to list all stored files under a storage directory.
Base class for all file backend classes (including multi-write backends).
string $name
Unique backend name.
static splitStoragePath( $storagePath)
Split a storage path into a backend name, a container name, and a relative file path.
static normalizeContainerPath( $path)
Validate and normalize a relative storage path.
getScopedFileLocks(array $paths, $type, StatusValue $status, $timeout=0)
Lock the files at the given storage paths in the backend.
getTopDirectoryList(array $params)
Same as FileBackend::getDirectoryList() except only lists directories that are immediately under the ...
newStatus()
Yields the result of the status wrapper callback on either:
scopedProfileSection( $section)
static normalizeStoragePath( $storagePath)
Normalize a storage path by cleaning up directory separators.
int $concurrency
How many operations can be done in parallel.
getLocalReference(array $params)
Returns a file system file, identical to the file at a storage path.
static attempt(array $performOps, array $opts, FileJournal $journal)
Attempt to perform a series of file operations.
Functions related to the output of file content.
static send404Message( $fname, $flags=0)
Send out a standard 404 message for a file.
Handles per process caching of items.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Multi-datacenter aware caching interface.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
while(( $__line=Maintenance::readconsole()) !==false) print
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
the array() calling protocol came about after MediaWiki 1.4rc1.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
it s the revision text itself In either if gzip is the revision text is gzipped $flags
processing should stop and the error should be shown to the user * false
if(count( $args)==0) $dir
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
if( $ext=='php'|| $ext=='php5') $mime
The most up to date schema for the tables in the database will always be tables sql in the maintenance directory
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.