From: Max Semenik Date: Tue, 17 Oct 2017 06:53:50 +0000 (-0700) Subject: Switch DifferenceEngine to the new shell framework X-Git-Tag: 1.31.0-rc.0~1704^2 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=782b20762121d2a8070df71213da4676dcfad081;p=lhc%2Fweb%2Fwiklou.git Switch DifferenceEngine to the new shell framework Change-Id: Iad8718e5f54ed829efded8efbb0f3496c119e6ad --- diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index a9d6ad69d4..899054d6c4 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -21,6 +21,7 @@ * @ingroup DifferenceEngine */ use MediaWiki\MediaWikiServices; +use MediaWiki\Shell\Shell; /** @deprecated use class constant instead */ define( 'MW_DIFF_VERSION', '1.11a' ); @@ -966,8 +967,16 @@ class DifferenceEngine extends ContextSource { fwrite( $tempFile2, $ntext ); fclose( $tempFile1 ); fclose( $tempFile2 ); - $cmd = wfEscapeShellArg( $wgExternalDiffEngine, $tempName1, $tempName2 ); - $difftext = wfShellExec( $cmd ); + $cmd = [ $wgExternalDiffEngine, $tempName1, $tempName2 ]; + $result = Shell::command( $cmd ) + ->execute(); + $exitCode = $result->getExitCode(); + if ( $exitCode !== 0 ) { + throw new Exception( "External diff command returned code {$exitCode}. Stderr: " + . wfEscapeWikiText( $result->getStderr() ) + ); + } + $difftext = $result->getStdout(); $difftext .= $this->debug( "external $wgExternalDiffEngine" ); unlink( $tempName1 ); unlink( $tempName2 );