- $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();