72 parent::__construct( $config );
73 $this->mimeCallback = isset( $config[
'mimeCallback'] )
74 ? $config[
'mimeCallback']
79 $this->expensiveCache =
new ProcessCacheLRU( self::CACHE_EXPENSIVE_SIZE );
130 if ( !isset( $params[
'dstExists'] ) || $params[
'dstExists'] ) {
171 if ( !isset( $params[
'dstExists'] ) || $params[
'dstExists'] ) {
209 if ( !isset( $params[
'dstExists'] ) || $params[
'dstExists'] ) {
274 $this->
clearCache( [ $params[
'src'], $params[
'dst'] ] );
276 if ( !isset( $params[
'dstExists'] ) || $params[
'dstExists'] ) {
289 unset( $params[
'async'] );
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]" );
377 $tmpPath = $params[
'dst'];
378 unset( $params[
'latest'] );
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 ) {
449 $status->fatal(
'backend-fail-invalidpath', $params[
'dir'] );
454 if ( $shard !== null ) {
457 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
458 list( , $shortCont, ) = self::splitStoragePath( $params[
'dir'] );
483 if (
$dir === null ) {
484 $status->fatal(
'backend-fail-invalidpath', $params[
'dir'] );
489 if ( $shard !== null ) {
492 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
493 list( , $shortCont, ) = self::splitStoragePath( $params[
'dir'] );
518 if (
$dir === null ) {
519 $status->fatal(
'backend-fail-invalidpath', $params[
'dir'] );
524 if ( $shard !== null ) {
527 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
528 list( , $shortCont, ) = self::splitStoragePath( $params[
'dir'] );
555 if ( $subDirsRel !== null ) {
556 foreach ( $subDirsRel
as $subDirRel ) {
557 $subDir = $params[
'dir'] .
"/{$subDirRel}";
558 $status->merge( $this->
doClean( [
'dir' => $subDir ] + $params ) );
560 unset( $subDirsRel );
565 if (
$dir === null ) {
566 $status->fatal(
'backend-fail-invalidpath', $params[
'dir'] );
572 $filesLockEx = [ $params[
'dir'] ];
578 if ( $shard !== null ) {
582 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
583 list( , $shortCont, ) = self::splitStoragePath( $params[
'dir'] );
608 return ( $stat === null ) ? null : (bool)$stat;
615 return $stat ? $stat[
'mtime'] :
false;
622 return $stat ? $stat[
'size'] :
false;
626 $path = self::normalizeStoragePath( $params[
'src'] );
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'] ) ) {
660 $stat[
'xattr'] = self::normalizeXAttributes( $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();
708 $path = self::normalizeStoragePath( $params[
'src'] );
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'] ) {
723 $fields = is_array( $fields ) ? self::normalizeXAttributes( $fields ) :
false;
724 $this->cheapCache->set(
$path,
'xattr', [
'map' => $fields,
'latest' => $latest ] );
735 return [
'headers' => [],
'metadata' => [] ];
739 $path = self::normalizeStoragePath( $params[
'src'] );
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'] );
789 foreach ( $params[
'srcs']
as $src ) {
790 $path = self::normalizeStoragePath( $src );
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'] : [];
855 $params[
'headers'] = isset( $params[
'headers'] ) ? $params[
'headers'] : [];
858 if ( ( empty( $params[
'headless'] ) || $params[
'headers'] ) && headers_sent() ) {
859 print "Headers already sent, terminating.\n";
860 $status->fatal(
'backend-fail-stream', $params[
'src'] );
890 $res = $streamer->stream( $params[
'headers'],
true, $params[
'options'],
$flags );
897 $status->fatal(
'backend-fail-stream', $params[
'src'] );
905 if (
$dir === null ) {
908 if ( $shard !== null ) {
911 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
912 list( , $shortCont, ) = self::splitStoragePath( $params[
'dir'] );
919 } elseif ( $exists === null ) {
940 if (
$dir === null ) {
943 if ( $shard !== null ) {
947 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
949 list( , $shortCont, ) = self::splitStoragePath( $params[
'dir'] );
970 if (
$dir === null ) {
973 if ( $shard !== null ) {
977 $this->logger->debug( __METHOD__ .
": iterating over all container shards.\n" );
979 list( , $shortCont, ) = self::splitStoragePath( $params[
'dir'] );
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} " .
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 ) {
1212 } elseif ( $fileOpHandle->backend->getName() !== $this->
getName() ) {
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'] ) ) {
1336 $stat[
'xattr'] = self::normalizeXAttributes( $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" );
1396 return self::isValidContainerName( $container ) && !preg_match(
'/[.]/', $container );
1413 return (
bool)preg_match(
'/^[a-z0-9][a-z0-9-_.]{0,199}$/i', $container );
1430 list( $backend, $shortCont, $relPath ) = self::splitStoragePath( $storagePath );
1431 if ( $backend === $this->
name ) {
1432 $relPath = self::normalizeContainerPath( $relPath );
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'] ) ) {
1781 $val[
'xattr'] = self::normalizeXAttributes( $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;
newStatus()
Yields the result of the status wrapper callback on either:
primeContainerCache(array $items)
Do a batch lookup from cache for container stats for all containers used in a list of container names...
doPublishInternal($container, $dir, array $params)
getFileHttpUrl(array $params)
const CACHE_EXPENSIVE_SIZE
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
doOperationsInternal(array $ops, array $opts)
setConcurrencyFlags(array $opts)
Set the 'concurrency' option from a list of operation options.
the array() calling protocol came about after MediaWiki 1.4rc1.
setFileCache($path, array $val)
Set the cached stat info for a file path.
Iterator for listing regular files.
moveInternal(array $params)
Move a file from one storage path to another in the backend.
processing should stop and the error should be shown to the user * false
concatenate(array $params)
doPrepareInternal($container, $dir, array $params)
doGetLocalReferenceMulti(array $params)
resolveContainerName($container)
Resolve a container name, checking if it's allowed by the backend.
getPathsToLockForOpsInternal(array $performOps)
Get a list of storage paths to lock for a list of operations Returns an array with LockManager::LOCK_...
scopedProfileSection($section)
static normalizeXAttributes(array $xattr)
Normalize file headers/metadata to the FileBackend::getFileXAttributes() format.
listFromShard($container)
Get the list for a given container shard.
doGetFileXAttributes(array $params)
getFileStat(array $params)
getContainerSuffixes($container)
Get a list of full container shard suffixes for a container.
listFromShard($container)
The most up to date schema for the tables in the database will always be tables sql in the maintenance directory
__construct(array $config)
if($ext== 'php'||$ext== 'php5') $mime
getName()
Get the unique backend name.
string $directory
Resolved relative path.
getScopedFileLocks(array $paths, $type, StatusValue $status, $timeout=0)
Lock the files at the given storage paths in the backend.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
string $container
Full container name.
ProcessCacheLRU $expensiveCache
Map of paths to large (RAM/disk) cache items.
fileCacheKey($path)
Get the cache key for a file path.
FileBackendStore helper function to handle listings that span container shards.
static isValidContainerName($container)
Check if a full container name is valid.
int $concurrency
How many operations can be done in parallel.
storeInternal(array $params)
Store a file into the backend from a file on disk.
array $shardViaHashLevels
Map of container names to sharding config.
doSecureInternal($container, $dir, array $params)
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
doCreateInternal(array $params)
static newEmpty()
Get an instance that wraps EmptyBagOStuff.
streamFile(array $params)
getFileSha1Base36(array $params)
executeOpHandlesInternal(array $fileOpHandles)
Execute a list of FileBackendStoreOpHandle handles in parallel.
getFileSize(array $params)
doQuickOperationsInternal(array $ops)
File backend exception for checked exceptions (e.g.
isPathUsableInternal($storagePath)
Check if a file can be created or changed at a given storage path.
Functions related to the output of file content.
ProcessCacheLRU $cheapCache
Map of paths to small (RAM/disk) cache items.
createInternal(array $params)
Create a file in the backend with the given contents.
fileExists(array $params)
directoryExists(array $params)
doStreamFile(array $params)
getFileXAttributes(array $params)
nullInternal(array $params)
No-op file operation that does nothing.
deleteInternal(array $params)
Delete a file at the storage path.
preloadCache(array $paths)
doGetLocalCopyMulti(array $params)
getFileContentsMulti(array $params)
getFileTimestamp(array $params)
maxFileSizeInternal()
Get the maximum allowable file size given backend medium restrictions and basic performance constrain...
FileBackendStore $backend
static placeholderProps()
Placeholder file properties to use for files that don't exist.
getOperationsInternal(array $ops)
Return a list of FileOp objects from a list of operations.
clearCache(array $paths=null)
A BagOStuff object with no objects in it.
callable $mimeCallback
Method to get the MIME type of files.
resolveStoragePathReal($storagePath)
Like resolveStoragePath() except null values are returned if the container is sharded and the shard c...
listFromShard($container)
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
doGetFileStatMulti(array $params)
Get file stat information (concurrently if possible) for several files.
getContentType($storagePath, $content, $fsPath)
Get the content type to use in HEAD/GET requests for a file.
copyInternal(array $params)
Copy a file from one storage path to another in the backend.
doGetFileStat(array $params)
string $name
Unique backend name.
doGetFileContentsMulti(array $params)
Base class for all backends using particular storage medium.
preloadFileStat(array $params)
fullContainerName($container)
Get the full container name, including the wiki ID prefix.
directoriesAreVirtual()
Is this a key/value store where directories are just virtual? Virtual directories exists in so much a...
getFileList(array $params)
closeResources()
Close all open file handles.
__construct(FileBackendStore $backend, $container, $dir, array $suffixes, array $params)
containerCacheKey($container)
Get the cache key for a container.
Iterator for listing directories.
getContainerHashLevels($container)
Get the sharding config for a container.
static normalizeStoragePath($storagePath)
Normalize a storage path by cleaning up directory separators.
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
static attempt(array $performOps, array $opts, FileJournal $journal)
Attempt to perform a series of file operations.
resolveContainerPath($container, $relStoragePath)
Resolve a relative storage path, checking if it's allowed by the backend.
setContainerCache($container, array $val)
Set the cached info for a container.
doConcatenate(array $params)
getContainerShard($container, $relPath)
Get the container name shard suffix for a given path.
FileBackendStore $backend
getDirectoryListInternal($container, $dir, array $params)
Do not call this function from places outside FileBackend.
doPrimeContainerCache(array $containerInfo)
Fill the backend-specific process cache given an array of resolved container names and their correspo...
static send404Message($fname, $flags=0)
Send out a standard 404 message for a file.
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
doClearCache(array $paths=null)
Clears any additional stat caches for storage paths.
describeInternal(array $params)
Alter metadata for a file at the 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
doStoreInternal(array $params)
isSingleShardPathInternal($storagePath)
Check if a storage path maps to a single shard.
Base class for all file backend classes (including multi-write backends).
doDeleteInternal(array $params)
getTopDirectoryList(array $params)
Same as FileBackend::getDirectoryList() except only lists directories that are immediately under the ...
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
static convert($style=TS_UNIX, $ts)
Convert a timestamp string to a given format.
deleteFileCache($path)
Delete the cached stat info for a file path.
getScopedLocksForOps(array $ops, StatusValue $status)
doMoveInternal(array $params)
sanitizeOpHeaders(array $op)
Normalize and filter HTTP headers from a file operation.
doDescribeInternal(array $params)
static isValidShortContainerName($container)
Check if a short container name is valid.
doCleanInternal($container, $dir, array $params)
getLocalReferenceMulti(array $params)
FileBackendStore helper class for performing asynchronous file operations.
doGetFileSha1Base36(array $params)
deleteContainerCache($container)
Delete the cached info for a container.
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...
getFileListInternal($container, $dir, array $params)
Do not call this function from places outside FileBackend.
doCopyInternal(array $params)
getLocalReference(array $params)
Returns a file system file, identical to the file at a storage path.
getDirectoryList(array $params)
Handles per process caching of items.
getLocalCopyMulti(array $params)
getFileProps(array $params)
doDirectoryExists($container, $dir, array $params)
resolveStoragePath($storagePath)
Splits a storage path into an internal container name, an internal relative file name, and a container shard suffix.
doExecuteOpHandlesInternal(array $fileOpHandles)