Forráskód Böngészése

fix issue with open dirhandle on undef

George Baugh 3 éve
szülő
commit
6c597094c1
1 módosított fájl, 3 hozzáadás és 2 törlés
  1. 3 2
      lib/Trog/Routes/HTML.pm

+ 3 - 2
lib/Trog/Routes/HTML.pm

@@ -880,8 +880,8 @@ sub posts ($query, $render_cb, $direct=0) {
     $footer = _pick_processor('templates/footers/'.$query->{primary_post}{footer}, $processor,$t_processor)->render('footers/'.$query->{primary_post}{footer}, { theme_dir => $td } ) if $query->{primary_post}{footer};
 
     # List the available headers/footers
-    my $headers = _templates_in_dir($theme_dir ? "www/$theme_dir/templates/headers" : "www/templates/headers");
-    my $footers = _templates_in_dir($theme_dir ? "www/$theme_dir/templates/footers" : "www/templates/footers");
+    my $headers = _templates_in_dir(-d $theme_dir ? "www/$theme_dir/templates/headers" : "www/templates/headers");
+    my $footers = _templates_in_dir(-d $theme_dir ? "www/$theme_dir/templates/footers" : "www/templates/footers");
 
     my $styles = _build_themed_styles('posts.css');
 
@@ -980,6 +980,7 @@ sub posts ($query, $render_cb, $direct=0) {
 
 sub _templates_in_dir($path) {
     my $forms = [];
+    return $forms unless -d $path;
     opendir(my $dh, $path);
     while (my $form = readdir($dh)) {
         push(@$forms, $form) if -f "$path/$form" && $form =~ m/.*\.tx$/;