Page MenuHomePhabricator

Allowing merging when external diff3 is unavailable
Open, LowestPublicFeature

Description

Author: furrykef

Description:
Patch to GlobalFunctions.php (1.16.0 version) to allow use of PEAR's Text_Diff_ThreeWay class

Some hosts, especially shared hosts such as nearlyfreespeech.net, support MediaWiki, but do not support calling external programs such as diff3. The current behavior when diff3 is unavailable is to fall back on the old behavior of signaling a conflict edit whenever two people edit the same page, even if they edit completely different parts of the page using section edits. This can also happen with one user and multiple browser tabs -- I've been bitten this way, and it's a bit annoying. Hence, I've developed a proof-of-concept patch for using PEAR's Text_Diff_ThreeWay class when $wgDiff3 is empty. (The patch is for includes/GlobalFunctions.php in 1.16.0 sources, because that's the version I tested it on.)

There are some problems with the patch in its current incarnation.

  • It uses PEAR, whereas, if I'm not mistaken, no other MediaWiki code uses PEAR. (However, there's still no dependency on PEAR if you do use an external diff3, and you can still fall back on the current behavior if PEAR is not available.)
  • The code misuses the Text_Diff_ThreeWay class by reading one of its private variables (to check if there were any conflicts). There are no current practical workarounds that I can find.
  • Very minor: The code could stop when it finds the first conflict, since that already invalidates the merge, but instead continues processing the entire text block. (I imagine the behavior with an external diff3 is similar, but hey, an optimization is an optimization.)
  • The inputs need to be exploded (using PHP's explode() function) into multiple strings (one per line) and the output needs to be imploded into one string afterward, which is inefficient.

All of these can be resolved by adapting the library's source (which is LGPL) into MediaWiki itself and modifying it as necessary (though fixing the last may be nontrivial; I haven't checked), but I thought I'd rather float the idea here before trying it. (Also, if somebody wants to volunteer to do this for me, by all means... ;))


Version: unspecified
Severity: enhancement

attachment GlobalFunctions.php-pear-diff3.patch ignored as obsolete

Details

Reference
bz25598

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:11 PM
bzimport set Reference to bz25598.
bzimport added a subscriber: Unknown Object (MLST).

sumanah wrote:

Kef, I'm so sorry it's taken so long for someone to look at your patch! Does the annoying behavior (when diff3 is unavailable) still happen with MediaWiki 1.17.0? And could you quickly check whether there are a lot of merge conflicts if you try it against MediaWiki trunk in Subversion?

Thank you for your patch and for contributing to MediaWiki.

furrykef wrote:

Actually, I've since found issues with the patch. Sometimes it prints a lot of warnings, like when two people edit the same section at the same time (or one person edits the same section twice at the same time using two tabs or windows), or when undoing edits.

In any case, I'm moving my wikis to a VPS, where such a patch is no longer necessary, so I don't have any interest in fixing or maintaining this patch anymore.

Does the annoying behavior (when diff3 is unavailable) still happen with >MediaWiki

yes it does. (We give a warning during install if diff3 is not there.)

Comment on attachment 7742
Patch to GlobalFunctions.php (1.16.0 version) to allow use of PEAR's Text_Diff_ThreeWay class

Marking as obsolete per the author

It might be useable as a base for someone to work on in future, but if it's got known issues, it's not a good thing to be adding as "supported" if it doesn't work correctly

Aklapper lowered the priority of this task from Medium to Lowest.Aug 10 2019, 2:27 PM
Aklapper removed a subscriber: wikibugs-l-list.
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:02 AM