From 7aa209f1ce882372590ff032a1a94ad2b977544d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 May 2010 13:28:35 -0400 Subject: [PATCH] Fix a bug that prevented matching deleted comments, and so did not update pages that had contained them. Problem is that by the time rendering calls render_dependent, %pagesources has had deleted files removed from it. So match_comment's lookup of files in there to see if they had the _comment extension failed. I had to introduce a hash that temporarily holds filenames of deleted pages to fix this. Note that unlike comment(), internal() had avoided this pitfall by being defined to match both internal and non-internal pages. --- IkiWiki.pm | 6 +++--- IkiWiki/Plugin/comments.pm | 18 ++++++++++-------- IkiWiki/Render.pm | 1 + debian/changelog | 2 ++ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 699ad13da..0f28801a6 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -12,9 +12,9 @@ use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %pagestate %wikistate %renderedfiles %oldrenderedfiles - %pagesources %destsources %depends %depends_simple @mass_depends - %hooks %forcerebuild %loaded_plugins %typedlinks %oldtypedlinks - %autofiles}; + %pagesources %delpagesources %destsources %depends %depends_simple + @mass_depends %hooks %forcerebuild %loaded_plugins %typedlinks + %oldtypedlinks %autofiles}; use Exporter q{import}; our @EXPORT = qw(hook debug error htmlpage template template_depends diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index eb861d74f..de193bd12 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -908,10 +908,12 @@ sub match_comment ($$;@) { my $page = shift; my $glob = shift; - if (! IkiWiki::isinternal($page)) { - return IkiWiki::FailReason->new("$page is not a comment"); - } - my $type=IkiWiki::pagetype($IkiWiki::pagesources{$page}); + # To see if it's a comment, check the source file type. + # Deal with comments that were just deleted. + my $source=exists $IkiWiki::pagesources{$page} ? + $IkiWiki::pagesources{$page} : + $IkiWiki::delpagesources{$page}; + my $type=IkiWiki::pagetype($source); if (defined $type && $type ne "_comment") { return IkiWiki::FailReason->new("$page is not a comment"); } @@ -923,10 +925,10 @@ sub match_comment_pending ($$;@) { my $page = shift; my $glob = shift; - if (! IkiWiki::isinternal($page)) { - return IkiWiki::FailReason->new("$page is not a pending comment"); - } - my $type=IkiWiki::pagetype($IkiWiki::pagesources{$page}); + my $source=exists $IkiWiki::pagesources{$page} ? + $IkiWiki::pagesources{$page} : + $IkiWiki::delpagesources{$page}; + my $type=IkiWiki::pagetype($source); if (defined $type && $type ne "_comment_pending") { return IkiWiki::FailReason->new("$page is not a pending comment"); } diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 833fcaaff..f9fbc801f 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -442,6 +442,7 @@ sub remove_del (@) { } delete $pagecase{lc $page}; + $delpagesources{$page}=$pagesources{$page}; delete $pagesources{$page}; } } diff --git a/debian/changelog b/debian/changelog index b8939f455..8b5389e88 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ ikiwiki (3.20100516) UNRELEASED; urgency=low * page.tmpl: Accidentially broke po plugin's otherlanguages list styling when modifying for html5; now fixed. + * Fix a bug that prevented matching deleted comments, and so did not update + pages that had contained them. -- Joey Hess Sun, 16 May 2010 00:03:06 -0400 -- 2.26.2