X-Git-Url: https://git.cyclocoop.org/%28%28?a=blobdiff_plain;f=includes%2Fdiff%2FDifferenceEngine.php;h=6a2837b43a0448607e18f45e090dbe7e2966e3c3;hb=50495b4f4e356882dd464685cc6f32b415371233;hp=ed8cbb4ca3c4321f6d3c936c39a7f8e97f906763;hpb=2edc104f99e3960c663b2c0834e88f7df86ad794;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index ed8cbb4ca3..6a2837b43a 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' ); @@ -181,10 +182,15 @@ class DifferenceEngine extends ContextSource { 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 ); @@ -601,14 +607,15 @@ class DifferenceEngine extends ContextSource { $out->addHTML( "

{$revHeader}

\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 @@ -627,13 +634,14 @@ class DifferenceEngine extends ContextSource { # 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' ) ) { @@ -963,8 +971,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 );