* @ingroup DifferenceEngine
*/
use MediaWiki\MediaWikiServices;
+use MediaWiki\Shell\Shell;
/** @deprecated use class constant instead */
define( 'MW_DIFF_VERSION', '1.11a' );
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 );