3 1. Add the backlinkbug plugin below to ikiwiki.
4 2. Create a page named test.mdwn somewhere in the wiki.
5 3. Refresh ikiwiki in verbose mode. Pages whose bestlink is the test.mwdn page will be printed to the terminal.
7 5. Refresh ikiwiki in verbose mode again. The same pages will be printed to the terminal again.
8 6. Refresh ikiwiki in verbose mode another time. Now no pages will be printed.
10 bestlink() checks %links (and %pagecase) to confirm the existance of the page.
11 However, find_del_files() does not remove the deleted page from %links (and %pagecase).
13 Since find_del_files removes the deleted page from %pagesources and %destsources,
14 won't it make sense for bestlink() to check %pagesources first? --[[harishcm]]
16 > This same problem turned out to also be the root of half of ikiwiki's
17 > second-oldest bug, [[bestlink_change_update_issue]].
19 > Fixing it is really a bit involved, see commit
20 > f1ddf4bd98821a597d8fa1532092f09d3d9b5483. The fix I committed fixes
21 > bestlink to not return deleted pages, but only *after* the needsbuild and
22 > scan hooks are called. So I was able to fix it for every case except the
23 > one you gave! Sorry for that. To fix it during beedsbuild and scan,
24 > a much more involved approach would be needed. AFAICS, no existing plugin
25 > in ikiwiki uses bestlink in needsbuild or scan though.
27 > If the other half of [[bestlink_change_update_issue]] is fixed,
28 > maybe by keeping a copy of the old backlinks info, then that fix could be
29 > applied here too. --[[Joey]]
34 # Plugin to reproduce bestlink returning deleted pages.
35 # Run with ikiwiki in verbose mode.
37 package IkiWiki::Plugin::bestlinkbug;
44 hook(type => "getsetup", id => "bestlinkbug", call => \&getsetup);
45 hook(type => "needsbuild", id => "bestlinkbug", call => \&needsbuild);
59 foreach my $page (keys %pagestate) {
60 my $testpage=bestlink($page, "test") || next;