From: Aaron Schulz Date: Tue, 20 Aug 2019 14:09:16 +0000 (-0400) Subject: filebackend: use AtEase in FileBackend related classes X-Git-Tag: 1.34.0-rc.0~618^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=d01d98012bf3534636b5b8f475d5af7ff920a00e;p=lhc%2Fweb%2Fwiklou.git filebackend: use AtEase in FileBackend related classes Change-Id: I819e0e923dfd3ffa7299acd1d6103e3cdf2baa93 --- diff --git a/includes/libs/filebackend/FileBackendStore.php b/includes/libs/filebackend/FileBackendStore.php index e2a25fcd51..aa95ee40bf 100644 --- a/includes/libs/filebackend/FileBackendStore.php +++ b/includes/libs/filebackend/FileBackendStore.php @@ -20,6 +20,7 @@ * @file * @ingroup FileBackend */ +use Wikimedia\AtEase\AtEase; use Wikimedia\Timestamp\ConvertibleTimestamp; /** @@ -376,9 +377,9 @@ abstract class FileBackendStore extends FileBackend { unset( $params['latest'] ); // sanity // Check that the specified temp file is valid... - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $ok = ( is_file( $tmpPath ) && filesize( $tmpPath ) == 0 ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( !$ok ) { // not present or not empty $status->fatal( 'backend-fail-opentemp', $tmpPath ); @@ -714,9 +715,9 @@ abstract class FileBackendStore extends FileBackend { protected function doGetFileContentsMulti( array $params ) { $contents = []; foreach ( $this->doGetLocalReferenceMulti( $params ) as $path => $fsFile ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $contents[$path] = $fsFile ? file_get_contents( $fsFile->getPath() ) : false; - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } return $contents; diff --git a/includes/libs/filebackend/HTTPFileStreamer.php b/includes/libs/filebackend/HTTPFileStreamer.php index 7a11aebf7e..653a102cc4 100644 --- a/includes/libs/filebackend/HTTPFileStreamer.php +++ b/includes/libs/filebackend/HTTPFileStreamer.php @@ -19,6 +19,8 @@ * * @file */ + +use Wikimedia\AtEase\AtEase; use Wikimedia\Timestamp\ConvertibleTimestamp; /** @@ -100,9 +102,9 @@ class HTTPFileStreamer { is_int( $header ) ? HttpStatus::header( $header ) : header( $header ); }; - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $info = stat( $this->path ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( !is_array( $info ) ) { if ( $sendErrors ) { diff --git a/includes/libs/filebackend/MemoryFileBackend.php b/includes/libs/filebackend/MemoryFileBackend.php index 3932f34505..f0cbf3bbcd 100644 --- a/includes/libs/filebackend/MemoryFileBackend.php +++ b/includes/libs/filebackend/MemoryFileBackend.php @@ -21,6 +21,8 @@ * @ingroup FileBackend */ +use Wikimedia\AtEase\AtEase; + /** * Simulation of a backend storage in memory. * @@ -70,9 +72,9 @@ class MemoryFileBackend extends FileBackendStore { return $status; } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $data = file_get_contents( $params['src'] ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $data === false ) { // source doesn't exist? $status->fatal( 'backend-fail-store', $params['src'], $params['dst'] ); diff --git a/includes/libs/filebackend/SwiftFileBackend.php b/includes/libs/filebackend/SwiftFileBackend.php index d6a0c6c0a3..afd1688c1c 100644 --- a/includes/libs/filebackend/SwiftFileBackend.php +++ b/includes/libs/filebackend/SwiftFileBackend.php @@ -22,6 +22,8 @@ * @author Russ Nelson */ +use Wikimedia\AtEase\AtEase; + /** * @brief Class for an OpenStack Swift (or Ceph RGW) based file backend. * @@ -326,9 +328,9 @@ class SwiftFileBackend extends FileBackendStore { return $status; } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $sha1Hash = sha1_file( $params['src'] ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $sha1Hash === false ) { // source doesn't exist? $status->fatal( 'backend-fail-store', $params['src'], $params['dst'] ); diff --git a/includes/libs/filebackend/fileop/FileOp.php b/includes/libs/filebackend/fileop/FileOp.php index 206048bd71..961fdb93b4 100644 --- a/includes/libs/filebackend/fileop/FileOp.php +++ b/includes/libs/filebackend/fileop/FileOp.php @@ -77,7 +77,7 @@ abstract class FileOp { * @param FileBackendStore $backend * @param array $params * @param LoggerInterface $logger PSR logger instance - * @throws FileBackendError + * @throws InvalidArgumentException */ final public function __construct( FileBackendStore $backend, array $params, LoggerInterface $logger diff --git a/includes/libs/filebackend/fileop/StoreFileOp.php b/includes/libs/filebackend/fileop/StoreFileOp.php index 69ae47f428..5783a822af 100644 --- a/includes/libs/filebackend/fileop/StoreFileOp.php +++ b/includes/libs/filebackend/fileop/StoreFileOp.php @@ -21,6 +21,8 @@ * @ingroup FileBackend */ +use Wikimedia\AtEase\AtEase; + /** * Store a file into the backend from a file on the file system. * Parameters for this operation are outlined in FileBackend::doOperations(). @@ -77,9 +79,9 @@ class StoreFileOp extends FileOp { } protected function getSourceSha1Base36() { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $hash = sha1_file( $this->params['src'] ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $hash !== false ) { $hash = Wikimedia\base_convert( $hash, 16, 36, 31 ); } diff --git a/includes/libs/filebackend/fsfile/FSFile.php b/includes/libs/filebackend/fsfile/FSFile.php index 553c9aaf17..1937e37441 100644 --- a/includes/libs/filebackend/fsfile/FSFile.php +++ b/includes/libs/filebackend/fsfile/FSFile.php @@ -21,6 +21,8 @@ * @ingroup FileBackend */ +use Wikimedia\AtEase\AtEase; + /** * Class representing a non-directory file on the file system * @@ -75,9 +77,9 @@ class FSFile { * @return string|bool TS_MW timestamp or false on failure */ public function getTimestamp() { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $timestamp = filemtime( $this->path ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $timestamp !== false ) { $timestamp = wfTimestamp( TS_MW, $timestamp ); } @@ -168,9 +170,9 @@ class FSFile { return $this->sha1Base36; } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $this->sha1Base36 = sha1_file( $this->path ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $this->sha1Base36 !== false ) { $this->sha1Base36 = Wikimedia\base_convert( $this->sha1Base36, 16, 36, 31 ); diff --git a/includes/libs/filebackend/fsfile/TempFSFile.php b/includes/libs/filebackend/fsfile/TempFSFile.php index 378dbe7268..46fa5e1333 100644 --- a/includes/libs/filebackend/fsfile/TempFSFile.php +++ b/includes/libs/filebackend/fsfile/TempFSFile.php @@ -24,6 +24,8 @@ use MediaWiki\FileBackend\FSFile\TempFSFileFactory; * @ingroup FileBackend */ +use Wikimedia\AtEase\AtEase; + /** * This class is used to hold the location and do limited manipulation * of files stored temporarily (this will be whatever wfTempDir() returns) @@ -38,7 +40,9 @@ class TempFSFile extends FSFile { protected static $pathsCollect = null; /** - * Do not call directly. Use TempFSFileFactory. + * Do not call directly. Use TempFSFileFactory + * + * @param string $path */ public function __construct( $path ) { parent::__construct( $path ); @@ -110,9 +114,9 @@ class TempFSFile extends FSFile { */ public function purge() { $this->canDelete = false; // done - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $ok = unlink( $this->path ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); unset( self::$pathsCollect[$this->path] ); @@ -172,9 +176,9 @@ class TempFSFile extends FSFile { */ public static function purgeAllOnShutdown() { foreach ( self::$pathsCollect as $path => $unused ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); unlink( $path ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } }