* @ingroup DifferenceEngine
*/
use MediaWiki\MediaWikiServices;
+use MediaWiki\Shell\Shell;
/** @deprecated use class constant instead */
define( 'MW_DIFF_VERSION', '1.11a' );
public function deletedLink( $id ) {
if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
$dbr = wfGetDB( DB_REPLICA );
- $row = $dbr->selectRow( 'archive',
- Revision::selectArchiveFields(),
+ $arQuery = Revision::getArchiveQueryInfo();
+ $row = $dbr->selectRow(
+ $arQuery['tables'],
+ array_merge( $arQuery['fields'], [ 'ar_namespace', 'ar_title' ] ),
[ 'ar_rev_id' => $id ],
- __METHOD__ );
+ __METHOD__,
+ [],
+ $arQuery['joins']
+ );
if ( $row ) {
$rev = Revision::newFromArchiveRow( $row );
$title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
$out->addHTML( "<hr class='diff-hr' id='mw-oldid' />
<h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
# Page content may be handled by a hooked call instead...
- # @codingStandardsIgnoreStart Ignoring long lines.
if ( Hooks::run( 'ArticleContentOnDiff', [ $this, $out ] ) ) {
$this->loadNewText();
$out->setRevisionId( $this->mNewid );
$out->setRevisionTimestamp( $this->mNewRev->getTimestamp() );
$out->setArticleFlag( true );
- if ( !Hooks::run( 'ArticleContentViewCustom', [ $this->mNewContent, $this->mNewPage, $out ] ) ) {
+ if ( !Hooks::run( 'ArticleContentViewCustom',
+ [ $this->mNewContent, $this->mNewPage, $out ] )
+ ) {
// Handled by extension
} else {
// Normal page
# WikiPage::getParserOutput() should not return false, but just in case
if ( $parserOutput ) {
// Allow extensions to change parser output here
- if ( Hooks::run( 'DifferenceEngineRenderRevisionAddParserOutput', [ $this, $out, $parserOutput, $wikiPage ] ) ) {
+ if ( Hooks::run( 'DifferenceEngineRenderRevisionAddParserOutput',
+ [ $this, $out, $parserOutput, $wikiPage ] )
+ ) {
$out->addParserOutput( $parserOutput );
}
}
}
}
- # @codingStandardsIgnoreEnd
// Allow extensions to optionally not show the final patrolled link
if ( Hooks::run( 'DifferenceEngineRenderRevisionShowFinalPatrolLink' ) ) {
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 );