Last modified: 2009-10-28 18:21:08 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T19812, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 17812 - Diff failed for minimal test case.
Diff failed for minimal test case.
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
History/Diffs (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: testme
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-03-06 04:12 UTC by Filipe Giusti
Modified: 2009-10-28 18:21 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Filipe Giusti 2009-03-06 04:12:52 UTC
I take just the diff engine code to use on my app, then I got a minimal simple case where the diff engine fails.
There is a try using the visual diff comparison algorithm, and below some code from my app that replicates the bug, you should be able to run the unit test case just adjusting the "requires" path.

http://test.wikipedia.org/w/index.php?title=Sandbox&htmldiff=Visual+comparison&diff=68746&oldid=68745

======================================== Code File
<?php

require_once('mediawiki/HTMLDiff.php');
require_once('mediawiki/Diff.php');
require_once('mediawiki/Nodes.php');
require_once('mediawiki/Xml.php');
require_once('mediawiki/Sanitizer.php');

/* <hack> */
/* I have no words to describe my love for global functions -
and for people who rely on this kind of stuff, for sure */
function wfProfileIn($arg) {}
function wfProfileOut($arg) {}
function wfMsgExt($arg) {}
function wfEmptyMsg($arg) {}
/* </hack> */

class MyDelegate{
    var $html = '';

    function addHtml($html) {
        $this->html .= $html;
    }
}

class ContentDiff {
	function diff($old, $new) {
	    $my_delegate = new MyDelegate();
	    $differ = new HTMLDiffer(new DelegatingContentHandler($my_delegate));
        $differ->htmlDiff($old, $new);
        return $my_delegate->html;
	}
}

?>

======================================== Test File
<?php
require_once 'PHPUnit/Framework.php';

require_once 'php/ContentDiff.php';

class ContentDiffTest extends PHPUnit_Framework_TestCase {
    public function test_scaring_bug() {
		$diff = new ContentDiff();

    	$html1 = "<p>teste</p><p><b>I came from the pampas</b></p>";
        $html2 = "<p>teste</p><p><b>And Im a jedi!</b></p>";

        $expected = "<p>teste</p>";
        $expected .= "<p><b>";
        $expected .= '<span class="diff-html-removed" id="removed-htmldiff-0">I came from the pampas</span>';
        $expected .= '<span class="diff-html-added" id="added-htmldiff-0">And Im a jedi!</span>';
        $expected .= "</b></p>";
        
        $this->assertEquals($expected, $diff->diff($html1, $html2));
    }
}
?>

===========================================

Got string		<p>teste<b><span class="diff-html-removed" id="removed-htmldiff-0">I came from the pampas</span></b></p><p><b><span class="diff-html-added" id="added-htmldiff-0">And Im a jedi!</span></b></p>
Comment 1 Chad H. 2009-03-06 19:35:18 UTC
HTMLDiff is very experimental and is disabled by default, I wouldn't recommend using it for anything.
Comment 2 Chad H. 2009-10-28 18:21:08 UTC
Removed by bug 19859 and r58267.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links