Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[ikiwiki] / doc / bugs / bestlink_returns_deleted_pages.mdwn
1 To reproduce: 
2
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.
6 4. Delete test.mdwn.
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.
9
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).
12
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]]
15
16
17 ----
18
19     #!/usr/bin/perl
20     # Plugin to reproduce bestlink returning deleted pages. 
21     # Run with ikiwiki in verbose mode.
22     
23     package IkiWiki::Plugin::bestlinkbug;
24     
25     use warnings;
26     use strict;
27     use IkiWiki 3.00;
28     
29     sub import {
30         hook(type => "getsetup", id => "bestlinkbug", call => \&getsetup);
31         hook(type => "needsbuild", id => "bestlinkbug", call => \&needsbuild);
32     }
33     
34     sub getsetup () {
35         return
36                 plugin => {
37                         safe => 1,
38                         rebuild => 0,
39                 },
40     }
41     
42     sub needsbuild (@) {
43         my $needsbuild=shift;
44         
45         foreach my $page (keys %pagestate) {
46                 my $testpage=bestlink($page, "test") || next;
47                 
48                 debug("$page");
49         }
50     }   
51     
52     1
53
54