Merge "Add some @noinspection flags to doPostOutputShutdown()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 4 Jan 2018 19:45:52 +0000 (19:45 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 4 Jan 2018 19:45:52 +0000 (19:45 +0000)
1  2 
includes/MediaWiki.php

diff --combined includes/MediaWiki.php
@@@ -26,7 -26,6 +26,7 @@@ use MediaWiki\MediaWikiServices
  use Wikimedia\Rdbms\ChronologyProtector;
  use Wikimedia\Rdbms\LBFactory;
  use Wikimedia\Rdbms\DBConnectionError;
 +use Liuggio\StatsdClient\Sender\SocketSender;
  
  /**
   * The MediaWiki class is the helper class for the index.php entry point.
@@@ -727,10 -726,12 +727,12 @@@ class MediaWiki 
                if ( function_exists( 'register_postsend_function' ) ) {
                        // https://github.com/facebook/hhvm/issues/1230
                        register_postsend_function( $callback );
+                       /** @noinspection PhpUnusedLocalVariableInspection */
                        $blocksHttpClient = false;
                } else {
                        if ( function_exists( 'fastcgi_finish_request' ) ) {
                                fastcgi_finish_request();
+                               /** @noinspection PhpUnusedLocalVariableInspection */
                                $blocksHttpClient = false;
                        } else {
                                // Either all DB and deferred updates should happen or none.
                wfDebug( "Request ended normally\n" );
        }
  
 +      /**
 +       * Send out any buffered statsd data according to sampling rules
 +       *
 +       * @param IBufferingStatsdDataFactory $stats
 +       * @param Config $config
 +       * @throws ConfigException
 +       * @since 1.31
 +       */
 +      public static function emitBufferedStatsdData(
 +              IBufferingStatsdDataFactory $stats, Config $config
 +      ) {
 +              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() );
 +
 +                              $stats->clearData(); // empty buffer for the next round
 +                      } catch ( Exception $ex ) {
 +                              MWExceptionHandler::logException( $ex );
 +                      }
 +              }
 +      }
 +
        /**
         * Potentially open a socket and sent an HTTP request back to the server
         * to run a specified number of jobs. This registers a callback to cleanup