X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Ffilebackend%2FFileBackend.php;h=4cacb7af63a8c9db933cfe16cc32b988cd72b1f4;hb=95e68098cadf9daf29c4621aaeb3706bd9de33d4;hp=4ad48c70c1de0d6620dacf602ef0ab00656911d2;hpb=592c19692e8bd1218e9e58c89116566dccce0315;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/filebackend/FileBackend.php b/includes/libs/filebackend/FileBackend.php index 4ad48c70c1..4cacb7af63 100644 --- a/includes/libs/filebackend/FileBackend.php +++ b/includes/libs/filebackend/FileBackend.php @@ -27,6 +27,7 @@ * @file * @ingroup FileBackend */ +use MediaWiki\FileBackend\FSFile\TempFSFileFactory; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Wikimedia\ScopedCallback; @@ -106,8 +107,8 @@ abstract class FileBackend implements LoggerAwareInterface { /** @var int How many operations can be done in parallel */ protected $concurrency; - /** @var string Temporary file directory */ - protected $tmpDirectory; + /** @var TempFSFileFactory */ + protected $tmpFileFactory; /** @var LockManager */ protected $lockManager; @@ -152,8 +153,10 @@ abstract class FileBackend implements LoggerAwareInterface { * - parallelize : When to do file operations in parallel (when possible). * Allowed values are "implicit", "explicit" and "off". * - concurrency : How many file operations can be done in parallel. - * - tmpDirectory : Directory to use for temporary files. If this is not set or null, - * then the backend will try to discover a usable temporary directory. + * - tmpDirectory : Directory to use for temporary files. + * - tmpFileFactory : Optional TempFSFileFactory object. Only has an effect if tmpDirectory is + * not set. If both are unset or null, then the backend will try to discover a usable + * temporary directory. * - obResetFunc : alternative callback to clear the output buffer * - streamMimeFunc : alternative method to determine the content type from the path * - logger : Optional PSR logger object. @@ -193,7 +196,12 @@ abstract class FileBackend implements LoggerAwareInterface { } $this->logger = $config['logger'] ?? new NullLogger(); $this->statusWrapper = $config['statusWrapper'] ?? null; - $this->tmpDirectory = $config['tmpDirectory'] ?? null; + // tmpDirectory gets precedence for backward compatibility + if ( isset( $config['tmpDirectory'] ) ) { + $this->tmpFileFactory = new TempFSFileFactory( $config['tmpDirectory'] ); + } else { + $this->tmpFileFactory = $config['tmpFileFactory'] ?? new TempFSFileFactory(); + } } public function setLogger( LoggerInterface $logger ) { @@ -225,6 +233,7 @@ abstract class FileBackend implements LoggerAwareInterface { * Alias to getDomainId() * @return string * @since 1.20 + * @deprecated Since 1.34 Use getDomainId() */ final public function getWikiId() { return $this->getDomainId(); @@ -411,7 +420,7 @@ abstract class FileBackend implements LoggerAwareInterface { * * The StatusValue will be "OK" unless: * - a) unexpected operation errors occurred (network partitions, disk full...) - * - b) significant operation errors occurred and 'force' was not set + * - b) predicted operation errors occurred and 'force' was not set * * @param array $ops List of operations to execute in order * @param array $opts Batch operation options