Learn about DokuWiki
Learn about DokuWiki
Compatible with DokuWiki
If a user starts editing a page and in the meantime another user edits and save the same page, when the first user tries to save its page a conflict arises, as it was changed since the edition started. In DokuWiki, when there is a conflict the user has only two choices: overwrite the latest revision of the page or keep it (losing the changes made by the user).
This plugin makes DokuWiki behave like MediaWiki: when there is a conflict, the conflict is automatically solved (when possible). A conflict can be automatically solved if the changes are independent (for example, one user changes line 1 and another user changes line 3). This plugin also adds the option to not only save or cancel, but also edit again when a conflict is found. See Behaviour section for further information.
To avoid conflicts, DokuWiki has a lock system: when a user starts editing a page, no other user can edit it until the first user frees the page or the lock expires. So only when the lock expires, another user modifies the page and then the first user tries to save it a conflict arises.
In order to let several users to edit the same page at the same time, the lock system must be disabled.
Since 2010-02-16, setting the locktime to 0 in DokuWiki configuration disables the lock system.
In releases previous to that date, two changes must be done in DokuWiki code. The following changes completely disable the lock system. If you want to disable it only when locktime is 0, just do the same changes as shown in the commit linked in the previous paragraph.
First, in common/inc.php, modify function checklock($id) to always return false. Doing this, DokuWiki will think that no page is locked, letting other users to edit it even if someone is already editing it. This can be done also setting the locktime in the configuration to 0.
Second, in lib/exe/js.php, comment line js_runonstart(“locktimer.init…. This will prevent the message warning that the lock is about to expire to show up. This can't be done from the configuration and, in fact, changing the locktime to 0 and not commenting this line will result in a warning message when the user starts to edit a page.
These changes can be seen in the following patch: dokuwiki-2009-12-25c.patch. It can be applied in dokuwiki directory using
patch -p 1 < dokuwiki-2009-12-25c.patch
A conflict appears in edit and save actions when the page was modified after the edit or conflict forms were shown. That is, even if the page is modified again while the user is looking to a conflict form, a new conflict form will appear informing the user about it.
Also, note the following scenario: user A starts editing a page, user B edits and saves the page, and user A saves the page. A conflict form will be shown to user A, as the page was changed while it was being edited. Now, the user A decides to further edit the page.
If the merge was successful, when the user hit save button in the edit form, the text will be directly saved (provided no other user changes the page in the meantime). That is, now the revision to check conflicts against is the revision the text was merged with, instead of the revision of the page when the fresh edition was started.
However, it is different in the case of an unsuccessful merge. In that case, as the contents weren't merged, the revision to check conflicts against is the revision of the page when the fresh edition was started. So even if the text is edited to avoid conflicts, a conflict form will appear, although a successful one. Once a successful merge form appears, the revision to check conflicts against is updated to the latest revision of the page.
This plugin needs the full path to the diff3 executable (note that diff3 is NOT diff). Default value is /usr/bin/diff3.
Windows users can take diff3 in utility pack at http://sourceforge.net/projects/gnuwin32/files/diffutils/2.8.7-1/diffutils-2.8.7-1.exe/download
Note: in Dokuwiki 2012-10-13 (Adora Belle), SimpleTest was replaced with PHPUnit. I will update the tests for this plugin to replace SimpleTest with PHPUnit in the future. For the time being, I am stuck with an old version of the PHPUnit Selenium2 extension that does not provide some features needed for the acceptance tests (although they were implemented in newer versions of the extension). In the meantime, the SimpleTest tests can be used (although, obviously, they need the Dokuwiki test infrastructure from previous versions).
The plugin includes a test directory with unit tests for merge function and acceptance tests for the whole plugin. The tests use the SimpleTest library used for DokuWiki tests (before 2012-05-01). So if your DokuWiki SimpleTest tests are working you shouldn't have any problem to make these work.
You can run them from the main Dokuwiki _test directory with
php runtests.php -f ../lib/plugins/conflictmerger/tests/XXX.test.php
where XXX is either merge or acceptance, depending on which ones you want to run.
Acceptance tests simulate two users editing and saving pages with a web browser. It tests every possible combination I was able to think of. If you want to change the behaviour of the plugin in some situation (for example, directly saving the merged changes like MediaWiki does instead of telling the user before doing it) you may find useful to adapt the tests to the new behaviour before modifying the plugin code to be sure that it works as expected.
Also note that the acceptance tests require DokuWiki to be configured in English (as they expect the Edit this page, Save and Cancel labels in the buttons), and that they create (and delete once they finish) a page called testConflictMerger.
I started to develop this plugin for a DokuWiki installation in a personal project. However, due to preferences of other members in the group a wiki wasn't used in the end, so I stopped to develop the plugin near its completion (it had several bugs).
Recently I had some time and decided to finish it and share it. I added a few acceptance test that were missing and fixed all the bugs, and here it is.
This plugin is the second or third time that I develop something in PHP, and although it passes all the acceptance tests I could think of, I didn't test it in a real wiki. So you may want to review its code first before using it ;)
The plugin is licensed as GPL 2 to be compatible with DokuWiki license (I intended to license it as AGPL3+, but then I saw that it was incompatible with DokuWiki license :( ).
Also note that I have no further development plans, at least in the short term.