fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-11-03 10:33 am

[dw-free] Warnings in the logs when user has a custom theme

[commit: http://hg.dwscoalition.org/dw-free/rev/dffe08acd2e0]

http://bugs.dwscoalition.org/show_bug.cgi?id=3197

Initialize just to avoid warnings; avoid unnecessary check when there's no
theme to init anyway.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/LJ/S2Theme.pm
--------------------------------------------------------------------------------
diff -r e3dcc8f71fbf -r dffe08acd2e0 cgi-bin/LJ/S2Theme.pm
--- a/cgi-bin/LJ/S2Theme.pm	Wed Nov 03 15:10:39 2010 +0800
+++ b/cgi-bin/LJ/S2Theme.pm	Wed Nov 03 18:33:10 2010 +0800
@@ -459,9 +459,11 @@ sub new {
 
     # package name for the theme
     my $theme_class = $self->{uniq};
-    $theme_class =~ s/-/_/g;
-    $theme_class =~ s/\//::/;
-    $theme_class = "LJ::S2Theme::$theme_class";
+    if ( $theme_class ) {
+        $theme_class =~ s/-/_/g;
+        $theme_class =~ s/\//::/;
+        $theme_class = "LJ::S2Theme::$theme_class";
+    }
 
     # package name for the layout
     my $layout_class = $self->{uniq} || $self->{layout_uniq};
@@ -470,7 +472,7 @@ sub new {
     $layout_class = "LJ::S2Theme::$layout_class";
 
     # make this theme an object of the lowest level class that's defined
-    if (eval { $theme_class->init }) {
+    if ( $theme_class && eval { $theme_class->init } ) {
         bless $self, $theme_class;
     } elsif (eval { $layout_class->init }) {
         bless $self, $layout_class;
@@ -511,7 +513,7 @@ sub layout_name {
 }
 
 sub uniq {
-    return $_[0]->{uniq};
+    return $_[0]->{uniq} || "";
 }
 
 sub layout_uniq {
--------------------------------------------------------------------------------