| eab6268c | 07-Jun-2026 |
Andreas Gohr <andi@splitbrain.org> |
fix(changelog): keep out-of-order external edits out of recent changes (#4634)
A detected external edit is recorded both in the page's own changelog and in the global recent-changes feed. When its d
fix(changelog): keep out-of-order external edits out of recent changes (#4634)
A detected external edit is recorded both in the page's own changelog and in the global recent-changes feed. When its date is older than the most recent change already in the global changelog — an old file surfacing after the feed has moved on — appending it placed it at the top of recent changes with an old date, above genuinely newer entries.
writeLogEntry() now delegates the global-feed append to writeGlobalLogEntry(), which skips an external edit whose date predates the global changelog's last-modified time. The entry still lands in the page's own changelog; it is only kept out of the cross-page feed. Normal edits are always appended.
show more ...
|
| 01e8d739 | 25-Apr-2026 |
Andreas Gohr <andi@splitbrain.org> |
refactor(changelog): persist external-edit detection on first read
This addresses the flaky test that makes tests randomly fail (mostly on windows runners).
The flake in common_saveWikiText_test::t
refactor(changelog): persist external-edit detection on first read
This addresses the flaky test that makes tests randomly fail (mostly on windows runners).
The flake in common_saveWikiText_test::test_savesequence5 came from this line in ChangeLog::getCurrentRevisionInfo():
'date' => max($lastRev + 1, time() - 1)
The synthesized "external delete" entry was kept in memory only and only persisted later, when saveWikiText next called detectExternalEdit. That meant the formula was evaluated twice on different ChangeLog instances — once during the test's inspection, and again during the following saveWikiText — and the two evaluations could pick different seconds depending on how long the surrounding I/O took. The test cached the first result in $expectExternal and asserted it against the on-disk entry written during the second call. On the slower Windows runner the second call sometimes crossed a second boundary, producing the off-by-one date mismatch.
The questions I had was, why are we persisting external file deletions (or edits) only when a page is saved when we are obviously already detecting it earlier during the changelog read already?
Instead of recording the external delete at the time a new page is written, it makes sense to record it as soon as we detect it (when the changelog is requested by a user or a bot). This will make the recoded timestamp closer to the actual deletion.
This patch refactors the changelog accordingly, but still tries to be minimal invasive (I think the changelog handling would need much more refactoring, but that's beyond the scope of this change).
To enable proper locking (when logging an external edit and copying the attic file), locking had to be moved to the Changelog class, duplicating some code of io_saveFile.
PageFile::detectExternalEdit() and the deprecated procedural wrapper detectExternalEdit() in inc/common.php are removed. A codesearch.dokuwiki.org check confirmed no plugin calls the method directly; the only external caller of the procedural function is the farmsync plugin, which needs a parallel update.
show more ...
|