}
public function showDiffPage( $diffOnly = false ) {
- wfProfileIn( __METHOD__ );
# Allow frames except in certain special cases
$out = $this->getOutput();
if ( !$this->loadRevisionData() ) {
$this->showMissingRevision();
- wfProfileOut( __METHOD__ );
return;
}
$this->mOldPage->getUserPermissionsErrors( 'read', $user ) );
}
if ( count( $permErrors ) ) {
- wfProfileOut( __METHOD__ );
throw new PermissionsError( 'read', $permErrors );
}
$this->renderNewRevision();
}
}
- wfProfileOut( __METHOD__ );
}
/**
* Show the new revision of the page.
*/
public function renderNewRevision() {
- wfProfileIn( __METHOD__ );
$out = $this->getOutput();
$revHeader = $this->getRevisionHeader( $this->mNewRev );
# Add "current version as of X" title
# Add redundant patrol link on bottom...
$out->addHTML( $this->markPatrolledLink() );
- wfProfileOut( __METHOD__ );
}
protected function getParserOutput( WikiPage $page, Revision $rev ) {
*/
public function getDiffBody() {
global $wgMemc;
- wfProfileIn( __METHOD__ );
$this->mCacheHit = true;
// Check if the diff should be hidden from this user
if ( !$this->loadRevisionData() ) {
- wfProfileOut( __METHOD__ );
return false;
} elseif ( $this->mOldRev &&
!$this->mOldRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
) {
- wfProfileOut( __METHOD__ );
return false;
} elseif ( $this->mNewRev &&
!$this->mNewRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
) {
- wfProfileOut( __METHOD__ );
return false;
}
if ( $this->mOldRev === false || ( $this->mOldRev && $this->mNewRev
&& $this->mOldRev->getID() == $this->mNewRev->getID() )
) {
- wfProfileOut( __METHOD__ );
return '';
}
wfIncrStats( 'diff_cache_hit' );
$difftext = $this->localiseLineNumbers( $difftext );
$difftext .= "\n<!-- diff cache key $key -->\n";
- wfProfileOut( __METHOD__ );
return $difftext;
}
// Loadtext is permission safe, this just clears out the diff
if ( !$this->loadText() ) {
- wfProfileOut( __METHOD__ );
return false;
}
if ( $difftext !== false ) {
$difftext = $this->localiseLineNumbers( $difftext );
}
- wfProfileOut( __METHOD__ );
return $difftext;
}
public function generateTextDiffBody( $otext, $ntext ) {
global $wgExternalDiffEngine, $wgContLang;
- wfProfileIn( __METHOD__ );
-
$otext = str_replace( "\r\n", "\n", $otext );
$ntext = str_replace( "\r\n", "\n", $ntext );
# input text to be HTML-escaped already
$otext = htmlspecialchars( $wgContLang->segmentForDiff( $otext ) );
$ntext = htmlspecialchars( $wgContLang->segmentForDiff( $ntext ) );
- wfProfileOut( __METHOD__ );
return $wgContLang->unsegmentForDiff( wikidiff_do_diff( $otext, $ntext, 2 ) ) .
$this->debug( 'wikidiff1' );
if ( $wgExternalDiffEngine == 'wikidiff2' && function_exists( 'wikidiff2_do_diff' ) ) {
# Better external diff engine, the 2 may some day be dropped
# This one does the escaping and segmenting itself
- wfProfileIn( 'wikidiff2_do_diff' );
$text = wikidiff2_do_diff( $otext, $ntext, 2 );
$text .= $this->debug( 'wikidiff2' );
- wfProfileOut( 'wikidiff2_do_diff' );
- wfProfileOut( __METHOD__ );
return $text;
}
$tempFile1 = fopen( $tempName1, "w" );
if ( !$tempFile1 ) {
- wfProfileOut( __METHOD__ );
return false;
}
$tempFile2 = fopen( $tempName2, "w" );
if ( !$tempFile2 ) {
- wfProfileOut( __METHOD__ );
return false;
}
fclose( $tempFile1 );
fclose( $tempFile2 );
$cmd = wfEscapeShellArg( $wgExternalDiffEngine, $tempName1, $tempName2 );
- wfProfileIn( __METHOD__ . "-shellexec" );
$difftext = wfShellExec( $cmd );
$difftext .= $this->debug( "external $wgExternalDiffEngine" );
- wfProfileOut( __METHOD__ . "-shellexec" );
unlink( $tempName1 );
unlink( $tempName2 );
- wfProfileOut( __METHOD__ );
return $difftext;
}
$nta = explode( "\n", $wgContLang->segmentForDiff( $ntext ) );
$diffs = new Diff( $ota, $nta );
$formatter = new TableDiffFormatter();
- $difftext = $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) ) .
- wfProfileOut( __METHOD__ );
+ $difftext = $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) );
return $difftext;
}