Go to the documentation of this file.
24 use Wikimedia\Timestamp\ConvertibleTimestamp;
73 parent::__construct( $config );
74 $this->mimeCallback = isset( $config[
'mimeCallback'] )
75 ? $config[
'mimeCallback']
80 $this->expensiveCache =
new ProcessCacheLRU( self::CACHE_EXPENSIVE_SIZE );
295 if ( $nsrc !== $ndst &&
$status->isOK() ) {
359 $start_time = microtime(
true );
361 $sec = microtime(
true ) - $start_time;
364 " failed to concatenate " .
count(
$params[
'srcs'] ) .
" file(s) [$sec sec]" );
382 MediaWiki\suppressWarnings();
383 $ok = ( is_file( $tmpPath ) && filesize( $tmpPath ) == 0 );
384 MediaWiki\restoreWarnings();
386 $status->fatal(
'backend-fail-opentemp', $tmpPath );
393 foreach ( $fsFiles
as $path => &$fsFile ) {
406 $tmpHandle = fopen( $tmpPath,
'ab' );
407 if ( $tmpHandle ===
false ) {
408 $status->fatal(
'backend-fail-opentemp', $tmpPath );
414 foreach ( $fsFiles
as $virtualSource => $fsFile ) {
416 $sourceHandle = fopen( $fsFile->getPath(),
'rb' );
417 if ( $sourceHandle ===
false ) {
418 fclose( $tmpHandle );
419 $status->fatal(
'backend-fail-read', $virtualSource );
424 if ( !stream_copy_to_stream( $sourceHandle, $tmpHandle ) ) {
425 fclose( $sourceHandle );
426 fclose( $tmpHandle );
427 $status->fatal(
'backend-fail-writetemp', $tmpPath );
431 fclose( $sourceHandle );
433 if ( !fclose( $tmpHandle ) ) {
434 $status->fatal(
'backend-fail-closetemp', $tmpPath );
449 if (
$dir ===
null ) {
455 if ( $shard !==
null ) {
458 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
484 if (
$dir ===
null ) {
490 if ( $shard !==
null ) {
493 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
519 if (
$dir ===
null ) {
525 if ( $shard !==
null ) {
528 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
556 if ( $subDirsRel !==
null ) {
557 foreach ( $subDirsRel
as $subDirRel ) {
558 $subDir =
$params[
'dir'] .
"/{$subDirRel}";
561 unset( $subDirsRel );
566 if (
$dir ===
null ) {
573 $filesLockEx = [
$params[
'dir'] ];
579 if ( $shard !==
null ) {
583 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
609 return ( $stat ===
null ) ? null : (bool)$stat;
616 return $stat ? $stat[
'mtime'] :
false;
623 return $stat ? $stat[
'size'] :
false;
628 if (
$path ===
null ) {
632 $latest = !empty(
$params[
'latest'] );
633 if ( !$latest && !$this->cheapCache->has(
$path,
'stat', self::CACHE_TTL ) ) {
636 if ( $this->cheapCache->has(
$path,
'stat', self::CACHE_TTL ) ) {
637 $stat = $this->cheapCache->get(
$path,
'stat' );
640 if ( is_array( $stat ) ) {
641 if ( !$latest || $stat[
'latest'] ) {
644 } elseif ( in_array( $stat, [
'NOT_EXIST',
'NOT_EXIST_LATEST' ] ) ) {
645 if ( !$latest || $stat ===
'NOT_EXIST_LATEST' ) {
651 if ( is_array( $stat ) ) {
653 $stat[
'latest'] = isset( $stat[
'latest'] ) ? $stat[
'latest'] : $latest;
654 $this->cheapCache->set(
$path,
'stat', $stat );
656 if ( isset( $stat[
'sha1'] ) ) {
657 $this->cheapCache->set(
$path,
'sha1',
658 [
'hash' => $stat[
'sha1'],
'latest' => $latest ] );
660 if ( isset( $stat[
'xattr'] ) ) {
662 $this->cheapCache->set(
$path,
'xattr',
663 [
'map' => $stat[
'xattr'],
'latest' => $latest ] );
665 } elseif ( $stat ===
false ) {
666 $this->cheapCache->set(
$path,
'stat', $latest ?
'NOT_EXIST_LATEST' :
'NOT_EXIST' );
667 $this->cheapCache->set(
$path,
'xattr', [
'map' =>
false,
'latest' => $latest ] );
668 $this->cheapCache->set(
$path,
'sha1', [
'hash' =>
false,
'latest' => $latest ] );
669 $this->logger->debug( __METHOD__ .
": File $path does not exist.\n" );
671 $this->logger->warning( __METHOD__ .
": Could not stat file $path.\n" );
700 MediaWiki\suppressWarnings();
701 $contents[
$path] = $fsFile ? file_get_contents( $fsFile->getPath() ) :
false;
702 MediaWiki\restoreWarnings();
710 if (
$path ===
null ) {
714 $latest = !empty(
$params[
'latest'] );
715 if ( $this->cheapCache->has(
$path,
'xattr', self::CACHE_TTL ) ) {
716 $stat = $this->cheapCache->get(
$path,
'xattr' );
719 if ( !$latest || $stat[
'latest'] ) {
725 $this->cheapCache->set(
$path,
'xattr', [
'map' => $fields,
'latest' => $latest ] );
736 return [
'headers' => [],
'metadata' => [] ];
741 if (
$path ===
null ) {
745 $latest = !empty(
$params[
'latest'] );
746 if ( $this->cheapCache->has(
$path,
'sha1', self::CACHE_TTL ) ) {
747 $stat = $this->cheapCache->get(
$path,
'sha1' );
750 if ( !$latest || $stat[
'latest'] ) {
751 return $stat[
'hash'];
755 $this->cheapCache->set(
$path,
'sha1', [
'hash' => $hash,
'latest' => $latest ] );
770 return $fsFile->getSha1Base36();
788 $latest = !empty(
$params[
'latest'] );
792 if (
$path ===
null ) {
793 $fsFiles[$src] =
null;
794 } elseif ( $this->expensiveCache->has(
$path,
'localRef' ) ) {
795 $val = $this->expensiveCache->get(
$path,
'localRef' );
798 if ( !$latest || $val[
'latest'] ) {
799 $fsFiles[$src] = $val[
'object'];
804 $params[
'srcs'] = array_diff(
$params[
'srcs'], array_keys( $fsFiles ) );
806 $fsFiles[
$path] = $fsFile;
808 $this->expensiveCache->set(
$path,
'localRef',
809 [
'object' => $fsFile,
'latest' => $latest ] );
855 $params[
'options'] = isset(
$params[
'options'] ) ?
$params[
'options'] : [];
859 if ( ( empty(
$params[
'headless'] ) ||
$params[
'headers'] ) && headers_sent() ) {
860 print
"Headers already sent, terminating.\n";
906 if (
$dir ===
null ) {
909 if ( $shard !==
null ) {
912 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
920 } elseif ( $exists ===
null ) {
941 if (
$dir ===
null ) {
944 if ( $shard !==
null ) {
948 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
971 if (
$dir ===
null ) {
974 if ( $shard !==
null ) {
978 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
1012 'store' =>
'StoreFileOp',
1013 'copy' =>
'CopyFileOp',
1014 'move' =>
'MoveFileOp',
1015 'delete' =>
'DeleteFileOp',
1016 'create' =>
'CreateFileOp',
1017 'describe' =>
'DescribeFileOp',
1018 'null' =>
'NullFileOp'
1023 foreach ( $ops
as $operation ) {
1024 $opName = $operation[
'op'];
1025 if ( isset( $supportedOps[$opName] ) ) {
1026 $class = $supportedOps[$opName];
1030 $performOps[] =
new $class( $this,
$params, $this->logger );
1051 $paths = [
'sh' => [],
'ex' => [] ];
1052 foreach ( $performOps
as $fileOp ) {
1053 $paths[
'sh'] = array_merge( $paths[
'sh'], $fileOp->storagePathsRead() );
1054 $paths[
'ex'] = array_merge( $paths[
'ex'], $fileOp->storagePathsChanged() );
1057 $paths[
'sh'] = array_diff( $paths[
'sh'], $paths[
'ex'] );
1059 $paths[
'sh'] = array_merge( $paths[
'sh'], array_map(
'dirname', $paths[
'ex'] ) );
1078 $ops = array_map( [ $this,
'sanitizeOpHeaders' ], $ops );
1084 if ( empty( $opts[
'nonLocking'] ) ) {
1096 if ( empty( $opts[
'preserveCache'] ) ) {
1102 foreach ( $performOps
as $performOp ) {
1103 $paths = array_merge( $paths, $performOp->storagePathsRead() );
1104 $paths = array_merge( $paths, $performOp->storagePathsChanged() );
1108 $this->cheapCache->resize( max( 2 *
count( $paths ), self::CACHE_CHEAP_SIZE ) );
1113 $ok = $this->
preloadFileStat( [
'srcs' => $paths,
'latest' =>
true ] );
1121 $subStatus = $this->
newStatus(
'backend-fail-internal', $this->
name );
1122 foreach ( $ops
as $i => $op ) {
1123 $subStatus->success[$i] =
false;
1124 ++$subStatus->failCount;
1132 $status->success = $subStatus->success;
1135 $this->cheapCache->resize( self::CACHE_CHEAP_SIZE );
1145 $ops = array_map( [ $this,
'sanitizeOpHeaders' ], $ops );
1150 $supportedOps = [
'create',
'store',
'copy',
'move',
'delete',
'describe',
'null' ];
1152 $async = ( $this->parallelize ===
'implicit' &&
count( $ops ) > 1 );
1156 $fileOpHandles = [];
1157 $curFileOpHandles = [];
1160 if ( !in_array(
$params[
'op'], $supportedOps ) ) {
1161 throw new FileBackendError(
"Operation '{$params['op']}' is not supported." );
1163 $method =
$params[
'op'] .
'Internal';
1164 $subStatus = $this->$method( [
'async' => $async ] +
$params );
1166 if (
count( $curFileOpHandles ) >= $maxConcurrency ) {
1167 $fileOpHandles[] = $curFileOpHandles;
1168 $curFileOpHandles = [];
1170 $curFileOpHandles[$index] = $subStatus->value;
1172 $statuses[$index] = $subStatus;
1175 if (
count( $curFileOpHandles ) ) {
1176 $fileOpHandles[] = $curFileOpHandles;
1179 foreach ( $fileOpHandles
as $fileHandleBatch ) {
1183 foreach ( $statuses
as $index => $subStatus ) {
1185 if ( $subStatus->isOK() ) {
1186 $status->success[$index] =
true;
1189 $status->success[$index] =
false;
1209 foreach ( $fileOpHandles
as $fileOpHandle ) {
1211 throw new InvalidArgumentException(
"Expected FileBackendStoreOpHandle object." );
1212 } elseif ( $fileOpHandle->backend->getName() !== $this->
getName() ) {
1213 throw new InvalidArgumentException(
"Expected handle for this file 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 ) {
1717 $mtime = ConvertibleTimestamp::convert( TS_UNIX, $val[
'mtime'] );
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;
doGetFileXAttributes(array $params)
isPathUsableInternal( $storagePath)
Check if a file can be created or changed at a given storage path.
static splitStoragePath( $storagePath)
Split a storage path into a backend name, a container name, and a relative file path.
directoryExists(array $params)
Check if a directory exists at a given storage path.
getOperationsInternal(array $ops)
Return a list of FileOp objects from a list of operations.
FileBackendStore $backend
listFromShard( $container)
Get the list for a given container shard.
static isValidShortContainerName( $container)
Check if a short container name is valid.
Iterator for listing regular files.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
getFileSha1Base36(array $params)
Get a SHA-1 hash of the file at a storage path in the backend.
static normalizeContainerPath( $path)
Validate and normalize a relative storage path.
processing should stop and the error should be shown to the user * false
The most up to date schema for the tables in the database will always be tables sql in the maintenance directory
directoriesAreVirtual()
Is this a key/value store where directories are just virtual? Virtual directories exists in so much a...
Base class for all file backend classes (including multi-write backends).
ProcessCacheLRU $cheapCache
Map of paths to small (RAM/disk) cache items.
A BagOStuff object with no objects in it.
resolveStoragePath( $storagePath)
Splits a storage path into an internal container name, an internal relative file name,...
sanitizeOpHeaders(array $op)
Normalize and filter HTTP headers from a file operation.
getName()
Get the unique backend name.
copyInternal(array $params)
Copy a file from one storage path to another in the backend.
File backend exception for checked exceptions (e.g.
getScopedFileLocks(array $paths, $type, StatusValue $status, $timeout=0)
Lock the files at the given storage paths in the backend.
FileBackendStore helper function to handle listings that span container shards.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
doGetFileSha1Base36(array $params)
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
fileExists(array $params)
Check if a file exists at a storage path in the backend.
deleteFileCache( $path)
Delete the cached stat info for a file path.
static normalizeStoragePath( $storagePath)
Normalize a storage path by cleaning up directory separators.
executeOpHandlesInternal(array $fileOpHandles)
Execute a list of FileBackendStoreOpHandle handles in parallel.
interface is intended to be more or less compatible with the PHP memcached client.
isSingleShardPathInternal( $storagePath)
Check if a storage path maps to a single shard.
doDeleteInternal(array $params)
getFileSize(array $params)
Get the size (bytes) of a file at a storage path in the backend.
concatenate(array $params)
Concatenate a list of storage files into a single file system file.
getContainerHashLevels( $container)
Get the sharding config for a container.
doGetFileStat(array $params)
deleteContainerCache( $container)
Delete the cached info for a container.
getFileContentsMulti(array $params)
Like getFileContents() except it takes an array of storage paths and returns a map of storage paths t...
clearCache(array $paths=null)
Invalidate any in-process file stat and property cache.
doPublishInternal( $container, $dir, array $params)
getFileListInternal( $container, $dir, array $params)
Do not call this function from places outside FileBackend.
doOperationsInternal(array $ops, array $opts)
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
Iterator for listing directories.
Functions related to the output of file content.
static isValidContainerName( $container)
Check if a full container name is valid.
static placeholderProps()
Placeholder file properties to use for files that don't exist.
deleteInternal(array $params)
Delete a file at the storage path.
static newEmpty()
Get an instance that wraps EmptyBagOStuff.
resolveContainerName( $container)
Resolve a container name, checking if it's allowed by the backend.
doPrimeContainerCache(array $containerInfo)
Fill the backend-specific process cache given an array of resolved container names and their correspo...
callable $mimeCallback
Method to get the MIME type of files.
getDirectoryListInternal( $container, $dir, array $params)
Do not call this function from places outside FileBackend.
getScopedLocksForOps(array $ops, StatusValue $status)
Get an array of scoped locks needed for a batch of file operations.
static normalizeXAttributes(array $xattr)
Normalize file headers/metadata to the FileBackend::getFileXAttributes() format.
setConcurrencyFlags(array $opts)
Set the 'concurrency' option from a list of operation options.
getLocalCopyMulti(array $params)
Like getLocalCopy() except it takes an array of storage paths and returns a map of storage paths to T...
int $concurrency
How many operations can be done in parallel.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
getFileProps(array $params)
Get the properties of the file at a storage path in the backend.
FileBackendStore $backend
doConcatenate(array $params)
doDirectoryExists( $container, $dir, array $params)
getLocalReferenceMulti(array $params)
Like getLocalReference() except it takes an array of storage paths and returns a map of storage paths...
preloadFileStat(array $params)
Preload file stat information (concurrently if possible) into in-process cache.
doGetLocalReferenceMulti(array $params)
const CACHE_EXPENSIVE_SIZE
getPathsToLockForOpsInternal(array $performOps)
Get a list of storage paths to lock for a list of operations Returns an array with LockManager::LOCK_...
doCreateInternal(array $params)
getContainerShard( $container, $relPath)
Get the container name shard suffix for a given path.
listFromShard( $container)
Get the list for a given container shard.
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
getContentType( $storagePath, $content, $fsPath)
Get the content type to use in HEAD/GET requests for a file.
doCleanInternal( $container, $dir, array $params)
doCopyInternal(array $params)
doClearCache(array $paths=null)
Clears any additional stat caches for storage paths.
if( $ext=='php'|| $ext=='php5') $mime
doStoreInternal(array $params)
doMoveInternal(array $params)
getFileStat(array $params)
Get quick information about a file at a storage path in the backend.
static attempt(array $performOps, array $opts, FileJournal $journal)
Attempt to perform a series of file operations.
containerCacheKey( $container)
Get the cache key for a container.
resolveStoragePathReal( $storagePath)
Like resolveStoragePath() except null values are returned if the container is sharded and the shard c...
Multi-datacenter aware caching interface.
moveInternal(array $params)
Move a file from one storage path to another in the backend.
preloadCache(array $paths)
Preload persistent file stat cache and property cache into in-process cache.
__construct(FileBackendStore $backend, $container, $dir, array $suffixes, array $params)
getContainerSuffixes( $container)
Get a list of full container shard suffixes for a container.
Base class for all backends using particular storage medium.
getDirectoryList(array $params)
Get an iterator to list all directories under a storage directory.
FileBackendStore helper class for performing asynchronous file operations.
static send404Message( $fname, $flags=0)
Send out a standard 404 message for a file.
fullContainerName( $container)
Get the full container name, including the wiki ID prefix.
doDescribeInternal(array $params)
doExecuteOpHandlesInternal(array $fileOpHandles)
primeContainerCache(array $items)
Do a batch lookup from cache for container stats for all containers used in a list of container names...
setFileCache( $path, array $val)
Set the cached stat info for a file path.
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...
fileCacheKey( $path)
Get the cache key for a file path.
doPrepareInternal( $container, $dir, array $params)
doGetLocalCopyMulti(array $params)
doGetFileContentsMulti(array $params)
string $name
Unique backend name.
ProcessCacheLRU $expensiveCache
Map of paths to large (RAM/disk) cache items.
createInternal(array $params)
Create a file in the backend with the given contents.
resolveContainerPath( $container, $relStoragePath)
Resolve a relative storage path, checking if it's allowed by the backend.
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
string $container
Full container name.
storeInternal(array $params)
Store a file into the backend from a file on disk.
doStreamFile(array $params)
streamFile(array $params)
Stream the file at a storage path in the backend.
array $shardViaHashLevels
Map of container names to sharding config.
getTopDirectoryList(array $params)
Same as FileBackend::getDirectoryList() except only lists directories that are immediately under the ...
getFileXAttributes(array $params)
Get metadata about a file at a storage path in the backend.
getFileHttpUrl(array $params)
getLocalReference(array $params)
Returns a file system file, identical to the file at a storage path.
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
nullInternal(array $params)
No-op file operation that does nothing.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Handles per process caching of items.
getFileList(array $params)
Get an iterator to list all stored files under a storage directory.
maxFileSizeInternal()
Get the maximum allowable file size given backend medium restrictions and basic performance constrain...
getFileTimestamp(array $params)
Get the last-modified timestamp of the file at a storage path.
describeInternal(array $params)
Alter metadata for a file at the storage path.
doGetFileStatMulti(array $params)
Get file stat information (concurrently if possible) for several files.
__construct(array $config)
doSecureInternal( $container, $dir, array $params)
it s the revision text itself In either if gzip is the revision text is gzipped $flags
setContainerCache( $container, array $val)
Set the cached info for a container.
scopedProfileSection( $section)
newStatus()
Yields the result of the status wrapper callback on either:
string $directory
Resolved relative path.
doQuickOperationsInternal(array $ops)
the array() calling protocol came about after MediaWiki 1.4rc1.
closeResources()
Close all open file handles.
listFromShard( $container)
Get the list for a given container shard.