X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=42a6573257cdb529bfdf23cd6138073959a4e82f;hb=856c6769cd9502a0872c0f8db74ec0c43025ca27;hp=a06d72100f2c346a152cb414d8a509d0871145ce;hpb=16c80e429be5904fb42a93f260f8de3d18f0c692;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a06d72100f..42a6573257 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -877,9 +877,9 @@ function wfParseUrl( $url ) { 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'] ) ) { @@ -1050,7 +1050,7 @@ function wfMatchesDomainList( $url, $domains ) { */ function wfDebug( $text, $dest = 'all', array $context = [] ) { global $wgDebugRawPage, $wgDebugLogPrefix; - global $wgDebugTimestamps, $wgRequestTime; + global $wgDebugTimestamps; if ( !$wgDebugRawPage && wfIsDebugRawPage() ) { return; @@ -1061,7 +1061,7 @@ function wfDebug( $text, $dest = 'all', array $context = [] ) { if ( $wgDebugTimestamps ) { $context['seconds_elapsed'] = sprintf( '%6.4f', - microtime( true ) - $wgRequestTime + microtime( true ) - $_SERVER['REQUEST_TIME_FLOAT'] ); $context['memory_used'] = sprintf( '%5.1fM', @@ -1514,9 +1514,11 @@ function wfHostname() { * @return string */ function wfReportTime() { - global $wgRequestTime, $wgShowHostnames; + global $wgShowHostnames; - $responseTime = round( ( microtime( true ) - $wgRequestTime ) * 1000 ); + $elapsed = ( microtime( true ) - $_SERVER['REQUEST_TIME_FLOAT'] ); + // seconds to milliseconds + $responseTime = round( $elapsed * 1000 ); $reportVars = [ 'wgBackendResponseTime' => $responseTime ]; if ( $wgShowHostnames ) { $reportVars['wgHostname'] = wfHostname(); @@ -1843,7 +1845,7 @@ function wfHttpError( $code, $label, $desc ) { function wfResetOutputBuffers( $resetGzipEncoding = true ) { if ( $resetGzipEncoding ) { // Suppress Content-Encoding and Content-Length - // headers from 1.10+s wfOutputHandler + // headers from OutputHandler::handle. global $wgDisableOutputCompression; $wgDisableOutputCompression = true; } @@ -2009,19 +2011,19 @@ function wfNegotiateType( $cprefs, $sprefs ) { /** * 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(); } /** @@ -2150,9 +2152,9 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) { } // 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 @@ -2412,9 +2414,9 @@ function wfMerge( $old, $mine, $yours, &$result, &$mergeAttemptResult = null ) { # 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" ); @@ -2496,9 +2498,9 @@ function wfDiff( $before, $after, $params = '-u' ) { } 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. @@ -2686,30 +2688,6 @@ function wfRelativePath( $path, $from ) { return implode( DIRECTORY_SEPARATOR, $pieces ); } -/** - * Convert an arbitrarily-long digit string from one numeric base - * to another, optionally zero-padding to a minimum column width. - * - * Supports base 2 through 36; digit values 10-36 are represented - * as lowercase letters a-z. Input is case-insensitive. - * - * @deprecated since 1.27 Use Wikimedia\base_convert() directly - * - * @param string $input Input number - * @param int $sourceBase Base of the input number - * @param int $destBase Desired base of the output - * @param int $pad Minimum number of digits in the output (pad with zeroes) - * @param bool $lowercase Whether to output in lowercase or uppercase - * @param string $engine Either "gmp", "bcmath", or "php" - * @return string|bool The output number as a string, or false on error - */ -function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, - $lowercase = true, $engine = 'auto' -) { - wfDeprecated( __FUNCTION__, '1.27' ); - return Wikimedia\base_convert( $input, $sourceBase, $destBase, $pad, $lowercase, $engine ); -} - /** * Reset the session id * @@ -2754,7 +2732,7 @@ function wfSetupSession( $sessionId = false ) { if ( session_id() !== $session->getId() ) { session_id( $session->getId() ); } - MediaWiki\quietCall( 'session_start' ); + Wikimedia\quietCall( 'session_start' ); } /** @@ -3052,7 +3030,8 @@ function wfWaitForSlaves( } try { - wfGetLBFactory()->waitForReplication( [ + $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + $lbFactory->waitForReplication( [ 'wiki' => $wiki, 'cluster' => $cluster, 'timeout' => $timeout, @@ -3122,15 +3101,15 @@ function wfMemoryLimit() { $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; } } @@ -3283,9 +3262,9 @@ function wfUnpack( $format, $data, $length = false ) { } } - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); $result = unpack( $format, $data ); - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); if ( $result === false ) { // If it cannot extract the packed data. @@ -3527,19 +3506,3 @@ function wfGetRusage() { return getrusage( 0 /* RUSAGE_SELF */ ); } } - -/** - * Begin profiling of a function - * @param string $functionname Name of the function we will profile - * @deprecated since 1.25 - */ -function wfProfileIn( $functionname ) { -} - -/** - * Stop profiling of a function - * @param string $functionname Name of the function we have profiled - * @deprecated since 1.25 - */ -function wfProfileOut( $functionname = 'missing' ) { -}