diff options
author | Reedy <reedy@wikimedia.org> | 2022-02-24 20:17:53 +0000 |
---|---|---|
committer | Reedy <reedy@wikimedia.org> | 2022-02-24 20:27:46 +0000 |
commit | 86934b2fa880ef09b60ea9703ed053c16187e7be (patch) | |
tree | 383a0122b1070ca514bfe64a89bbe0f7f54cd208 | |
parent | 99e1b7312efd7ec17b7344d3888bbc3398a42bca (diff) | |
download | mediawikicore-86934b2fa880ef09b60ea9703ed053c16187e7be.tar.gz mediawikicore-86934b2fa880ef09b60ea9703ed053c16187e7be.zip |
Replace some more usages of Wikimedia\(suppress|restore)Warnings()
Change-Id: I2eb133a9e32116cd155f59086245bc4d15ecbfcc
43 files changed, 175 insertions, 121 deletions
diff --git a/includes/GitInfo.php b/includes/GitInfo.php index 5cc8ce496d22..410f6e68d2b2 100644 --- a/includes/GitInfo.php +++ b/includes/GitInfo.php @@ -318,9 +318,9 @@ class GitInfo { $config = "{$this->basedir}/config"; $url = false; if ( is_readable( $config ) ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $configArray = parse_ini_file( $config, true ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); $remote = false; // Use the "origin" remote repo if available or any other repo if not. diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 9bb795618caf..9c6b1929d0fe 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2359,14 +2359,14 @@ function wfMemoryLimit( $newLimit ) { $newLimit = wfShorthandToInteger( $newLimit ); if ( $newLimit == -1 ) { wfDebug( "Removing PHP's memory limit" ); - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); ini_set( 'memory_limit', $newLimit ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } elseif ( $newLimit > $oldLimit ) { wfDebug( "Raising PHP's memory limit to $newLimit bytes" ); - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); ini_set( 'memory_limit', $newLimit ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } } } @@ -2483,9 +2483,9 @@ function wfUnpack( $format, $data, $length = false ) { } } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $result = unpack( $format, $data ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $result === false ) { // If it cannot extract the packed data. diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index fe7f4e87c8a4..9e6311dc15ee 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -26,6 +26,7 @@ use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use MediaWiki\Permissions\PermissionStatus; use Psr\Log\LoggerInterface; +use Wikimedia\AtEase\AtEase; use Wikimedia\Rdbms\ChronologyProtector; use Wikimedia\Rdbms\DBConnectionError; use Wikimedia\ScopedCallback; @@ -1226,7 +1227,7 @@ class MediaWiki { $port = $info['port']; } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $sock = $host ? fsockopen( $host, $port, @@ -1235,7 +1236,7 @@ class MediaWiki { // If it takes more than 100ms to connect to ourselves there is a problem... 0.100 ) : false; - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); $invokedWithSuccess = true; if ( $sock ) { diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 06798df6f168..293398f99e26 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -29,6 +29,7 @@ use MediaWiki\Page\PageReference; use MediaWiki\Permissions\PermissionStatus; use MediaWiki\Session\SessionManager; use MediaWiki\Tidy\RemexDriver; +use Wikimedia\AtEase\AtEase; use Wikimedia\Rdbms\IResultWrapper; use Wikimedia\RelPath; use Wikimedia\WrappedString; @@ -802,9 +803,10 @@ class OutputPage extends ContextSource { # this breaks strtotime(). $clientHeader = preg_replace( '/;.*$/', '', $clientHeader ); - Wikimedia\suppressWarnings(); // E_STRICT system time warnings + // E_STRICT system time warnings + AtEase::suppressWarnings(); $clientHeaderTime = strtotime( $clientHeader ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( !$clientHeaderTime ) { wfDebug( __METHOD__ . ": unable to parse the client's If-Modified-Since header: $clientHeader" ); diff --git a/includes/Setup.php b/includes/Setup.php index 223ae448a5d7..22e1a6f57c9c 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -58,6 +58,7 @@ use MediaWiki\Settings\Config\PhpIniSink; use MediaWiki\Settings\SettingsBuilder; use MediaWiki\Settings\Source\PhpSettingsSource; use Psr\Log\LoggerInterface; +use Wikimedia\AtEase\AtEase; use Wikimedia\RequestTimeout\RequestTimeout; /** @@ -606,9 +607,9 @@ if ( isset( $wgSlaveLagCritical ) ) { } if ( $wgInvalidateCacheOnLocalSettingsChange && defined( 'MW_CONFIG_FILE' ) ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', filemtime( MW_CONFIG_FILE ) ) ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } if ( $wgNewUserLog ) { diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 9cad463e7672..327434a686ce 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -28,6 +28,7 @@ use MediaWiki\ParamValidator\TypeDef\UserDef; use MediaWiki\Rest\HeaderParser\Origin; use MediaWiki\Session\SessionManager; use MediaWiki\User\UserFactory; +use Wikimedia\AtEase\AtEase; use Wikimedia\Timestamp\TimestampException; /** @@ -1678,9 +1679,9 @@ class ApiMain extends ApiBase { $this->getRequest()->response()->statusHeader( 304 ); // Avoid outputting the compressed representation of a zero-length body - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); ini_set( 'zlib.output_compression', 0 ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); wfResetOutputBuffers( false ); return false; diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php index 7669f0b97284..352c8e4fe2ac 100644 --- a/includes/cache/FileCacheBase.php +++ b/includes/cache/FileCacheBase.php @@ -22,6 +22,7 @@ */ use MediaWiki\MediaWikiServices; +use Wikimedia\AtEase\AtEase; use Wikimedia\IPUtils; /** @@ -182,9 +183,9 @@ abstract class FileCacheBase { * @return void */ public function clearCache() { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); unlink( $this->cachePath() ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); $this->mCached = false; } diff --git a/includes/cache/dependency/FileDependency.php b/includes/cache/dependency/FileDependency.php index 1000fb40d543..1cc2379ff668 100644 --- a/includes/cache/dependency/FileDependency.php +++ b/includes/cache/dependency/FileDependency.php @@ -21,6 +21,8 @@ * @ingroup Cache */ +use Wikimedia\AtEase\AtEase; + /** * @newable * @ingroup Cache @@ -59,11 +61,11 @@ class FileDependency extends CacheDependency { public function loadDependencyValues() { if ( $this->timestamp === null ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); # Dependency on a non-existent file stores "false" # This is a valid concept! $this->timestamp = filemtime( $this->filename ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } } @@ -71,9 +73,9 @@ class FileDependency extends CacheDependency { * @return bool */ public function isExpired() { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $lastmod = filemtime( $this->filename ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $lastmod === false ) { if ( $this->timestamp === false ) { # Still nonexistent diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index b1b74fe7420b..3177af4148f9 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -31,6 +31,7 @@ use MediaWiki\Storage\EditResult; use MediaWiki\User\UserIdentity; use MediaWiki\User\UserIdentityValue; use Wikimedia\Assert\Assert; +use Wikimedia\AtEase\AtEase; use Wikimedia\IPUtils; /** @@ -1289,9 +1290,9 @@ class RecentChange implements Taggable { public function parseParams() { $rcParams = $this->getAttribute( 'rc_params' ); - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $unserializedParams = unserialize( $rcParams ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return $unserializedParams; } diff --git a/includes/debug/logger/LegacyLogger.php b/includes/debug/logger/LegacyLogger.php index b38ab9a7f4ec..232e1af4b6bc 100644 --- a/includes/debug/logger/LegacyLogger.php +++ b/includes/debug/logger/LegacyLogger.php @@ -30,6 +30,7 @@ use RuntimeException; use Throwable; use UDPTransport; use WikiMap; +use Wikimedia\AtEase\AtEase; /** * PSR-3 logger that mimics the historic implementation of MediaWiki's former @@ -514,7 +515,7 @@ class LegacyLogger extends AbstractLogger { $transport = UDPTransport::newFromString( $file ); $transport->emit( $text ); } else { - \Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $exists = file_exists( $file ); $size = $exists ? filesize( $file ) : false; if ( !$exists || @@ -522,7 +523,7 @@ class LegacyLogger extends AbstractLogger { ) { file_put_contents( $file, $text, FILE_APPEND ); } - \Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } } diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index cd9e74484368..62f8e2876fec 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -12,6 +12,7 @@ use MediaWiki\MediaWikiServices; use MediaWiki\Page\PageIdentity; use MediaWiki\Permissions\Authority; use MediaWiki\User\UserIdentity; +use Wikimedia\AtEase\AtEase; /** * Base code for file repositories. @@ -1376,9 +1377,9 @@ class FileRepo { } // Cleanup for disk source files... foreach ( $sourceFSFilesToDelete as $file ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); unlink( $file ); // FS cleanup - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } return $status; diff --git a/includes/historyblob/DiffHistoryBlob.php b/includes/historyblob/DiffHistoryBlob.php index 7741d2b083be..b31b1d5c5408 100644 --- a/includes/historyblob/DiffHistoryBlob.php +++ b/includes/historyblob/DiffHistoryBlob.php @@ -20,6 +20,8 @@ * @file */ +use Wikimedia\AtEase\AtEase; + /** * Diff-based history compression * Requires xdiff 1.5+ and zlib @@ -195,9 +197,9 @@ class DiffHistoryBlob implements HistoryBlob { private function diff( $t1, $t2 ) { # Need to do a null concatenation with warnings off, due to bugs in the current version of xdiff # "String is not zero-terminated" - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $diff = xdiff_string_rabdiff( $t1, $t2 ) . ''; - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return $diff; } @@ -208,9 +210,9 @@ class DiffHistoryBlob implements HistoryBlob { */ private function patch( $base, $diff ) { if ( function_exists( 'xdiff_string_bpatch' ) ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $text = xdiff_string_bpatch( $base, $diff ) . ''; - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return $text; } diff --git a/includes/import/ImportStreamSource.php b/includes/import/ImportStreamSource.php index ec05f2709998..168acb00b893 100644 --- a/includes/import/ImportStreamSource.php +++ b/includes/import/ImportStreamSource.php @@ -25,6 +25,7 @@ */ use MediaWiki\MediaWikiServices; +use Wikimedia\AtEase\AtEase; /** * Imports a XML dump from a file (either from file upload, files on disk, or HTTP) @@ -60,9 +61,9 @@ class ImportStreamSource implements ImportSource { * @return Status */ public static function newFromFile( $filename ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $file = fopen( $filename, 'rt' ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( !$file ) { return Status::newFatal( "importcantopen" ); } diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index 1ba9f5fc62ce..216300edad3c 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -21,6 +21,7 @@ * @ingroup Installer */ +use Wikimedia\AtEase\AtEase; use Wikimedia\Rdbms\Database; use Wikimedia\Rdbms\DBConnectionError; use Wikimedia\Rdbms\DBExpectedError; @@ -787,10 +788,10 @@ abstract class DatabaseInstaller { return $status; } global $IP; - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $rows = file( "$IP/maintenance/interwiki.list", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); $interwikis = []; if ( !$rows ) { return Status::newFatal( 'config-install-interwiki-list' ); diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 72ecf58cd198..a2ecd7d62244 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -29,6 +29,7 @@ use MediaWiki\HookContainer\StaticHookRegistry; use MediaWiki\Interwiki\NullInterwikiLookup; use MediaWiki\MediaWikiServices; use MediaWiki\Settings\SettingsBuilder; +use Wikimedia\AtEase\AtEase; /** * The Installer helps admins create or upgrade their wiki. @@ -652,10 +653,10 @@ abstract class Installer { // phpcs:ignore MediaWiki.VariableAnalysis.UnusedGlobalVariables global $wgExtensionDirectory, $wgStyleDirectory; - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); wfDetectLocalSettingsFile( $IP ); // defines MW_CONFIG_FILE $_lsExists = file_exists( MW_CONFIG_FILE ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( !$_lsExists ) { return false; @@ -867,14 +868,14 @@ abstract class Installer { * @return bool */ protected function envCheckPCRE() { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' ); // Need to check for \p support too, as PCRE can be compiled // with utf8 support, but not unicode property support. // check that \p{Zs} (space separators) matches // U+3000 (Ideographic space) $regexprop = preg_replace( '/\p{Zs}/u', '', "-\u{3000}-" ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $regexd != '--' || $regexprop != '--' ) { $this->showError( 'config-pcre-no-utf8' ); @@ -1154,7 +1155,7 @@ abstract class Installer { $httpRequestFactory = MediaWikiServices::getInstance()->getHttpRequestFactory(); - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); foreach ( $scriptTypes as $ext => $contents ) { foreach ( $contents as $source ) { @@ -1178,14 +1179,14 @@ abstract class Installer { unlink( $dir . $file ); if ( $text == 'exec' ) { - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return $ext; } } } - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return false; } @@ -1935,8 +1936,8 @@ abstract class Installer { * Some long-running pages (Install, Upgrade) will want to do this */ protected function disableTimeLimit() { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); set_time_limit( 0 ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } } diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php index 151e4e1b9eba..256fc70a4171 100644 --- a/includes/installer/SqliteInstaller.php +++ b/includes/installer/SqliteInstaller.php @@ -21,6 +21,7 @@ * @ingroup Installer */ +use Wikimedia\AtEase\AtEase; use Wikimedia\Rdbms\Database; use Wikimedia\Rdbms\DatabaseSqlite; use Wikimedia\Rdbms\DBConnectionError; @@ -173,9 +174,9 @@ class SqliteInstaller extends DatabaseInstaller { */ private static function createDataDir( $dir ): Status { if ( !is_dir( $dir ) ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $ok = wfMkdirParents( $dir, 0700, __METHOD__ ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( !$ok ) { return Status::newFatal( 'config-sqlite-mkdir-error', $dir ); } diff --git a/includes/language/Language.php b/includes/language/Language.php index fbf6093f3d9e..1e9d3824e76c 100644 --- a/includes/language/Language.php +++ b/includes/language/Language.php @@ -32,6 +32,7 @@ use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use MediaWiki\User\UserIdentity; use Wikimedia\Assert\Assert; +use Wikimedia\AtEase\AtEase; use Wikimedia\RequestTimeout\TimeoutException; /** @@ -2116,7 +2117,8 @@ class Language { return $ts; } - Wikimedia\suppressWarnings(); // E_STRICT system time bitching + // E_STRICT system time bitching + AtEase::suppressWarnings(); # Generate an adjusted date; take advantage of the fact that mktime # will normalize out-of-range values so we don't have to split $minDiff # into hours and minutes. @@ -2129,7 +2131,7 @@ class Language { (int)substr( $ts, 0, 4 ) ); # Year $date = date( 'YmdHis', $t ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return $date; } @@ -2623,9 +2625,9 @@ class Language { # *input* string. We just ignore those too. # REF: https://bugs.php.net/bug.php?id=37166 # REF: https://phabricator.wikimedia.org/T18885 - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $text = iconv( $in, $out . '//IGNORE', $string ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return $text; } diff --git a/includes/libs/Deflate.php b/includes/libs/Deflate.php index 333091e23039..e54864b4a388 100644 --- a/includes/libs/Deflate.php +++ b/includes/libs/Deflate.php @@ -16,6 +16,8 @@ * */ +use Wikimedia\AtEase\AtEase; + /** * Server-side helper for client-side compressed content. * @@ -60,9 +62,9 @@ class Deflate { if ( $deflated === false ) { return StatusValue::newFatal( 'deflate-invaliddeflate' ); } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $inflated = gzinflate( $deflated ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $inflated === false ) { return StatusValue::newFatal( 'deflate-invaliddeflate' ); } diff --git a/includes/libs/filebackend/fsfile/TempFSFileFactory.php b/includes/libs/filebackend/fsfile/TempFSFileFactory.php index 1120973803ee..10def1a0aadb 100644 --- a/includes/libs/filebackend/fsfile/TempFSFileFactory.php +++ b/includes/libs/filebackend/fsfile/TempFSFileFactory.php @@ -3,6 +3,7 @@ namespace MediaWiki\FileBackend\FSFile; use TempFSFile; +use Wikimedia\AtEase\AtEase; /** * @ingroup FileBackend @@ -38,9 +39,9 @@ class TempFSFileFactory { while ( $attempts-- ) { $hex = sprintf( '%06x%06x', mt_rand( 0, 0xffffff ), mt_rand( 0, 0xffffff ) ); $path = "$tmpDirectory/$prefix$hex$ext"; - \Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $newFileHandle = fopen( $path, 'x' ); - \Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $newFileHandle ) { fclose( $newFileHandle ); $tmpFile = new TempFSFile( $path ); diff --git a/includes/libs/lockmanager/FSLockManager.php b/includes/libs/lockmanager/FSLockManager.php index c94fa55cc8b5..8cec36de0f1e 100644 --- a/includes/libs/lockmanager/FSLockManager.php +++ b/includes/libs/lockmanager/FSLockManager.php @@ -21,6 +21,8 @@ * @ingroup LockManager */ +use Wikimedia\AtEase\AtEase; + /** * Simple version of LockManager based on using FS lock files. * All locks are non-blocking, which avoids deadlocks. @@ -122,7 +124,7 @@ class FSLockManager extends LockManager { if ( isset( $this->handles[$path] ) ) { $handle = $this->handles[$path]; } else { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $handle = fopen( $this->getLockPath( $path ), 'a+' ); if ( !$handle && !is_dir( $this->lockDir ) ) { // Create the lock directory in case it is missing @@ -132,7 +134,7 @@ class FSLockManager extends LockManager { $this->logger->error( "Cannot create directory '{$this->lockDir}'." ); } } - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } if ( $handle ) { // Either a shared or exclusive lock diff --git a/includes/libs/mime/MSCompoundFileReader.php b/includes/libs/mime/MSCompoundFileReader.php index 7a5a900ae2db..121994a2152a 100644 --- a/includes/libs/mime/MSCompoundFileReader.php +++ b/includes/libs/mime/MSCompoundFileReader.php @@ -14,6 +14,8 @@ * specific language governing permissions and limitations under the License. */ +use Wikimedia\AtEase\AtEase; + /** * Read the directory of a Microsoft Compound File Binary file, a.k.a. an OLE * file, and detect the MIME type. @@ -216,9 +218,9 @@ class MSCompoundFileReader { private function readOffset( $offset, $length ) { $this->fseek( $offset ); - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $block = fread( $this->file, $length ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $block === false ) { $this->error( 'error reading from file', self::ERROR_READ ); } @@ -243,9 +245,9 @@ class MSCompoundFileReader { } private function fseek( $offset ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $result = fseek( $this->file, $offset ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $result !== 0 ) { $this->error( "unable to seek to offset $offset", self::ERROR_SEEK ); } diff --git a/includes/libs/mime/MimeAnalyzer.php b/includes/libs/mime/MimeAnalyzer.php index dfe331c22507..9b994c0e01ef 100644 --- a/includes/libs/mime/MimeAnalyzer.php +++ b/includes/libs/mime/MimeAnalyzer.php @@ -22,6 +22,7 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; +use Wikimedia\AtEase\AtEase; use Wikimedia\Mime\MimeMap; use Wikimedia\Mime\MimeMapMinimal; @@ -545,9 +546,9 @@ class MimeAnalyzer implements LoggerAwareInterface { */ private function doGuessMimeType( string $file, $ext ) { // Read a chunk of the file - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $f = fopen( $file, 'rb' ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( !$f ) { return 'unknown/unknown'; @@ -681,9 +682,9 @@ class MimeAnalyzer implements LoggerAwareInterface { /** * look for XML formats (XHTML and SVG) */ - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $xml = new XmlTypeCheck( $file ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $xml->wellFormed ) { $xmlTypes = $this->xmlTypes; return $xmlTypes[$xml->getRootElement()] ?? 'application/xml'; @@ -759,9 +760,9 @@ class MimeAnalyzer implements LoggerAwareInterface { } } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $gis = getimagesize( $file ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $gis && isset( $gis['mime'] ) ) { $mime = $gis['mime']; diff --git a/includes/libs/objectcache/utils/MemcachedClient.php b/includes/libs/objectcache/utils/MemcachedClient.php index 0edafe0308e6..345104bc15d8 100644 --- a/includes/libs/objectcache/utils/MemcachedClient.php +++ b/includes/libs/objectcache/utils/MemcachedClient.php @@ -68,6 +68,7 @@ use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; +use Wikimedia\AtEase\AtEase; use Wikimedia\IPUtils; // {{{ class MemcachedClient @@ -800,13 +801,13 @@ class MemcachedClient { $timeout = $this->_connect_timeout; $errno = $errstr = null; for ( $i = 0; !$sock && $i < $this->_connect_attempts; $i++ ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); if ( $this->_persistent == 1 ) { $sock = pfsockopen( $ip, $port, $errno, $errstr, $timeout ); } else { $sock = fsockopen( $ip, $port, $errno, $errstr, $timeout ); } - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } if ( !$sock ) { $this->_error_log( "Error connecting to $host: $errstr" ); diff --git a/includes/logging/DatabaseLogEntry.php b/includes/logging/DatabaseLogEntry.php index 5f366e71893a..41e75d2f40a2 100644 --- a/includes/logging/DatabaseLogEntry.php +++ b/includes/logging/DatabaseLogEntry.php @@ -26,6 +26,7 @@ use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use MediaWiki\User\UserIdentity; +use Wikimedia\AtEase\AtEase; use Wikimedia\Rdbms\IDatabase; /** @@ -181,9 +182,9 @@ class DatabaseLogEntry extends LogEntryBase { public function getParameters() { if ( !isset( $this->params ) ) { $blob = $this->getRawParameters(); - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $params = LogEntryBase::extractParams( $blob ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $params !== false ) { $this->params = $params; $this->legacy = false; diff --git a/includes/mail/UserMailer.php b/includes/mail/UserMailer.php index 555d1e2c2e06..85bb69c3e04f 100644 --- a/includes/mail/UserMailer.php +++ b/includes/mail/UserMailer.php @@ -26,6 +26,7 @@ */ use MediaWiki\MediaWikiServices; +use Wikimedia\AtEase\AtEase; /** * Collection of static functions for sending mail @@ -390,13 +391,13 @@ class UserMailer { $recips = array_map( 'strval', $to ); - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); // Create the mail object using the Mail::factory method $mail_object = Mail::factory( 'smtp', $smtp ); if ( PEAR::isError( $mail_object ) ) { wfDebug( "PEAR::Mail factory failed: " . $mail_object->getMessage() ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return Status::newFatal( 'pear-mail-error', $mail_object->getMessage() ); } '@phan-var Mail_smtp $mail_object'; @@ -417,11 +418,11 @@ class UserMailer { $status = self::sendWithPear( $mail_object, $chunk, $headers, $body ); // FIXME : some chunks might be sent while others are not! if ( !$status->isOK() ) { - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return $status; } } - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return Status::newGood(); } else { // PHP mail() diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php index de842fba3e7a..fe086b8c19aa 100644 --- a/includes/media/DjVuImage.php +++ b/includes/media/DjVuImage.php @@ -26,6 +26,7 @@ use MediaWiki\MediaWikiServices; use MediaWiki\Shell\Shell; +use Wikimedia\AtEase\AtEase; /** * Support for detecting/validating DjVu image files and getting @@ -123,9 +124,9 @@ class DjVuImage { } private function getInfo() { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $file = fopen( $this->mFilename, 'rb' ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $file === false ) { wfDebug( __METHOD__ . ": missing or failed file read" ); diff --git a/includes/media/Exif.php b/includes/media/Exif.php index c2d80c48831b..29c8d595401a 100644 --- a/includes/media/Exif.php +++ b/includes/media/Exif.php @@ -25,6 +25,8 @@ * @file */ +use Wikimedia\AtEase\AtEase; + /** * Class to extract and validate Exif data from jpeg (and possibly tiff) files. * @ingroup Media @@ -292,9 +294,9 @@ class Exif { $this->debugFile( __FUNCTION__, true ); if ( function_exists( 'exif_read_data' ) ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $data = exif_read_data( $this->file, 0, true ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } else { throw new MWException( "Internal error: exif_read_data not present. " . "\$wgShowEXIF may be incorrectly set or not checked by an extension." ); @@ -474,17 +476,17 @@ class Exif { break; } if ( $charset ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $val = iconv( $charset, 'UTF-8//IGNORE', $val ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } else { // if valid utf-8, assume that, otherwise assume windows-1252 $valCopy = $val; UtfNormal\Validator::quickIsNFCVerify( $valCopy ); // validates $valCopy. if ( $valCopy !== $val ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $val = iconv( 'Windows-1252', 'UTF-8//IGNORE', $val ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } } diff --git a/includes/media/GIFMetadataExtractor.php b/includes/media/GIFMetadataExtractor.php index 24f3734443c6..ed9852bab017 100644 --- a/includes/media/GIFMetadataExtractor.php +++ b/includes/media/GIFMetadataExtractor.php @@ -26,6 +26,8 @@ * @ingroup Media */ +use Wikimedia\AtEase\AtEase; + /** * GIF frame counter. * @@ -172,9 +174,9 @@ class GIFMetadataExtractor { UtfNormal\Validator::quickIsNFCVerify( $dataCopy ); if ( $dataCopy !== $data ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $data = iconv( 'windows-1252', 'UTF-8', $data ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } $commentCount = count( $comment ); diff --git a/includes/media/IPTC.php b/includes/media/IPTC.php index db711dd1bb0d..fd0db3769fad 100644 --- a/includes/media/IPTC.php +++ b/includes/media/IPTC.php @@ -21,6 +21,8 @@ * @ingroup Media */ +use Wikimedia\AtEase\AtEase; + /** * Class for some IPTC functions. * @@ -429,9 +431,9 @@ class IPTC { */ private static function convIPTCHelper( $data, $charset ) { if ( $charset ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $data = iconv( $charset, "UTF-8//IGNORE", $data ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $data === false ) { $data = ""; wfDebugLog( 'iptc', __METHOD__ . " Error converting iptc data charset $charset to utf-8" ); diff --git a/includes/media/ImageHandler.php b/includes/media/ImageHandler.php index e9088d463d4f..0ff7157439ab 100644 --- a/includes/media/ImageHandler.php +++ b/includes/media/ImageHandler.php @@ -21,6 +21,8 @@ * @ingroup Media */ +use Wikimedia\AtEase\AtEase; + /** * Media handler abstract base class for images * @@ -221,9 +223,9 @@ abstract class ImageHandler extends MediaHandler { } public function getImageSize( $image, $path ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $gis = getimagesize( $path ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); return $gis; } diff --git a/includes/media/JpegMetadataExtractor.php b/includes/media/JpegMetadataExtractor.php index 86e87f1b15f5..5d4e020084db 100644 --- a/includes/media/JpegMetadataExtractor.php +++ b/includes/media/JpegMetadataExtractor.php @@ -21,6 +21,7 @@ * @ingroup Media */ +use Wikimedia\AtEase\AtEase; use Wikimedia\XMPReader\Reader as XMPReader; /** @@ -103,9 +104,9 @@ class JpegMetadataExtractor { // turns $com to valid utf-8. // thus if no change, its utf-8, otherwise its something else. if ( $com !== $oldCom ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $com = $oldCom = iconv( 'windows-1252', 'UTF-8//IGNORE', $oldCom ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } // Try it again, if its still not a valid string, then probably // binary junk or some really weird encoding, so don't extract. diff --git a/includes/media/PNGMetadataExtractor.php b/includes/media/PNGMetadataExtractor.php index d18a05a37179..5efee62e8d87 100644 --- a/includes/media/PNGMetadataExtractor.php +++ b/includes/media/PNGMetadataExtractor.php @@ -25,6 +25,8 @@ * @ingroup Media */ +use Wikimedia\AtEase\AtEase; + /** * PNG frame counter. * @@ -201,9 +203,9 @@ class PNGMetadataExtractor { // if compressed if ( $items[2] == "\x01" ) { if ( function_exists( 'gzuncompress' ) && $items[4] === "\x00" ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $items[5] = gzuncompress( $items[5] ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $items[5] === false ) { // decompression failed @@ -242,9 +244,9 @@ class PNGMetadataExtractor { // Don't recognize chunk, so skip. continue; } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $content = iconv( 'ISO-8859-1', 'UTF-8', $content ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $content === false ) { wfDebug( __METHOD__ . ": Read error (error with iconv)" ); @@ -281,9 +283,9 @@ class PNGMetadataExtractor { continue; } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $content = gzuncompress( $content ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $content === false ) { // decompression failed @@ -291,9 +293,9 @@ class PNGMetadataExtractor { continue; } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $content = iconv( 'ISO-8859-1', 'UTF-8', $content ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $content === false ) { wfDebug( __METHOD__ . ": iconv error in zTXt chunk" ); diff --git a/includes/media/SVGReader.php b/includes/media/SVGReader.php index 883f7b6d0db4..e5bfef1ed88c 100644 --- a/includes/media/SVGReader.php +++ b/includes/media/SVGReader.php @@ -27,6 +27,7 @@ */ use MediaWiki\MediaWikiServices; +use Wikimedia\AtEase\AtEase; /** * @ingroup Media @@ -99,7 +100,7 @@ class SVGReader { // Because we cut off the end of the svg making an invalid one. Complicated // try catch thing to make sure warnings get restored. Seems like there should // be a better way. - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); try { $this->read(); } catch ( Exception $e ) { @@ -108,7 +109,7 @@ class SVGReader { throw $e; } finally { libxml_disable_entity_loader( $oldDisable ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } } diff --git a/includes/media/SvgHandler.php b/includes/media/SvgHandler.php index 935080375d30..b621fd7e64eb 100644 --- a/includes/media/SvgHandler.php +++ b/includes/media/SvgHandler.php @@ -23,6 +23,7 @@ use MediaWiki\MediaWikiServices; use MediaWiki\Shell\Shell; +use Wikimedia\AtEase\AtEase; use Wikimedia\RequestTimeout\TimeoutException; use Wikimedia\ScopedCallback; @@ -277,10 +278,10 @@ class SvgHandler extends ImageHandler { $ok = symlink( $srcPath, $lnPath ); /** @noinspection PhpUnusedLocalVariableInspection */ $cleaner = new ScopedCallback( static function () use ( $tmpDir, $lnPath ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); unlink( $lnPath ); rmdir( $tmpDir ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } ); if ( !$ok ) { wfDebugLog( 'thumbnail', diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index af646fd79171..cfb6eb4820c9 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -25,6 +25,7 @@ */ use MediaWiki\MediaWikiServices; +use Wikimedia\AtEase\AtEase; /** * Search engine hook for MySQL @@ -58,9 +59,9 @@ class SearchMySQL extends SearchDatabase { $contLang = $services->getContentLanguage(); $langConverter = $services->getLanguageConverterFactory()->getLanguageConverter( $contLang ); foreach ( $m as $bits ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits; - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $nonQuoted != '' ) { $term = $nonQuoted; diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index 3523ffc28674..edcba3b9be4d 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -22,6 +22,7 @@ */ use MediaWiki\MediaWikiServices; +use Wikimedia\AtEase\AtEase; /** * Search engine hook for SQLite @@ -61,9 +62,9 @@ class SearchSqlite extends SearchDatabase { if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { foreach ( $m as $bits ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits; - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $nonQuoted != '' ) { $term = $nonQuoted; diff --git a/includes/session/PHPSessionHandler.php b/includes/session/PHPSessionHandler.php index c30713f7f1ed..ca24d5081443 100644 --- a/includes/session/PHPSessionHandler.php +++ b/includes/session/PHPSessionHandler.php @@ -26,6 +26,7 @@ namespace MediaWiki\Session; use BagOStuff; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; +use Wikimedia\AtEase\AtEase; /** * Adapter for PHP's session handling @@ -126,7 +127,7 @@ class PHPSessionHandler implements \SessionHandlerInterface { session_write_close(); try { - \Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); // Tell PHP not to mess with cookies itself ini_set( 'session.use_cookies', 0 ); @@ -145,7 +146,7 @@ class PHPSessionHandler implements \SessionHandlerInterface { // shutdown function. session_set_save_handler( self::$instance, true ); } finally { - \Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } } diff --git a/includes/sparql/SparqlClient.php b/includes/sparql/SparqlClient.php index 8cc9fee9e05d..b262ce3af1af 100644 --- a/includes/sparql/SparqlClient.php +++ b/includes/sparql/SparqlClient.php @@ -21,6 +21,7 @@ namespace MediaWiki\Sparql; use MediaWiki\Http\HttpRequestFactory; +use Wikimedia\AtEase\AtEase; /** * Simple SPARQL client @@ -169,9 +170,9 @@ class SparqlClient { throw new SparqlException( 'HTTP error: ' . $status->getWikiText( false, false, 'en' ) ); } $result = $request->getContent(); - \Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $data = json_decode( $result, true ); - \Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $data === null || $data === false ) { throw new SparqlException( "HTTP request failed, response:\n" . substr( $result, 1024 ) ); diff --git a/includes/specials/SpecialLockdb.php b/includes/specials/SpecialLockdb.php index d846fd79d527..c73b2d5d92cb 100644 --- a/includes/specials/SpecialLockdb.php +++ b/includes/specials/SpecialLockdb.php @@ -21,6 +21,8 @@ * @ingroup SpecialPage */ +use Wikimedia\AtEase\AtEase; + /** * A form to make the database readonly (eg for maintenance purposes). * @@ -76,9 +78,9 @@ class SpecialLockdb extends FormSpecialPage { return Status::newFatal( 'locknoconfirm' ); } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $fp = fopen( $this->getConfig()->get( 'ReadOnlyFile' ), 'w' ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $fp === false ) { # This used to show a file not found error, but the likeliest reason for fopen() diff --git a/includes/specials/SpecialUnlockdb.php b/includes/specials/SpecialUnlockdb.php index 3135653c8da7..00e0dff9b598 100644 --- a/includes/specials/SpecialUnlockdb.php +++ b/includes/specials/SpecialUnlockdb.php @@ -21,6 +21,8 @@ * @ingroup SpecialPage */ +use Wikimedia\AtEase\AtEase; + /** * Implements Special:Unlockdb * @@ -69,9 +71,9 @@ class SpecialUnlockdb extends FormSpecialPage { } $readOnlyFile = $this->getConfig()->get( 'ReadOnlyFile' ); - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $res = unlink( $readOnlyFile ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $res ) { return Status::newGood(); diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 4f574063d1c4..fbf082f1a4a1 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -27,6 +27,7 @@ use MediaWiki\Permissions\Authority; use MediaWiki\Permissions\PermissionStatus; use MediaWiki\Shell\Shell; use MediaWiki\User\UserIdentity; +use Wikimedia\AtEase\AtEase; /** * @defgroup Upload Upload related @@ -1466,9 +1467,9 @@ abstract class UploadBase { // detect the encoding in case is specifies an encoding not whitelisted in self::$safeXmlEncodings $attemptEncodings = [ 'UTF-16', 'UTF-16BE', 'UTF-32', 'UTF-32BE' ]; foreach ( $attemptEncodings as $encoding ) { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $str = iconv( $encoding, 'UTF-8', $contents ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $str != '' && preg_match( "!<\?xml\b(.*?)\?>!si", $str, $matches ) ) { if ( preg_match( $encodingRegex, $matches[1], $encMatch ) && !in_array( strtoupper( $encMatch[1] ), self::$safeXmlEncodings ) diff --git a/includes/utils/ExecutableFinder.php b/includes/utils/ExecutableFinder.php index 44fb9ccd04b9..578692f1c898 100644 --- a/includes/utils/ExecutableFinder.php +++ b/includes/utils/ExecutableFinder.php @@ -19,6 +19,7 @@ */ use MediaWiki\Shell\Shell; +use Wikimedia\AtEase\AtEase; /** * Utility class to find executables in likely places @@ -62,9 +63,9 @@ class ExecutableFinder { protected static function findExecutable( $path, $name, $versionInfo = false ) { $command = $path . DIRECTORY_SEPARATOR . $name; - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $file_exists = is_executable( $command ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $file_exists ) { if ( !$versionInfo ) { diff --git a/maintenance/includes/TextPassDumper.php b/maintenance/includes/TextPassDumper.php index d473b54b5ab6..ee1ce3df5134 100644 --- a/maintenance/includes/TextPassDumper.php +++ b/maintenance/includes/TextPassDumper.php @@ -808,7 +808,7 @@ TEXT } private function closeSpawn() { - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); if ( $this->spawnRead ) { fclose( $this->spawnRead ); } @@ -825,7 +825,7 @@ TEXT pclose( $this->spawnProc ); } $this->spawnProc = false; - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); } /** |