From: Joey Hess <joey@kodama.kitenet.net>
Date: Wed, 31 Oct 2007 02:50:44 +0000 (-0400)
Subject: * Fix an aggregate plugin expiry bug. Over time, it's possible for the same
X-Git-Tag: 2.12~77
X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/5cbd86235e7993cc067b76105b9ed2e4fbdda3a1?ds=inline;hp=--cc

* Fix an aggregate plugin expiry bug. Over time, it's possible for the same
  page name to be expired and reused for several distinct guids. When this
  happened, the expiry code counted each past guid that had used that page
  name as a currently existing page, and thus expired too many pages.
---

5cbd86235e7993cc067b76105b9ed2e4fbdda3a1
diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm
index 6f9c78075..1add53987 100644
--- a/IkiWiki/Plugin/aggregate.pm
+++ b/IkiWiki/Plugin/aggregate.pm
@@ -220,9 +220,11 @@ sub expire () { #{{{
 	foreach my $feed (values %feeds) {
 		next unless $feed->{expireage} || $feed->{expirecount};
 		my $count=0;
+		my %seen;
 		foreach my $item (sort { $IkiWiki::pagectime{$b->{page}} <=> $IkiWiki::pagectime{$a->{page}} }
-		                  grep { exists $_->{page} && $_->{feed} eq $feed->{name} && $IkiWiki::pagectime{$_->{page}} }
+		                  grep { exists $_->{page} && ! exists $seen{$_->{page}} && $_->{feed} eq $feed->{name} && $IkiWiki::pagectime{$_->{page}} }
 		                  values %guids) {
+			$seen{$item}=1;
 			if ($feed->{expireage}) {
 				my $days_old = (time - $IkiWiki::pagectime{$item->{page}}) / 60 / 60 / 24;
 				if ($days_old > $feed->{expireage}) {
diff --git a/debian/changelog b/debian/changelog
index 9684a02d5..3817f142a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,12 @@
 ikiwiki (2.12) UNRELEASED; urgency=low
 
   * Fix some issues with toggles in preview mode.
+  * Fix an aggregate plugin expiry bug. Over time, it's possible for the same
+    page name to be expired and reused for several distinct guids. When this
+    happened, the expiry code counted each past guid that had used that page
+    name as a currently existing page, and thus expired too many pages.
 
- -- Joey Hess <joeyh@debian.org>  Mon, 29 Oct 2007 17:15:04 -0400
+ -- Joey Hess <joeyh@debian.org>  Tue, 30 Oct 2007 22:47:36 -0400
 
 ikiwiki (2.11) unstable; urgency=low