From: Max Semenik Date: Wed, 25 Oct 2017 01:51:45 +0000 (-0700) Subject: Switch ServiceWiring to the new execution framework X-Git-Tag: 1.31.0-rc.0~214^2 X-Git-Url: http://git.cyclocoop.org/images/a/a9/%28?a=commitdiff_plain;h=0216bd487197c446cf872f0e096dd6647f1ffb61;p=lhc%2Fweb%2Fwiklou.git Switch ServiceWiring to the new execution framework To test: $wgMimeDetectorCommand = 'file -bi'; $services = \MediaWiki\MediaWikiServices::getInstance(); echo $services->getMimeAnalyzer()->guessMimeType('/vagrant/mediawiki/README'); Change-Id: Iaf124901c68292736e5588636f5ec746147f6a54 --- diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 5131917d94..dd837a848c 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -286,8 +286,14 @@ return [ $detectorCmd = $mainConfig->get( 'MimeDetectorCommand' ); if ( $detectorCmd ) { - $params['detectCallback'] = function ( $file ) use ( $detectorCmd ) { - return wfShellExec( "$detectorCmd " . wfEscapeShellArg( $file ) ); + $factory = $services->getShellCommandFactory(); + $params['detectCallback'] = function ( $file ) use ( $detectorCmd, $factory ) { + $result = $factory->create() + // $wgMimeDetectorCommand can contain commands with parameters + ->unsafeParams( $detectorCmd ) + ->params( $file ) + ->execute(); + return $result->getStdout(); }; }