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, and 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 you could have
8 issues upgrading to this release.
10 Most issues found with pre-existing components have been easy to solve, and a
11 complete description of behaviour changes which may cause compatibility issues,
12 or warnings which are now 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 > declaration needs to occur in a begin block for
55 L<attributes> to operate correctly. You also don't get the L<Moose::Object>
56 constructor, and therefore attribute initialization will not work as normally
57 expected. If you want to use Moose attributes, then they need to be made lazy
58 to correctly initialize.
60 =head3 use Moose in MyApp
62 Similar to the above, this will also fail:
71 If you need to use Moose in your application class (e.g. for method modifiers
72 etc) then the correct technique is:
77 __PACKAGE__->setup(qw/
81 =head2 Anonymous closures installed directly into the symbol table
83 If you have any code which installs anonymous subroutine references directly
84 into the symbol table, you may encounter breakages. The simplest solution is
85 to use L<Sub::Name> to name the subroutine. Example:
87 # Original code, likely to break:
88 my $full_method_name = join('::', $package_name, $method_name);
89 *$full_method_name = sub { ... };
92 use Sub::Name 'subname';
93 my $full_method_name = join('::',$package_name, $method_name);
94 *$full_method_name = subname $full_method_name, sub { ... };
96 Additionally, you can take advantage of Catalysts use of L<Class::MOP> and
97 install the closure using the appropriate metaclass. Example:
100 my $metaclass = Moose::Meta::Class->initialize($package_name);
101 $metaclass->add_method($method_name => sub { ... });
103 =head2 Hooking into application setup
105 To execute code during application startup the following snippet in MyApp.pm
109 my ($class, @args) = @_;
110 $class->NEXT::setup(@args);
111 ... # things to do after the actual setup
114 With Catalyst 5.80 this won't work anymore. Due to the fact that Catalyst is
115 no longer using NEXT.pm for method resolution, this no longer works. The
116 functionality was only ever originally operational as L<NEXT> remembers what
117 methods have already been called, and will not call them again.
119 Using this now causes infinite recursion between MyApp::setup and
120 Catalyst::setup, due to other backwards compatibility issues related to how
121 plugin setup works. Moose method modifiers like C<< before|after|around 'setup
122 => sub { ... }; >> also will not operate correctly on the setup method.
124 The right way to do it is this:
126 after setup_finalize => sub {
127 ... # things to do after the actual setup
130 The setup_finalize hook was introduced as a way to void this issue.
132 =head2 Components with a new method which returns false
134 Previously, if you had a component which inherited from Catalyst::COMPONENT,
135 but overrode the new method to return false, then your class' configuration
136 would be blessed into a hash on your behalf, and this would be returned from
137 the COMPONENT method.
139 This behaviour makes no sense, and so has been removed. Implementing your own
140 C< new > method in components is B<highly> discouraged, instead, you should
141 inherit the new method from Catalyst::Component, and use Mooses BUILD
142 functionality and/or Moose attributes to perform any construction work
143 necessary for your class.
145 =head2 __PACKAGE__->mk_accessor('meta');
147 Won't work due to a limitation of L<Moose>. This is currently being fixed
150 =head2 Class::Data::Inheritable side effects
152 Previously, writing to a class data accessor would copy the accessor method
153 down into your package.
155 This behaviour has been removed. Whilst the class data is still stored
156 per-class, it is stored on the metaclass of the class defining the accessor.
158 Therefore anything relying on the side-effect of the accessor being copied down
161 The following test demonstrates the problem:
165 use base qw/Class::Data::Inheritable/;
166 __PACKAGE__->mk_classdata('foo');
171 use base qw/BaseClass/;
174 BaseClass->foo('base class');
175 Child->foo('sub class');
178 isnt(BaseClass->can('foo'), Child->can('foo'));
180 =head2 Extending Catalyst::Request or other classes in an ad-hoc manor using mk_accessors
182 Previously, it was possible to add additional accessors to Catalyst::Request
183 (or other classes) by calling the mk_accessors class method.
185 This is no longer supported - users should make a sub-class of the class whose
186 behaviour they would like to change, rather than globally polluting the
189 =head2 Confused multiple inheritance with Catalyst::Component::COMPONENT
191 Previously, Catalyst's COMPONENT method would delegate to the method on the
192 right hand side, which could then delegate back again with NEXT. This (as it
193 is insane AND makes no sense with C3 method dispatch order), and is therefore
196 If a COMPONENT method is detected in the inheritance hierarchy to the right
197 hand side of Catalyst::Component::COMPONENT, then the following warning
198 message will be emitted:
200 There is a COMPONENT method resolving after Catalyst::Component
203 The correct fix is to re-arrange your class' inheritance hierarchy so that the
204 COMPONENT method you would like to inherit is the first (left-hand most)
205 COMPONENT method in your @ISA.
209 =head2 Methods in Catalyst::Dispatcher
211 The following methods in Catalyst::Dispatcher are both an implementation
212 detail, which may change in the 5.8X release series, and therefore their use
213 is highly deprecated.
221 =item registered_dispatch_types
223 =item method_action_class
231 The first time one of these methods is called, a warning will be emitted:
233 Class $class is calling the deprecated method Catalyst::Dispatcher::$public_method_name,
234 this will be removed in Catalyst 5.9X
236 You should B<NEVER> be calling any of these methods from application code.
238 Plugins authors and maintainers whose plugins currently call these methods
239 should change to using the public API, or, if you do not feel the public API
240 adequately supports your use-case, please email the development list to
241 discuss what API features you need so that you can be appropriately supported.
243 =head2 Class naming to packages defined does not correspond.
245 In this version of Catalyst, if a component is loaded from disk, but no
246 symbols are defined in that component's name space after it is loaded, this
247 warning will be issued:
249 require $class was successful but the package is not defined.
251 This is to protect against confusing bugs caused by mis-typing package names,
252 and will become a fatal error in a future version.
254 Please note that 'inner packages' (via L<Devel::InnerPackage>) are still fully
255 supported, this warning is only issued when component file naming does not map
256 to B<any> of the packages defined within that component.
258 =head2 $c->plugin method
260 Calling the plugin method is deprecated, and calling it at runtime is B<highly
263 Instead you are recommended to use L< Catalyst::Model::Adaptor > or similar to
264 compose the functionality you need outside of the main application name space.
266 Calling the plugin method at runtime will not be supported past Catalyst 5.81.