From: Joey Hess <joey@kitenet.net>
Date: Sat, 20 Nov 2010 18:54:43 +0000 (-0400)
Subject: edittemplate: Fix crash if using a .tmpl file or other non-page file as a template... 
X-Git-Tag: 3.20101129~34
X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/31f0e459b8143cd986f04d122d255f4d0f44a505?ds=inline;hp=--cc

edittemplate: Fix crash if using a .tmpl file or other non-page file as a template for a new page.
---

31f0e459b8143cd986f04d122d255f4d0f44a505
diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm
index 576c94be4..061242fd8 100644
--- a/IkiWiki/Plugin/edittemplate.pm
+++ b/IkiWiki/Plugin/edittemplate.pm
@@ -107,9 +107,11 @@ sub formbuilder (@) {
 						my $template=$pagestate{$registering_page}{edittemplate}{$pagespec};
 						$form->field(name => "editcontent",
 							 value =>  filltemplate($template, $page));
-						$form->field(name => "type",
-							 value => pagetype($pagesources{$template}))
+						my $type=pagetype($pagesources{$template})
 								if $pagesources{$template};
+						$form->field(name => "type",
+							 value => $type)
+								if defined $type;
 						return;
 					}
 				}
diff --git a/debian/changelog b/debian/changelog
index ecd028a0c..d236361d2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,8 @@ ikiwiki (3.20101113) UNRELEASED; urgency=low
   * Optimise glob() pagespec. (Thanks, Kathryn and smcv)
   * highlight: Support new format of filetypes.conf used by version 3.2
     of the highlight package.
+  * edittemplate: Fix crash if using a .tmpl file or other non-page file
+    as a template for a new page.
 
  -- Joey Hess <joeyh@debian.org>  Tue, 16 Nov 2010 14:23:47 -0400