Fixing creation of DifferenceEninge
Creation of DifferenceEninge insteances was based on invalid assumptions in several places. Change-Id: Ib67ca893ea53a27d4ac7efd8a9ca0d3b2d93949f
This commit is contained in:
parent
2fb3ee45b5
commit
2bc191889a
7 changed files with 52 additions and 23 deletions
|
|
@ -787,6 +787,8 @@ class Article extends Page {
|
|||
/**
|
||||
* Show a diff page according to current request variables. For use within
|
||||
* Article::view() only, other callers should use the DifferenceEngine class.
|
||||
*
|
||||
* @todo: make protected
|
||||
*/
|
||||
public function showDiffPage() {
|
||||
$request = $this->getContext()->getRequest();
|
||||
|
|
@ -798,7 +800,15 @@ class Article extends Page {
|
|||
$unhide = $request->getInt( 'unhide' ) == 1;
|
||||
$oldid = $this->getOldID();
|
||||
|
||||
$contentHandler = ContentHandler::getForTitle( $this->getTitle() );
|
||||
$rev = $this->getRevisionFetched();
|
||||
|
||||
if ( !$rev ) {
|
||||
$this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' )->text() );
|
||||
$this->getContext()->getOutput()->addWikiMsg( 'difference-missing-revision', $oldid, 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
$contentHandler = $rev->getContentHandler();
|
||||
$de = $contentHandler->createDifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
|
||||
|
||||
// DifferenceEngine directly fetched the revision:
|
||||
|
|
|
|||
|
|
@ -138,14 +138,23 @@ class FeedUtils {
|
|||
$diffText = '';
|
||||
// Don't bother generating the diff if we won't be able to show it
|
||||
if ( $wgFeedDiffCutoff > 0 ) {
|
||||
$contentHandler = ContentHandler::getForTitle( $title );
|
||||
$de = $contentHandler->createDifferenceEngine( $title, $oldid, $newid );
|
||||
$diffText = $de->getDiff(
|
||||
wfMsg( 'previousrevision' ), // hack
|
||||
wfMsg( 'revisionasof',
|
||||
$wgLang->timeanddate( $timestamp ),
|
||||
$wgLang->date( $timestamp ),
|
||||
$wgLang->time( $timestamp ) ) );
|
||||
$rev = Revision::newFromId( $oldid );
|
||||
|
||||
if ( !$rev ) {
|
||||
$diffText = false;
|
||||
} else {
|
||||
$context = clone RequestContext::getMain();
|
||||
$context->setTitle( $title );
|
||||
|
||||
$contentHandler = $rev->getContentHandler();
|
||||
$de = $contentHandler->createDifferenceEngine( $context, $oldid, $newid );
|
||||
$diffText = $de->getDiff(
|
||||
wfMsg( 'previousrevision' ), // hack
|
||||
wfMsg( 'revisionasof',
|
||||
$wgLang->timeanddate( $timestamp ),
|
||||
$wgLang->date( $timestamp ),
|
||||
$wgLang->time( $timestamp ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $wgFeedDiffCutoff <= 0 || ( strlen( $diffText ) > $wgFeedDiffCutoff ) ) {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class RollbackAction extends FormlessAction {
|
|||
$this->getOutput()->returnToMain( false, $this->getTitle() );
|
||||
|
||||
if ( !$request->getBool( 'hidediff', false ) && !$this->getUser()->getBoolOption( 'norollbackdiff', false ) ) {
|
||||
$contentHandler = ContentHandler::getForTitle( $this->getTitle() );
|
||||
$contentHandler = $current->getContentHandler();
|
||||
$de = $contentHandler->createDifferenceEngine( $this->getContext(), $current->getId(), $newId, false, true );
|
||||
$de->showDiff( '', '' );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,14 @@ class ApiComparePages extends ApiBase {
|
|||
$rev1 = $this->revisionOrTitleOrId( $params['fromrev'], $params['fromtitle'], $params['fromid'] );
|
||||
$rev2 = $this->revisionOrTitleOrId( $params['torev'], $params['totitle'], $params['toid'] );
|
||||
|
||||
$contentHandler = ContentHandler::getForModelID( $rev1->getContentModel() );
|
||||
$revision = Revision::newFromId( $rev1 );
|
||||
|
||||
if ( !$revision ) {
|
||||
$this->dieUsage( 'The diff cannot be retrieved, ' .
|
||||
'one revision does not exist or you do not have permission to view it.', 'baddiff' );
|
||||
}
|
||||
|
||||
$contentHandler = $revision->getContentHandler();
|
||||
$de = $contentHandler->createDifferenceEngine( $this->getContext(),
|
||||
$rev1,
|
||||
$rev2,
|
||||
|
|
|
|||
|
|
@ -572,7 +572,7 @@ class ApiQueryRevisions extends ApiQueryBase {
|
|||
$vals['diff'] = array();
|
||||
$context = new DerivativeContext( $this->getContext() );
|
||||
$context->setTitle( $title );
|
||||
$handler = ContentHandler::getForTitle( $title );
|
||||
$handler = $revision->getContentHandler();
|
||||
|
||||
if ( !is_null( $this->difftotext ) ) {
|
||||
$model = $title->getContentModel();
|
||||
|
|
|
|||
|
|
@ -111,15 +111,19 @@ class SpecialComparePages extends SpecialPage {
|
|||
$rev2 = self::revOrTitle( $data['Revision2'], $data['Page2'] );
|
||||
|
||||
if( $rev1 && $rev2 ) {
|
||||
$contentHandler = ContentHandler::getForModelID( $rev1->getContentModel() );
|
||||
$de = $contentHandler->createDifferenceEngine( $form->getContext(),
|
||||
$rev1,
|
||||
$rev2,
|
||||
null, // rcid
|
||||
( $data['Action'] == 'purge' ),
|
||||
( $data['Unhide'] == '1' )
|
||||
);
|
||||
$de->showDiffPage( true );
|
||||
$revision = Revision::newFromId( $rev1 );
|
||||
|
||||
if ( $revision ) { // NOTE: $rev1 was already checked, should exist.
|
||||
$contentHandler = $revision->getContentHandler();
|
||||
$de = $contentHandler->createDifferenceEngine( $form->getContext(),
|
||||
$rev1,
|
||||
$rev2,
|
||||
null, // rcid
|
||||
( $data['Action'] == 'purge' ),
|
||||
( $data['Unhide'] == '1' )
|
||||
);
|
||||
$de->showDiffPage( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -934,8 +934,7 @@ class SpecialUndelete extends SpecialPage {
|
|||
* @return String: HTML
|
||||
*/
|
||||
function showDiff( $previousRev, $currentRev ) {
|
||||
$contentHandler = ContentHandler::getForTitle( $this->getTitle() );
|
||||
$diffEngine = $contentHandler->createDifferenceEngine( $this->getContext() );
|
||||
$diffEngine = $currentRev->getContentHandler()->createDifferenceEngine( $this->getContext() );
|
||||
$diffEngine->showDiffStyle();
|
||||
$this->getOutput()->addHTML(
|
||||
"<div>" .
|
||||
|
|
|
|||
Loading…
Reference in a new issue