Subject: | Demos fail spectacularly on Catalyst 5.80 if plugins have new methods... |
Hiya.
Looking at examples/demo/server.pl, the entire DemoApp package is
included in the script.
This has the unfortunate side effect that with Catalyst 5.80, the chunk
of code beginning with the comment 'Make sure that the application class
becomes immutable at this point' never gets run.
This causes you to not get a Moose constructor (therefore getting the
Class::Accessor::Fast one, which doesn't fill attribute defaults. This
results in the error:
[error] Caught exception in engine "Can't use an undefined value as an
ARRAY reference at /Users/t0m/perl5/lib/perl5/Catalyst.pm line 1584."
As $c->state is never initialized.
There are three possible fixes for this:
1) Move DemoApp out into its own package (I guess you don't want to do
this).
2) Test if the app is a Catalyst 5.80 app and force constructor inlining
yourself. ( __PACKAGE__->meta->make_immutable(replace_constructor => 1)
if __PACKAGE__->can('meta') )
3) Just put the entire decleration of DemoApp inside a BEGIN { block,
which causes the end of scope hook used by Catalyst to correctly fire
and replace constructors _if_ needed..
Hope this explantion / solutions help!
Note, this is related to:
http://search.cpan.org/~flora/Catalyst-Runtime-5.80014/lib/Catalyst/Test.pm#INLINE_TESTS_WILL_NO_LONGER_WORK
Cheers
t0m