diff options
author | Joey Hess <joey@kitenet.net> | 2010-05-07 13:59:08 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-05-07 14:02:30 -0400 |
commit | b50b549cabc8695959628bee10e015d2dcbb2e95 (patch) | |
tree | 396a9cbac5b9422fed0fa3d159cc6d2712819dce /IkiWiki | |
parent | fe8f4a77818f835aaaeb3784ca954e9ae96b4709 (diff) | |
download | ikiwiki-b50b549cabc8695959628bee10e015d2dcbb2e95.tar ikiwiki-b50b549cabc8695959628bee10e015d2dcbb2e95.tar.gz |
fix comment matching pagespecs
test isinternal first, because match_glob with internal => 1 also returns
non-internal pages that match. This order should also be faster.
Remove test to see if pagesources is set. isinternal will not succeed if it
is not.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/comments.pm | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 5d7176a8c..348d91fd8 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -904,28 +904,30 @@ sub match_comment ($$;@) { my $page = shift; my $glob = shift; - my $match=match_glob($page, "$glob/*", internal => 1, @_); - if ($match && exists $IkiWiki::pagesources{$page}) { - my $type=IkiWiki::pagetype($IkiWiki::pagesources{$page}); - if (defined $type && $type ne "_comment") { - return IkiWiki::FailReason->new("$page is not a comment"); - } + if (! IkiWiki::isinternal($page)) { + return IkiWiki::FailReason->new("$page is not a comment"); + } + my $type=IkiWiki::pagetype($IkiWiki::pagesources{$page}); + if (defined $type && $type ne "_comment") { + return IkiWiki::FailReason->new("$page is not a comment"); } - return $match; + + return match_glob($page, "$glob/*", internal => 1, @_); } sub match_comment_pending ($$;@) { my $page = shift; my $glob = shift; - - my $match=match_glob($page, "$glob/*", internal => 1, @_); - if ($match && $IkiWiki::pagesources{$page}) { - my $type=IkiWiki::pagetype($IkiWiki::pagesources{$page}); - if (defined $type && $type ne "_comment_pending") { - return IkiWiki::FailReason->new("$page is not a pending comment"); - } + + if (! IkiWiki::isinternal($page)) { + return IkiWiki::FailReason->new("$page is not a pending comment"); } - return $match; + my $type=IkiWiki::pagetype($IkiWiki::pagesources{$page}); + if (defined $type && $type ne "_comment_pending") { + return IkiWiki::FailReason->new("$page is not a pending comment"); + } + + return match_glob($page, "$glob/*", internal => 1, @_); } 1 |