1 =head1 Upgrading to Catalyst 5.80
3 Most applications and plugins should run unaltered on Catalyst 5.80.
5 However as a lot of refactoring work has taken place, several changes have
6 been made which could cause incompatibilities, if your application or plugin
7 is using deprecated code, or relying on side-effects then there could be
10 Most issues found with pre-existing components have been easy to solve, and a
11 complete description of behavior changes which may cause compatibility issues,
12 or warnings to be emitted is included below to help if you have problems.
14 If you think you have found an upgrade related issue which is not covered in
15 this document, then please email the Catalyst list to discuss the problem.
17 =head1 Known backwards compatibility breakages.
19 =head2 Components which inherit from Moose::Object before Catalyst::Component
21 Moose components which say:
23 package TestApp::Controller::Example;
25 extends qw/Moose::Object Catalyst::Component/;
27 to use the constructor provided by Moose, whilst working if you do some hacks
28 with the C< BUILDARGS > method, will not work with Catalyst 5.80 as
29 C<Catalyst::Component> inherits from C<Moose::Object>, and so C< @ISA > fails
32 The fix for this, is to not inherit directly from C<Moose::Object>
33 yourself. Having components which do not inherit their constructor from
34 C<Catalyst::Component> is B<unsupported>, and has never been recommended,
35 therefore you're on your own if you're using this technique. You'll need
36 to detect the version of Catalyst your application is running with and deal
37 with it appropriately.
39 You will also see this issue if you do the following:
41 package TestApp::Controller::Example;
43 use base 'Catalyst::Controller';
45 as C< use base > appends to @ISA.
47 The correct way to use Moose in a component in a both forward and backwards
50 package TestApp::Controller::Root;
52 BEGIN { extends 'Catalyst::Component' }; # Or ::Controller, or whatever
54 Note that the C< extends > decleration needs to occur in a begin block for
55 L<attributes> to operate correctly.
57 =head3 use Moose in MyApp
59 Similar to the above, this will also fail:
68 If you need to use Moose in your application class (e.g. for method modifiers
69 etc) then the correct technique is:
74 __PACKAGE__->setup(qw/
78 =head2 Anonymous closures installed directly into the symbol table
80 If you have any code which installs anonymous subroutine references directly
81 into the symbol table, you may encounter breakages. The simplest solution is
82 to use L<Sub::Name> to name the subroutine. Example:
84 # Original code, likely to break:
85 my $full_method_name = join('::',$package_name, $method_name);
86 *$full_method_name = sub { ... };
89 use Sub::Name 'subname';
90 my $full_method_name = join('::',$package_name, $method_name);
91 *$full_method_name = subname $full_method_name, sub { ... };
93 Additionally, you can take advantage of Catalysts use of L<Class::MOP> and
94 install the closure using the appropriate metaclass. Example:
97 my $metaclass = Moose::Meta::Class->initialize($package_name);
98 $metaclass->add_method($method_name => sub { ... });
100 =head2 Hooking into application setup
102 To execute code during application startup the following snippet in MyApp.pm
106 my ($class, @args) = @_;
107 $class->NEXT::setup(@args);
108 ... # things to do after the actual setup
111 With Catalyst 5.80 this won't work anymore. Because instead of using NEXT.pm it
112 relies on L<Class::C3::Adopt::NEXT>, which uses plain C3 method resolution.
114 As L<NEXTs|NEXT> hacks to remember what methods have already been called, this
115 causes infinite recursion between MyApp::setup and Catalyst::setup.
117 Moose method modifiers like C<< before|after|around 'setup => sub { ... }; >>
118 also will not operate correctly due to backward compatibility issues with the
119 way plugin setup methods.
121 The right way to do it is this:
123 after setup_finalize => sub {
124 ... # things to do after the actual setup
127 =head2 Components with a new method which returns false
129 Previously, if you had a component which inherited from Catalyst::COMPONENT,
130 but overrode the new method to return false, then your class' configuration
131 would be blessed into a hash on your behalf, and this would be returned from
132 the COMPONENT method.
134 This behaviour makes no sense, and so has been removed. Implementing your own
135 new method in components is B<highly> discouraged, instead, you should inherit
136 the new method from Catalyst::Component, and use Moose's BUILD functionality
137 to perform any construction work necessary for your sub-class.
139 =head2 __PACKAGE__->mk_accessor('meta');
141 Won't work due to a limitation of L<Moose>. This is currently being fixed
144 =head2 Class::Data::Inheritable side effects
146 Previously, writing to a class data accessor would copy the accessor method
147 down into your package.
149 This behavior has been removed. Whilst the class data is still stored
150 per-class, it is stored on the metaclass of the class defining the accessor.
152 Therefore anything relying on the side-effect of the accessor being copied down
155 The following example demonstrates the problem:
159 use base qw/Class::Data::Inheritable/;
160 __PACKAGE__->mk_classdata('foo');
165 use base qw/BaseClass/;
168 BaseClass->foo('base class');
169 Child->foo('sub class');
172 isnt(BaseClass->can('foo'), Child->can('foo'));
174 =head2 Extending Catalyst::Request or other classes in an ad-hoc manor using mk_accessors
176 Previously, it was possible to add additional accessors to Catalyst::Request
177 (or other classes) by calling the mk_accessors class method.
179 This is no longer supported - users should make a sub-class of the class whos
180 behavior they would like to change, rather than globally polluting the
183 =head2 Confused multiple inheritance with Catalyst::Component::COMPONENT
187 There is a COMPONENT method resolving after Catalyst::Component
190 This means that one of the packages on the right hand side of
191 Catalyst::Component in your Class' inheritance hierarchy defines a COMPONENT
194 Previously, Catalyst's COMPONENT method would delegate to the method on the
195 right hand side, which could then delegate back again with NEXT. This (as it
196 is insane), is no longer supported, as it makes no sense with C3 method
199 Therefore the correct fix is to re-arrange your class' inheritance hierarchy
200 so that the COMPONENT method you would like to inherit is the first COMPONENT
205 =head2 Methods in Catalyst::Dispatcher
207 The following methods in Catalyst::Dispatcher are both an implementation detail,
208 and also likely to change significantly in the 5.8X release series, and therefore
209 their use is highly deprecated.
217 =item registered_dispatch_types
219 =item method_action_class
227 The first time one of these methods is called, a warning will be emitted:
229 Class $class is calling the deprecated method Catalyst::Dispatcher::$public_method_name,\n"
230 . "this will be removed in Catalyst 5.9X"
232 You should B<NEVER> be calling any of these methods from application code.
234 Plugins authors and maintainers whos plugins currently call these methods
235 should change to using the public API, or, if you do not feel the public API
236 adaquately supports your use-case, please email the development list to
237 discuss what API features you need so that you can be appropriately supported.
239 =head2 require $class was successful but the package is not defined.
241 In this version of Catalyst, if a component is loaded from disk, but no
242 symbols are defined in that component's namespace after it is loaded, this
243 warning will be issued.
245 This is to protect against confusing bugs caused by mis-typing package names.
247 This will become a fatal error in a future version.
249 =head2 $c->plugin method
251 Calling the plugin method is deprecated, and calling it at runtime is B<highly
254 Instead you are recommended to use L< Catalyst::Model::Adaptor > or similar to
255 compose the functionality you need outside of the main application namespace.