# This file documents the revision history for Perl extension Catalyst.
+ - Make MyApp immutable at the end of the scope after the setup
+ method is called, fixing issues with plugins which have their
+ own new methods by inlining a constructor on MyApp (t0m)
+ - Test for this and method modifiers in MyApp (t0m)
- Fix Catalyst::Plugin::Authentication's authentication
plugin backwards compatibility issues by fixing
Class::Data::Inheritable compatibility (t0m)
all_from 'lib/Catalyst/Runtime.pm';
requires 'namespace::clean';
+requires 'B::Hooks::EndOfScope';
requires 'MooseX::Emulate::Class::Accessor::Fast' => '0.00600';
requires 'Moose' => '0.59';
requires 'Carp';
use Class::MOP::Object ();
extends 'Catalyst::Component';
use bytes;
+use B::Hooks::EndOfScope;
use Catalyst::Exception;
use Catalyst::Log;
use Catalyst::Request;
BEGIN { require 5.008001; }
-# FIXME lazy => 1 here makes C::P::Auth tests pass?!?
has stack => (is => 'ro', default => sub { [] });
has stash => (is => 'rw', default => sub { {} });
has state => (is => 'rw', default => 0);
}
$class->log->_flush() if $class->log->can('_flush');
+ # Make sure that the application class becomes immutable at this point,
+ # which ensures that it gets an inlined constructor. This means that it
+ # works even if the user has added a plugin which contains a new method.
+ # Note however that we have to do the work on scope end, so that method
+ # modifiers work correctly in MyApp (as you have to call setup _before_
+ # applying modifiers).
+ on_scope_end {
+ my $meta = $class->Moose::Object::meta();
+ $meta->make_immutable unless $meta->is_immutable;
+ };
+
$class->setup_finished(1);
}
--- /dev/null
+# Test that plugins with their own new method don't break applications.
+
+# 5.70 creates all of the request/response structure itself in prepare,
+# and as the new method in our plugin just blesses our args, that works nicely.
+
+# In 5.80, we rely on the new method to appropriately initialise data
+# structures, and therefore we need to inline a new method on MyApp to ensure
+# that plugins don't get it wrong for us.
+
+# Also tests method modifiers and etc in MyApp.pm still work as expected.
+
+use FindBin;
+use lib "$FindBin::Bin/lib";use Test::More tests => 3;
+
+use Catalyst::Test qw/TestAppPluginWithNewMethod/; # 1 test for adding a modifer not throwing.
+ok request('/foo')->is_success;
+is $TestAppPluginWithNewMethod::MODIFIER_FIRED, 1, 'Before modifier was fired correctly.';