Stop relying on Package::Stash PP bugs
Florian Ragwitz [Mon, 3 Jan 2011 19:59:37 +0000 (19:59 +0000)]
We want to know if $MyApp::_config contains something like a valid
configuration, not if the package symbol exists.

The pure-perl version Package::Stash has always been buggy in assuming that a
scalar symbol containing undef is a symbol that doesn't exist. This is to work
around the fact that getting the SCALAR slot from a glob in pure perl
autovivifies the scalar to undef. Package::Stash::XS doesn't have that
limitation and is used transparently by Package::Stash if it's installed. That
exposed this bug in our code.

lib/Catalyst/Component.pm

index 28da155..d428826 100644 (file)
@@ -127,7 +127,7 @@ sub config {
         # TODO maybe this should be a ClassData option?
         my $class = blessed($self) || $self;
         my $meta = Class::MOP::get_metaclass_by_name($class);
-        unless ($meta->has_package_symbol('$_config')) {
+        unless (${ $meta->get_package_symbol('$_config') }) {
             # Call merge_hashes to ensure we deep copy the parent
             # config onto the subclass
             $self->_config( Catalyst::Utils::merge_hashes($config, {}) );