X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=523a0f93a69ed55a1195cf668be4543a239a28c1;hp=bb1951d52822759c9664a66ed3182a8481368c6e;hb=dbad540cd37617879aff6f28ce9c016dd8049d4e;hpb=1ec7e520d388b7cf23e116ac8f7a5a89ab613f9e diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index bb1951d528..523a0f93a6 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -24,7 +24,6 @@ if ( !defined( 'MEDIAWIKI' ) ) { die( "This file is part of MediaWiki, it is not a valid entry point" ); } -use Liuggio\StatsdClient\Sender\SocketSender; use MediaWiki\Logger\LoggerFactory; use MediaWiki\ProcOpenError; use MediaWiki\Session\SessionManager; @@ -1231,6 +1230,7 @@ function wfErrorLog( $text, $file, array $context = [] ) { /** * @todo document + * @todo Move logic to MediaWiki.php */ function wfLogProfilingData() { global $wgDebugLogGroups, $wgDebugRawPage; @@ -1242,23 +1242,13 @@ function wfLogProfilingData() { $profiler->setContext( $context ); $profiler->logData(); - $config = $context->getConfig(); - $stats = MediaWikiServices::getInstance()->getStatsdDataFactory(); - if ( $config->get( 'StatsdServer' ) && $stats->hasData() ) { - try { - $statsdServer = explode( ':', $config->get( 'StatsdServer' ) ); - $statsdHost = $statsdServer[0]; - $statsdPort = isset( $statsdServer[1] ) ? $statsdServer[1] : 8125; - $statsdSender = new SocketSender( $statsdHost, $statsdPort ); - $statsdClient = new SamplingStatsdClient( $statsdSender, true, false ); - $statsdClient->setSamplingRates( $config->get( 'StatsdSamplingRates' ) ); - $statsdClient->send( $stats->getData() ); - } catch ( Exception $ex ) { - MWExceptionHandler::logException( $ex ); - } - } + // Send out any buffered statsd metrics as needed + MediaWiki::emitBufferedStatsdData( + MediaWikiServices::getInstance()->getStatsdDataFactory(), + $context->getConfig() + ); - # Profiling must actually be enabled... + // Profiling must actually be enabled... if ( $profiler instanceof ProfilerStub ) { return; } @@ -2404,9 +2394,10 @@ function wfShellWikiCmd( $script, array $parameters = [], array $options = [] ) * @param string $mine * @param string $yours * @param string &$result + * @param string &$mergeAttemptResult * @return bool */ -function wfMerge( $old, $mine, $yours, &$result ) { +function wfMerge( $old, $mine, $yours, &$result, &$mergeAttemptResult = null ) { global $wgDiff3; # This check may also protect against code injection in @@ -2442,13 +2433,18 @@ function wfMerge( $old, $mine, $yours, &$result ) { $oldtextName, $yourtextName ); $handle = popen( $cmd, 'r' ); - if ( fgets( $handle, 1024 ) ) { - $conflict = true; - } else { - $conflict = false; - } + $mergeAttemptResult = ''; + do { + $data = fread( $handle, 8192 ); + if ( strlen( $data ) == 0 ) { + break; + } + $mergeAttemptResult .= $data; + } while ( true ); pclose( $handle ); + $conflict = $mergeAttemptResult !== ''; + # Merge differences $cmd = Shell::escape( $wgDiff3, '-a', '-e', '--merge', $mytextName, $oldtextName, $yourtextName );