$config = "{$this->basedir}/config";
$url = false;
if ( is_readable( $config ) ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$configArray = parse_ini_file( $config, true );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$remote = false;
// Use the "origin" remote repo if available or any other repo if not.
if ( $wasRelative ) {
$url = "http:$url";
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$bits = parse_url( $url );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
// parse_url() returns an array without scheme for some invalid URLs, e.g.
// parse_url("%0Ahttp://example.com") == [ 'host' => '%0Ahttp', 'path' => 'example.com' ]
if ( !$bits || !isset( $bits['scheme'] ) ) {
/**
* Reference-counted warning suppression
*
- * @deprecated since 1.26, use MediaWiki\suppressWarnings() directly
+ * @deprecated since 1.26, use Wikimedia\suppressWarnings() directly
* @param bool $end
*/
function wfSuppressWarnings( $end = false ) {
- MediaWiki\suppressWarnings( $end );
+ Wikimedia\suppressWarnings( $end );
}
/**
- * @deprecated since 1.26, use MediaWiki\restoreWarnings() directly
+ * @deprecated since 1.26, use Wikimedia\restoreWarnings() directly
* Restore error level to previous value
*/
function wfRestoreWarnings() {
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
/**
}
// Turn off the normal warning, we're doing our own below
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ok = mkdir( $dir, $mode, true ); // PHP5 <3
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$ok ) {
// directory may have been created on another request since we last checked
# This check may also protect against code injection in
# case of broken installations.
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$haveDiff3 ) {
wfDebug( "diff3 not found\n" );
}
global $wgDiff;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$haveDiff = $wgDiff && file_exists( $wgDiff );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
# This check may also protect against code injection in
# case of broken installations.
$conflimit = wfShorthandToInteger( $wgMemoryLimit );
if ( $conflimit == -1 ) {
wfDebug( "Removing PHP's memory limit\n" );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
ini_set( 'memory_limit', $conflimit );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $conflimit;
} elseif ( $conflimit > $memlimit ) {
wfDebug( "Raising PHP's memory limit to $conflimit bytes\n" );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
ini_set( 'memory_limit', $conflimit );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $conflimit;
}
}
}
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$result = unpack( $format, $data );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $result === false ) {
// If it cannot extract the packed data.
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"
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$diff = xdiff_string_rabdiff( $t1, $t2 ) . '';
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $diff;
}
*/
function patch( $base, $diff ) {
if ( function_exists( 'xdiff_string_bpatch' ) ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$text = xdiff_string_bpatch( $base, $diff ) . '';
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $text;
}
$port = $info['port'];
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$sock = $host ? fsockopen(
$host,
$port,
// If it takes more than 100ms to connect to ourselves there is a problem...
0.100
) : false;
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$invokedWithSuccess = true;
if ( $sock ) {
# this breaks strtotime().
$clientHeader = preg_replace( '/;.*$/', '', $clientHeader );
- MediaWiki\suppressWarnings(); // E_STRICT system time bitching
+ Wikimedia\suppressWarnings(); // E_STRICT system time bitching
$clientHeaderTime = strtotime( $clientHeader );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$clientHeaderTime ) {
wfDebug( __METHOD__
. ": unable to parse the client's If-Modified-Since header: $clientHeader\n" );
$wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) );
if ( $wgInvalidateCacheOnLocalSettingsChange ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', filemtime( "$IP/LocalSettings.php" ) ) );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
if ( $wgNewUserLog ) {
* explicitly set. Inspired by phpMyAdmin's treatment of the problem.
*/
if ( is_null( $wgLocaltimezone ) ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$wgLocaltimezone = date_default_timezone_get();
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
date_default_timezone_set( $wgLocaltimezone );
if ( !preg_match( '!^https?://!', $url ) ) {
$url = 'http://unused' . $url;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$a = parse_url( $url );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $a ) {
$path = isset( $a['path'] ) ? $a['path'] : '';
$this->getRequest()->response()->statusHeader( 304 );
// Avoid outputting the compressed representation of a zero-length body
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
ini_set( 'zlib.output_compression', 0 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
wfClearOutputBuffers();
return false;
}
if ( $meta ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$metadata = unserialize( $file->getMetadata() );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $metadata && $version !== 'latest' ) {
$metadata = $file->convertMetadataVersion( $metadata, $version );
}
function loadDependencyValues() {
if ( is_null( $this->timestamp ) ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
# Dependency on a non-existent file stores "false"
# This is a valid concept!
$this->timestamp = filemtime( $this->filename );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
}
* @return bool
*/
function isExpired() {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$lastmod = filemtime( $this->filename );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $lastmod === false ) {
if ( $this->timestamp === false ) {
# Still nonexistent
* @return void
*/
public function clearCache() {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
unlink( $this->cachePath() );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$this->mCached = false;
}
*/
protected function readPHPFile( $_fileName, $_fileType ) {
// Disable APC caching
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$_apcEnabled = ini_set( 'apc.cache_by_default', '0' );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
include $_fileName;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
ini_set( 'apc.cache_by_default', $_apcEnabled );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $_fileType == 'core' || $_fileType == 'extension' ) {
$data = compact( self::$allKeys );
public function parseParams() {
$rcParams = $this->getAttribute( 'rc_params' );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$unserializedParams = unserialize( $rcParams );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $unserializedParams;
}
}
$this->socket = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
socket_set_nonblock( $this->socket );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ok = socket_connect( $this->socket, $ip, $this->port );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$ok ) {
$error = socket_last_error( $this->socket );
if ( $error !== self::EINPROGRESS ) {
} elseif ( IP::isIPv6( $this->host ) ) {
throw new MWException( '$wgSquidServers does not support IPv6' );
} else {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$this->ip = gethostbyname( $this->host );
if ( $this->ip === $this->host ) {
$this->ip = false;
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
}
return $this->ip;
*/
public function close() {
if ( $this->socket ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
socket_set_block( $this->socket );
socket_shutdown( $this->socket );
socket_close( $this->socket );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
$this->socket = null;
$this->readBuffer = '';
$buf = substr( $this->writeBuffer, 0, self::BUFFER_SIZE );
$flags = 0;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$bytesSent = socket_send( $socket, $buf, strlen( $buf ), $flags );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $bytesSent === false ) {
$error = socket_last_error( $socket );
}
$buf = '';
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$bytesRead = socket_recv( $socket, $buf, self::BUFFER_SIZE, 0 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $bytesRead === false ) {
$error = socket_last_error( $socket );
if ( $error != self::EAGAIN && $error != self::EINTR ) {
}
$exceptSockets = null;
$timeout = min( $startTime + $this->timeout - microtime( true ), 1 );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$numReady = socket_select( $readSockets, $writeSockets, $exceptSockets, $timeout );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $numReady === false ) {
wfDebugLog( 'squid', __METHOD__ . ': Error in stream_select: ' .
socket_strerror( socket_last_error() ) . "\n" );
function __destruct() {
if ( $this->mOpened ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$this->close();
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
}
$session_mode = $this->mFlags & DBO_SYSDBA ? OCI_SYSDBA : OCI_DEFAULT;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
if ( $this->mFlags & DBO_PERSISTENT ) {
$this->mConn = oci_pconnect(
$this->mUser,
$session_mode
);
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $this->mUser != $this->mDBname ) {
// change current schema in session
$explain_count
);
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$this->mLastResult = $stmt = oci_parse( $this->mConn, $sql );
if ( $stmt === false ) {
}
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $explain_count > 0 ) {
return $this->doQuery( 'SELECT id, cardinality "ROWS" FROM plan_table ' .
}
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
if ( oci_execute( $stmt, $this->execFlags() ) === false ) {
$e = oci_error( $stmt );
$this->mAffectedRows = oci_num_rows( $stmt );
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( isset( $lob ) ) {
foreach ( $lob as $lob_v ) {
}
$sql = 'ALTER SESSION SET CURRENT_SCHEMA=' . strtoupper( $db );
$stmt = oci_parse( $this->mConn, $sql );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$success = oci_execute( $stmt );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$success ) {
$e = oci_error( $stmt );
if ( $e['code'] != '1435' ) {
}
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
if ( oci_execute( $stmt, $this->execFlags() ) === false ) {
$e = oci_error( $stmt );
$this->mAffectedRows = oci_num_rows( $stmt );
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( isset( $lob ) ) {
foreach ( $lob as $lob_v ) {
$transport = UDPTransport::newFromString( $file );
$transport->emit( $text );
} else {
- \MediaWiki\suppressWarnings();
+ \Wikimedia\suppressWarnings();
$exists = file_exists( $file );
$size = $exists ? filesize( $file ) : false;
if ( !$exists ||
) {
file_put_contents( $file, $text, FILE_APPEND );
}
- \MediaWiki\restoreWarnings();
+ \Wikimedia\restoreWarnings();
}
}
$catcher = self::CAUGHT_BY_HANDLER;
// The set_error_handler callback is independent from error_reporting.
// Filter out unwanted errors manually (e.g. when
- // MediaWiki\suppressWarnings is active).
+ // Wikimedia\suppressWarnings is active).
$suppressed = ( error_reporting() & $e->getSeverity() ) === 0;
if ( !$suppressed ) {
$logger = LoggerFactory::getInstance( $channel );
}
// Cleanup for disk source files...
foreach ( $sourceFSFilesToDelete as $file ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
unlink( $file ); // FS cleanup
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
return $status;
}
if ( $this->followRedirects && $this->canFollowRedirects() ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
if ( !curl_setopt( $curlHandle, CURLOPT_FOLLOWLOCATION, true ) ) {
$this->logger->debug( __METHOD__ . ": Couldn't set CURLOPT_FOLLOWLOCATION. " .
"Probably open_basedir is set.\n" );
// Continue the processing. If it were in curl_setopt_array,
// processing would have halted on its entry
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
if ( $this->profiler ) {
* @return Status
*/
static function newFromFile( $filename ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$file = fopen( $filename, 'rt' );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$file ) {
return Status::newFatal( "importcantopen" );
}
return $status;
}
global $IP;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$rows = file( "$IP/maintenance/interwiki.list",
FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$interwikis = [];
if ( !$rows ) {
return Status::newFatal( 'config-install-interwiki-list' );
// phpcs:ignore MediaWiki.VariableAnalysis.UnusedGlobalVariables
global $wgExtensionDirectory, $wgStyleDirectory;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$_lsExists = file_exists( "$IP/LocalSettings.php" );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$_lsExists ) {
return false;
* @return bool
*/
protected function envCheckPCRE() {
- MediaWiki\suppressWarnings();
+ Wikimedia\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', '', "-\xE3\x80\x80-" );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $regexd != '--' || $regexprop != '--' ) {
$this->showError( 'config-pcre-no-utf8' );
// it would be good to check other popular languages here, but it'll be slow.
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
foreach ( $scriptTypes as $ext => $contents ) {
foreach ( $contents as $source ) {
unlink( $dir . $file );
if ( $text == 'exec' ) {
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $ext;
}
}
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return false;
}
* Some long-running pages (Install, Upgrade) will want to do this
*/
protected function disableTimeLimit() {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
set_time_limit( 0 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
}
# Called early on in the installer, later we just want to sanity check
# if it's still writable
if ( $create ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ok = wfMkdirParents( $dir, 0700, __METHOD__ );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$ok ) {
return Status::newFatal( 'config-sqlite-mkdir-error', $dir );
}
$files[] = dirname( __DIR__ );
foreach ( $files as $file ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$stat = stat( $file );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $stat ) {
// stat() duplicates data into numeric and string keys so kill off all the numeric ones
foreach ( $stat as $k => $v ) {
}
// /dev/urandom is generally considered the best possible commonly
// available random source, and is available on most *nix systems.
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$urandom = fopen( "/dev/urandom", "rb" );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
// Attempt to read all our random data from urandom
// php's fread always does buffered reads based on the stream's chunk_size
unset( $params['latest'] ); // sanity
// Check that the specified temp file is valid...
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ok = ( is_file( $tmpPath ) && filesize( $tmpPath ) == 0 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$ok ) { // not present or not empty
$status->fatal( 'backend-fail-opentemp', $tmpPath );
protected function doGetFileContentsMulti( array $params ) {
$contents = [];
foreach ( $this->doGetLocalReferenceMulti( $params ) as $path => $fsFile ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$contents[$path] = $fsFile ? file_get_contents( $fsFile->getPath() ) : false;
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
return $contents;
is_int( $header ) ? HttpStatus::header( $header ) : header( $header );
};
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$info = stat( $this->path );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !is_array( $info ) ) {
if ( $sendErrors ) {
return $status;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$data = file_get_contents( $params['src'] );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $data === false ) { // source doesn't exist?
$status->fatal( 'backend-fail-store', $params['src'], $params['dst'] );
return $status;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$sha1Hash = sha1_file( $params['src'] );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $sha1Hash === false ) { // source doesn't exist?
$status->fatal( 'backend-fail-store', $params['src'], $params['dst'] );
}
protected function getSourceSha1Base36() {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$hash = sha1_file( $this->params['src'] );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $hash !== false ) {
$hash = Wikimedia\base_convert( $hash, 16, 36, 31 );
}
* @return string|bool TS_MW timestamp or false on failure
*/
public function getTimestamp() {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$timestamp = filemtime( $this->path );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $timestamp !== false ) {
$timestamp = wfTimestamp( TS_MW, $timestamp );
}
return $this->sha1Base36;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$this->sha1Base36 = sha1_file( $this->path );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $this->sha1Base36 !== false ) {
$this->sha1Base36 = Wikimedia\base_convert( $this->sha1Base36, 16, 36, 31 );
$tmpDirectory = self::getUsableTempDirectory();
}
$path = wfTempDir() . '/' . $prefix . $hex . $ext;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$newFileHandle = fopen( $path, 'x' );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $newFileHandle ) {
fclose( $newFileHandle );
$tmpFile = new self( $path );
*/
public function purge() {
$this->canDelete = false; // done
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ok = unlink( $this->path );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
unset( self::$pathsCollect[$this->path] );
*/
public static function purgeAllOnShutdown() {
foreach ( self::$pathsCollect as $path ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
unlink( $path );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
}
if ( isset( $this->handles[$path] ) ) {
$handle = $this->handles[$path];
} else {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$handle = fopen( $this->getLockPath( $path ), 'a+' );
if ( !$handle ) { // lock dir missing?
mkdir( $this->lockDir, 0777, true );
$handle = fopen( $this->getLockPath( $path ), 'a+' ); // try again
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
if ( $handle ) {
// Either a shared or exclusive lock
*/
private function doGuessMimeType( $file, $ext ) {
// Read a chunk of the file
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$f = fopen( $file, 'rb' );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$f ) {
return 'unknown/unknown';
}
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$gis = getimagesize( $file );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $gis && isset( $gis['mime'] ) ) {
$mime = $gis['mime'];
$timeout = $this->_connect_timeout;
$errno = $errstr = null;
for ( $i = 0; !$sock && $i < $this->_connect_attempts; $i++ ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
if ( $this->_persistent == 1 ) {
$sock = pfsockopen( $ip, $port, $errno, $errstr, $timeout );
} else {
$sock = fsockopen( $ip, $port, $errno, $errstr, $timeout );
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
if ( !$sock ) {
$this->_error_log( "Error connecting to $host: $errstr" );
use Psr\Log\LoggerInterface;
use Wikimedia\ScopedCallback;
use Wikimedia\Timestamp\ConvertibleTimestamp;
-use MediaWiki;
+use Wikimedia;
use BagOStuff;
use HashBagOStuff;
use InvalidArgumentException;
$fname = false,
callable $inputCallback = null
) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$fp = fopen( $filename, 'r' );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( false === $fp ) {
throw new RuntimeException( "Could not open \"{$filename}\".\n" );
if ( $this->mConn ) {
// Avoid connection leaks for sanity. Normally, resources close at script completion.
// The connection might already be closed in zend/hhvm by now, so suppress warnings.
- \MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$this->closeConnection();
- \MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$this->mConn = false;
$this->mOpened = false;
}
namespace Wikimedia\Rdbms;
-use MediaWiki;
+use Wikimedia;
use Exception;
use stdClass;
$connectionInfo['PWD'] = $password;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$this->mConn = sqlsrv_connect( $server, $connectionInfo );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $this->mConn === false ) {
throw new DBConnectionError( $this, $this->lastError() );
use DateTime;
use DateTimeZone;
-use MediaWiki;
+use Wikimedia;
use InvalidArgumentException;
use Exception;
use stdClass;
}
if ( strlen( $dbName ) ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$success = $this->selectDB( $dbName );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$success ) {
$this->queryLogger->error(
"Error selecting database {db_name} on server {db_server}",
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ok = $this->mysqlFreeResult( $res );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$ok ) {
throw new DBUnexpectedError( $this, "Unable to free MySQL result" );
}
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$row = $this->mysqlFetchObject( $res );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$errno = $this->lastErrno();
// Unfortunately, mysql_fetch_object does not reset the last errno.
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$row = $this->mysqlFetchArray( $res );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$errno = $this->lastErrno();
// Unfortunately, mysql_fetch_array does not reset the last errno.
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$n = $this->mysqlNumRows( $res );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
// Unfortunately, mysql_num_rows does not reset the last errno.
// We are not checking for any errors here, since
public function lastError() {
if ( $this->mConn ) {
# Even if it's non-zero, it can still be invalid
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$error = $this->mysqlError( $this->mConn );
if ( !$error ) {
$error = $this->mysqlError();
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
} else {
$error = $this->mysqlError();
}
use Wikimedia\Timestamp\ConvertibleTimestamp;
use Wikimedia\WaitConditionLoop;
-use MediaWiki;
+use Wikimedia;
use Exception;
/**
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ok = pg_free_result( $res );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$ok ) {
throw new DBUnexpectedError( $this, "Unable to free Postgres result\n" );
}
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$row = pg_fetch_object( $res );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
# @todo FIXME: HACK HACK HACK HACK debug
# @todo hashar: not sure if the following test really trigger if the object
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$row = pg_fetch_array( $res );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$conn = $this->getBindingHandle();
if ( pg_last_error( $conn ) ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$n = pg_num_rows( $res );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$conn = $this->getBindingHandle();
if ( pg_last_error( $conn ) ) {
}
if ( $this->charset !== 'UTF-8' ) {
// don't convert if already utf-8
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$content = iconv( $this->charset, 'UTF-8//IGNORE', $content );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
// Ensure the XMP block does not have an xml doctype declaration, which
// Even with LIBXML_NOWARNING set, XMLReader::read gives a warning
// when parsing truncated XML, which causes unit tests to fail.
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
while ( $reader->read() ) {
if ( $reader->nodeType === XMLReader::ELEMENT ) {
// Reached the first element without hitting a doctype declaration
break;
}
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !is_null( $result ) ) {
return $result;
public function getParameters() {
if ( !isset( $this->params ) ) {
$blob = $this->getRawParameters();
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$params = LogEntryBase::extractParams( $blob );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $params !== false ) {
$this->params = $params;
$this->legacy = false;
require_once 'Mail.php';
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory( 'smtp', $wgSMTP );
if ( PEAR::isError( $mail_object ) ) {
wfDebug( "PEAR::Mail factory failed: " . $mail_object->getMessage() . "\n" );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return Status::newFatal( 'pear-mail-error', $mail_object->getMessage() );
}
$status = self::sendWithPear( $mail_object, $chunk, $headers, $body );
// FIXME : some chunks might be sent while others are not!
if ( !$status->isOK() ) {
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $status;
}
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return Status::newGood();
} else {
// PHP mail()
'-layers', 'merge',
'-background', 'white',
];
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$xcfMeta = unserialize( $image->getMetadata() );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $xcfMeta
&& isset( $xcfMeta['colorType'] )
&& $xcfMeta['colorType'] === 'greyscale-alpha'
return $metadata;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$unser = unserialize( $metadata );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( is_array( $unser ) ) {
if ( isset( $unser['error'] ) ) {
return false;
* @return array
*/
protected function extractTreesFromMetadata( $metadata ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
try {
// Set to false rather than null to avoid further attempts
$metaTree = false;
} catch ( Exception $e ) {
wfDebug( "Bogus multipage XML metadata\n" );
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return [ 'MetaTree' => $metaTree, 'TextTree' => $textTree ];
}
}
function getInfo() {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$file = fopen( $this->mFilename, 'rb' );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $file === false ) {
wfDebug( __METHOD__ . ": missing or failed file read\n" );
$this->debugFile( $this->basename, __FUNCTION__, true );
if ( function_exists( 'exif_read_data' ) ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$data = exif_read_data( $this->file, 0, true );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
} else {
throw new MWException( "Internal error: exif_read_data not present. " .
"\$wgShowEXIF may be incorrectly set or not checked by an extension." );
break;
}
if ( $charset ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$val = iconv( $charset, 'UTF-8//IGNORE', $val );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
} else {
// if valid utf-8, assume that, otherwise assume windows-1252
$valCopy = $val;
UtfNormal\Validator::quickIsNFCVerify( $valCopy ); // validates $valCopy.
if ( $valCopy !== $val ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$val = iconv( 'Windows-1252', 'UTF-8//IGNORE', $val );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
}
if ( $metadata === self::BROKEN_FILE ) {
return self::METADATA_GOOD;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$exif = unserialize( $metadata );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !isset( $exif['MEDIAWIKI_EXIF_VERSION'] )
|| $exif['MEDIAWIKI_EXIF_VERSION'] != Exif::version()
) {
if ( !$data ) {
return 0;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$data = unserialize( $data );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( isset( $data['Orientation'] ) ) {
# See http://sylvana.net/jpegcrop/exif_orientation.html
switch ( $data['Orientation'] ) {
return self::METADATA_GOOD;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$data = unserialize( $metadata );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$data || !is_array( $data ) ) {
wfDebug( __METHOD__ . " invalid GIF metadata\n" );
$original = parent::getLongDesc( $image );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$metadata = unserialize( $image->getMetadata() );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$metadata || $metadata['frameCount'] <= 1 ) {
return $original;
*/
public function getLength( $file ) {
$serMeta = $file->getMetadata();
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$metadata = unserialize( $serMeta );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$metadata || !isset( $metadata['duration'] ) || !$metadata['duration'] ) {
return 0.0;
UtfNormal\Validator::quickIsNFCVerify( $dataCopy );
if ( $dataCopy !== $data ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$data = iconv( 'windows-1252', 'UTF-8', $data );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
$commentCount = count( $comment );
*/
private static function convIPTCHelper( $data, $charset ) {
if ( $charset ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$data = iconv( $charset, "UTF-8//IGNORE", $data );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $data === false ) {
$data = "";
wfDebugLog( 'iptc', __METHOD__ . " Error converting iptc data charset $charset to utf-8" );
}
function getImageSize( $image, $path ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$gis = getimagesize( $path );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $gis;
}
// turns $com to valid utf-8.
// thus if no change, its utf-8, otherwise its something else.
if ( $com !== $oldCom ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$com = $oldCom = iconv( 'windows-1252', 'UTF-8//IGNORE', $oldCom );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
// Try it again, if its still not a valid string, then probably
// binary junk or some really weird encoding, so don't extract.
function convertMetadataVersion( $metadata, $version = 1 ) {
if ( !is_array( $metadata ) ) {
// unserialize to keep return parameter consistent.
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ret = unserialize( $metadata );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $ret;
}
return self::METADATA_GOOD;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$data = unserialize( $metadata );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$data || !is_array( $data ) ) {
wfDebug( __METHOD__ . " invalid png metadata\n" );
global $wgLang;
$original = parent::getLongDesc( $image );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$metadata = unserialize( $image->getMetadata() );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$metadata || $metadata['frameCount'] <= 0 ) {
return $original;
*/
public function getLength( $file ) {
$serMeta = $file->getMetadata();
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$metadata = unserialize( $serMeta );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$metadata || !isset( $metadata['duration'] ) || !$metadata['duration'] ) {
return 0.0;
// if compressed
if ( $items[2] == "\x01" ) {
if ( function_exists( 'gzuncompress' ) && $items[4] === "\x00" ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$items[5] = gzuncompress( $items[5] );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $items[5] === false ) {
// decompression failed
fseek( $fh, self::$crcSize, SEEK_CUR );
continue;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$content = iconv( 'ISO-8859-1', 'UTF-8', $content );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $content === false ) {
throw new Exception( __METHOD__ . ": Read error (error with iconv)" );
continue;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$content = gzuncompress( $content );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $content === false ) {
// decompression failed
continue;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$content = iconv( 'ISO-8859-1', 'UTF-8', $content );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $content === false ) {
throw new Exception( __METHOD__ . ": Read error (error with iconv)" );
$ok = symlink( $srcPath, $lnPath );
/** @noinspection PhpUnusedLocalVariableInspection */
$cleaner = new ScopedCallback( function () use ( $tmpDir, $lnPath ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
unlink( $lnPath );
rmdir( $tmpDir );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
} );
if ( !$ok ) {
wfDebugLog( 'thumbnail',
}
function unpackMetadata( $metadata ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$unser = unserialize( $metadata );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( isset( $unser['version'] ) && $unser['version'] == self::SVG_METADATA_VERSION ) {
return $unser;
} else {
// 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.
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
try {
$this->read();
} catch ( Exception $e ) {
// Note, if this happens, the width/height will be taken to be 0x0.
// Should we consider it the default 512x512 instead?
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
libxml_disable_entity_loader( $oldDisable );
throw $e;
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
libxml_disable_entity_loader( $oldDisable );
}
return self::METADATA_GOOD;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$data = unserialize( $metadata );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$data || !is_array( $data ) ) {
wfDebug( __METHOD__ . " invalid WebP metadata\n" );
$metadata = $file->getMetadata();
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$metadata = unserialize( $metadata );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $metadata == false ) {
return false;
* @return bool
*/
public function canRender( $file ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$xcfMeta = unserialize( $file->getMetadata() );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( isset( $xcfMeta['colorType'] ) && $xcfMeta['colorType'] === 'index-coloured' ) {
return false;
}
*/
protected function unserialize( $serial ) {
if ( function_exists( 'gzinflate' ) ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$decomp = gzinflate( $serial );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( false !== $decomp ) {
$serial = $decomp;
$xml .= "</list>";
$dom = new DOMDocument();
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$result = $dom->loadXML( $xml );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$result ) {
// Try running the XML through UtfNormal to get rid of invalid characters
$xml = UtfNormal\Validator::cleanUp( $xml );
}
$dom = new DOMDocument;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$result = $dom->loadXML( $xml );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$result ) {
// Try running the XML through UtfNormal to get rid of invalid characters
$xml = UtfNormal\Validator::cleanUp( $xml );
$badtag = true;
} elseif ( $slash ) {
# Closing a tag... is it the one we just opened?
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ot = array_pop( $tagstack );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $ot != $t ) {
if ( isset( $htmlsingleallowed[$ot] ) ) {
# and see if we find a match below them
$optstack = [];
array_push( $optstack, $ot );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ot = array_pop( $tagstack );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
while ( $ot != $t && isset( $htmlsingleallowed[$ot] ) ) {
array_push( $optstack, $ot );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ot = array_pop( $tagstack );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
if ( $t != $ot ) {
# No match. Push the optional elements back again
$badtag = true;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ot = array_pop( $optstack );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
while ( $ot ) {
array_push( $tagstack, $ot );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ot = array_pop( $optstack );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
}
} else {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
array_push( $tagstack, $ot );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
# <li> can be nested in <ul> or <ol>, skip those cases:
if ( !isset( $htmllist[$ot] ) || !isset( $listtags[$t] ) ) {
* @return int UNIX timestamp
*/
protected static function safeFilemtime( $filePath ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$mtime = filemtime( $filePath ) ?: 1;
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $mtime;
}
if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
$filteredText, $m, PREG_SET_ORDER ) ) {
foreach ( $m as $bits ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits;
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $nonQuoted != '' ) {
$term = $nonQuoted;
if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
$filteredText, $m, PREG_SET_ORDER ) ) {
foreach ( $m as $bits ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits;
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $nonQuoted != '' ) {
$term = $nonQuoted;
$m = [];
while ( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
list( $src, $var ) = $m;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$varValue = $this->context[$var];
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$value = str_replace( $src, $varValue, $value );
}
return $value;
$buffer = WikiExporter::STREAM;
// This might take a while... :D
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
set_time_limit( 0 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
$exporter = new WikiExporter( $db, $history, $buffer );
return Status::newFatal( 'locknoconfirm' );
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$fp = fopen( $this->getConfig()->get( 'ReadOnlyFile' ), 'w' );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( false === $fp ) {
# This used to show a file not found error, but the likeliest reason for fopen()
}
$readOnlyFile = $this->getConfig()->get( 'ReadOnlyFile' );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$res = unlink( $readOnlyFile );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $res ) {
return Status::newGood();
* we're definitely dealing with revision data and we may proceed, if not, we'll leave it
* to extensions to subscribe to the hook to parse the row.
*/
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
try {
$rev = new Revision( $row );
$validRevision = (bool)$rev->getId();
} catch ( Exception $e ) {
$validRevision = false;
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $validRevision ) {
$attribs['data-mw-revid'] = $rev->getId();
* we're definitely dealing with revision data and we may proceed, if not, we'll leave it
* to extensions to subscribe to the hook to parse the row.
*/
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
try {
$rev = Revision::newFromArchiveRow( $row );
$validRevision = (bool)$rev->getId();
} catch ( Exception $e ) {
$validRevision = false;
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $validRevision ) {
$attribs['data-mw-revid'] = $rev->getId();
// 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 ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$str = iconv( $encoding, 'UTF-8', $contents );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $str != '' && preg_match( "!<\?xml\b(.*?)\?>!si", $str, $matches ) ) {
if ( preg_match( $encodingRegex, $matches[1], $encMatch )
&& !in_array( strtoupper( $encMatch[1] ), self::$safeXmlEncodings )
protected static function findExecutable( $path, $name, $versionInfo = false ) {
$command = $path . DIRECTORY_SEPARATOR . $name;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$file_exists = is_executable( $command );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $file_exists ) {
if ( !$versionInfo ) {
$filePaths = (array)$filePaths;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
if ( count( $filePaths ) === 1 ) {
$hash = $instance->getFileContentsHashInternal( $filePaths[0], $algo );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $hash;
}
return $instance->getFileContentsHashInternal( $filePath, $algo ) ?: '';
}, $filePaths );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$hashes = implode( '', $hashes );
return $hashes ? hash( $algo, $hashes ) : false;
}
// Try to get some ID that uniquely identifies this machine (RFC 4122)...
if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
if ( wfIsWindows() ) {
// https://technet.microsoft.com/en-us/library/bb490913.aspx
$csv = trim( wfShellExec( 'getmac /NH /FO CSV' ) );
wfShellExec( '/sbin/ifconfig -a' ), $m );
$nodeId = isset( $m[1] ) ? str_replace( ':', '', $m[1] ) : '';
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
$nodeId = MWCryptRand::generateHex( 12, true );
$nodeId[1] = dechex( hexdec( $nodeId[1] ) | 0x1 ); // set multicast bit
return $ts;
}
- MediaWiki\suppressWarnings(); // E_STRICT system time bitching
+ Wikimedia\suppressWarnings(); // E_STRICT system time bitching
# 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.
(int)substr( $ts, 0, 4 ) ); # Year
$date = date( 'YmdHis', $t );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $date;
}
# *input* string. We just ignore those too.
# REF: https://bugs.php.net/bug.php?id=37166
# REF: https://phabricator.wikimedia.org/T18885
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$text = iconv( $in, $out . '//IGNORE', $string );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $text;
}
$wgShowSQLErrors = true;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
set_time_limit( 0 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$this->adjustMemoryLimit();
}
}
public function execute() {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$content = file_get_contents( $this->getOption( 'file' ) );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $content === false ) {
$this->fatalError( 'Unable to open input file' );
}
}
private function getTextSpawned( $id ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
if ( !$this->spawnProc ) {
// First time?
$this->openSpawn();
}
$text = $this->getTextSpawnedOnce( $id );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $text;
}
}
private function closeSpawn() {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
if ( $this->spawnRead ) {
fclose( $this->spawnRead );
}
pclose( $this->spawnProc );
}
$this->spawnProc = false;
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
private function getTextSpawnedOnce( $id ) {
$this->error( 'WARNING: You have provided the options "dbpass" and "dbpassfile". '
. 'The content of "dbpassfile" overrides "dbpass".' );
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$dbpass = file_get_contents( $dbpassfile ); // returns false on failure
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $dbpass === false ) {
$this->fatalError( "Couldn't open $dbpassfile" );
}
$this->error( 'WARNING: You have provided the options "pass" and "passfile". '
. 'The content of "passfile" overrides "pass".' );
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$pass = file_get_contents( $passfile ); // returns false on failure
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $pass === false ) {
$this->fatalError( "Couldn't open $passfile" );
}
$parser = new JSParser();
foreach ( $files as $filename ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$js = file_get_contents( $filename );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $js === false ) {
$this->output( "$filename ERROR: could not read file\n" );
$this->errs++;
/** A general output object. Need to be overridden */
class StatsOutput {
function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$return = sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $return;
}
}
function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$v = round( 255 * $subset / $total );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $revert ) {
# Weigh reverse with factor 20 so coloring takes effect more quickly as
}
}
- MediaWiki\suppressWarnings(); // header notices
+ Wikimedia\suppressWarnings(); // header notices
// Cache ?action=view
$wgRequestTime = microtime( true ); # T24852
ob_start();
$context->getOutput()->clearHTML();
$historyHtml = ob_get_clean();
$historyCache->saveToFileCache( $historyHtml );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $rebuilt ) {
$this->output( "Re-cached page '$title' (id {$row->page_id})..." );
$this->db->query( 'BEGIN IMMEDIATE TRANSACTION', __METHOD__ );
$ourFile = $this->db->getDbFilePath();
$this->output( " Copying database file $ourFile to $fileName... " );
- MediaWiki\suppressWarnings( false );
+ Wikimedia\suppressWarnings();
if ( !copy( $ourFile, $fileName ) ) {
$err = error_get_last();
$this->error( " {$err['message']}" );
}
- MediaWiki\suppressWarnings( true );
+ Wikimedia\restoreWarnings();
$this->output( " Releasing lock...\n" );
$this->db->query( 'COMMIT TRANSACTION', __METHOD__ );
}
$text = $secondaryRow->old_text;
if ( in_array( 'external', $flags ) ) {
$url = $text;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
list( /* $proto */, $path ) = explode( '://', $url, 2 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $path == "" ) {
return false;
[ 'file', 'php://stdout', 'w' ],
[ 'file', 'php://stderr', 'w' ]
];
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$proc = proc_open( "$cmd --replica-id $i", $spec, $pipes );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$proc ) {
$this->critical( "Error opening replica DB process: $cmd" );
exit( 1 );
// guaranteed to give accurate results. For example, it may introduce
// differences in the number of line breaks in <pre> tags.
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
if ( !$this->doc->loadXML( '<html><body>' . $text . '</body></html>' ) ) {
$this->invalid = true;
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$this->xpath = new DOMXPath( $this->doc );
$this->body = $this->xpath->query( '//body' )->item( 0 );
}
function guessVarSize( $var ) {
$length = 0;
try {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$length = strlen( serialize( $var ) );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
} catch ( Exception $e ) {
}
return $length;
* @param string $function
*/
public function hideDeprecated( $function ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
wfDeprecated( $function );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
/**
# This check may also protect against code injection in
# case of broken installations.
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$haveDiff3 ) {
$this->markTestSkipped( "Skip test, since diff3 is not configured" );
}
public function testGetCommentErrors() {
- MediaWiki\suppressWarnings();
- $reset = new ScopedCallback( 'MediaWiki\restoreWarnings' );
+ Wikimedia\suppressWarnings();
+ $reset = new ScopedCallback( 'Wikimedia\restoreWarnings' );
$store = $this->makeStore( MIGRATION_OLD );
$res = $store->getComment( 'dummy', [ 'dummy' => 'comment' ] );
public function testWfMkdirParents() {
// Should not return true if file exists instead of directory
$fname = $this->getNewTempFile();
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ok = wfMkdirParents( $fname );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$this->assertFalse( $ok );
}
'UploadPath' => $uploadPath,
] );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$actual = OutputPage::transformResourcePath( $conf, $path );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$this->assertEquals( $expected ?: $path, $actual );
}
'text_id' => 123456789, // not in the test DB
] );
- MediaWiki\suppressWarnings(); // bad text_id will trigger a warning.
+ Wikimedia\suppressWarnings(); // bad text_id will trigger a warning.
$this->assertNull( $rev->getContent(),
"getContent() should return null if the revision's text blob could not be loaded." );
$this->assertNull( $rev->getContent(),
"getContent() should return null if the revision's text blob could not be loaded." );
- MediaWiki\suppressWarnings( 'end' );
+ Wikimedia\restoreWarnings();
}
public function provideGetSize() {
* @covers \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray
*/
public function testConstructFromArrayWithBadPageId() {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$rev = new Revision( [ 'page' => 77777777 ] );
$this->assertSame( 77777777, $rev->getPage() );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
public function provideConstructFromArray_userSetAsExpected() {
public function testConstructFromRowWithBadPageId() {
$this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD );
$this->overrideMwServices();
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$rev = new Revision( (object)[ 'rev_page' => 77777777 ] );
$this->assertSame( 77777777, $rev->getPage() );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
public function provideGetRevisionText() {
}
public static function provideGetMessageFromException() {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$usageException = new UsageException(
'<b>Something broke!</b>', 'ue-code', 0, [ 'xxx' => 'yyy', 'baz' => 23 ]
);
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return [
'Normal exception' => [
MWExceptionHandler::getRedactedTraceAsString( $dbex )
)->inLanguage( 'en' )->useDatabase( false )->text();
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$usageEx = new UsageException( 'Usage exception!', 'ue', 0, [ 'foo' => 'bar' ] );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$apiEx1 = new ApiUsageException( null,
StatusValue::newFatal( new ApiRawMessage( 'An error', 'sv-error1' ) ) );
$chunkSessionKey = false;
$resultOffset = 0;
// Open the file:
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$handle = fopen( $filePath, "r" );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $handle === false ) {
$this->markTestIncomplete( "could not open file: $filePath" );
while ( !feof( $handle ) ) {
// Get the current chunk
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$chunkData = fread( $handle, $chunkSize );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
// Upload the current chunk into the $_FILE object:
$this->fakeUploadChunk( 'chunk', 'blob', $mimeType, $chunkData );
$row->rc_deleted = 'bar';
$row->rc_comment = 'comment';
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$rc = RecentChange::newFromRow( $row );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$expected = [
'rc_foo' => 'AAA',
$this->assertInstanceOf( \Wikimedia\Rdbms\DBConnectionError::class, $e );
$this->assertFalse( $db->isOpen() );
} else {
- \MediaWiki\suppressWarnings();
+ \Wikimedia\suppressWarnings();
$this->assertFalse( $db->selectDB( 'garbage-db' ) );
- \MediaWiki\restoreWarnings();
+ \Wikimedia\restoreWarnings();
}
$lb->reuseConnection( $db ); // don't care
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
MWDebug::init();
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
}
public static function tearDownAfterClass() {
parent::tearDownAfterClass();
MWDebug::deinit();
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
/**
// disable conversion of notices
PHPUnit_Framework_Error_Notice::$enabled = false;
// have to keep the user notice from being output
- \MediaWiki\suppressWarnings();
+ \Wikimedia\suppressWarnings();
$res = $formatter->format( [ 'channel' => 'marty' ] );
- \MediaWiki\restoreWarnings();
+ \Wikimedia\restoreWarnings();
PHPUnit_Framework_Error_Notice::$enabled = $noticeEnabled;
$this->assertNull( $res );
}
]
];
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$actual = $be->sanitizeOpHeaders( $input );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$this->assertEquals( $expected, $actual, "Header sanitized properly" );
}
// JSMin+'s parser will throw an exception if output is not valid JS.
// suppression of warnings needed for stupid crap
if ( $expectedValid ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$parser = new JSParser();
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
$parser->parse( $minified, 'minify-test.js', 1 );
}
);
$wrap->setEnableFlags( 'warn' );
- \MediaWiki\suppressWarnings();
+ \Wikimedia\suppressWarnings();
ini_set( 'session.serialize_handler', $handler );
- \MediaWiki\restoreWarnings();
+ \Wikimedia\restoreWarnings();
if ( ini_get( 'session.serialize_handler' ) !== $handler ) {
$this->markTestSkipped( "Cannot set session.serialize_handler to \"$handler\"" );
}
$hmac = hash_hmac( 'sha256', $sealed, $hmacKey, true );
$encrypted = base64_encode( $hmac ) . '.' . $sealed;
$session->set( 'test', $encrypted );
- \MediaWiki\suppressWarnings();
+ \Wikimedia\suppressWarnings();
$this->assertEquals( 'defaulted', $session->getSecret( 'test', 'defaulted' ) );
- \MediaWiki\restoreWarnings();
+ \Wikimedia\restoreWarnings();
}
}
continue;
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$contents = file_get_contents( $filePath );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $contents === false ) {
$actual[$class] = "[couldn't read file '$filePath']";
// Fix IE brokenness
$imsString = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
// Calculate time
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$imsUnix = strtotime( $imsString );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( wfTimestamp( TS_UNIX, $img->getTimestamp() ) <= $imsUnix ) {
HttpStatus::header( 304 );
return;