]> sipb.mit.edu Git - ikiwiki.git/commitdiff
fix subpage rename bug with indexpages
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 1 Oct 2008 18:43:28 +0000 (14:43 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 1 Oct 2008 18:43:28 +0000 (14:43 -0400)
If indexpages is enabled, then foo/index.mdwn will look like a subpage
of foo, so an additional check is needed to avoid trying to rename it
twice.

IkiWiki/Plugin/rename.pm

index 218cab489b227976c94dd105e0ee8e644b4a60d5..6c131487a3527c46c00b1ce57ca0a15936f04f49 100644 (file)
@@ -292,17 +292,21 @@ sub sessioncgi ($$) { #{{{
                        # See if any subpages need to be renamed.
                        if ($q->param("subpages") && $src ne $dest) {
                                foreach my $p (keys %pagesources) {
-                                       if ($pagesources{$p}=~m/^\Q$src\E\//) {
-                                               my $d=$pagesources{$p};
-                                               $d=~s/^\Q$src\E\//$dest\//;
-                                               push @torename, {
-                                                       src => $p,
-                                                       srcfile => $pagesources{$p},
-                                                       dest => pagename($d),
-                                                       destfile => $d,
-                                                       required => 0,
-                                               };
-                                       }
+                                       next unless $pagesources{$p}=~m/^\Q$src\E\//;
+                                       # If indexpages is enabled, the
+                                       # srcfile should not be confused
+                                       # with a subpage.
+                                       next if $pagesources{$p} eq $srcfile;
+
+                                       my $d=$pagesources{$p};
+                                       $d=~s/^\Q$src\E\//$dest\//;
+                                       push @torename, {
+                                               src => $p,
+                                               srcfile => $pagesources{$p},
+                                               dest => pagename($d),
+                                               destfile => $d,
+                                               required => 0,
+                                       };
                                }
                        }