Commit | Line | Data |
7e2ec16e |
1 | =head1 Upgrading to Catalyst 5.80 |
2 | |
5687c7f9 |
3 | Most applications and plugins should run unaltered on Catalyst 5.80. |
7e2ec16e |
4 | |
1a98f036 |
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 |
ba03ccca |
8 | issues upgrading to this release. |
5687c7f9 |
9 | |
e11cac87 |
10 | Most issues found with pre-existing components have been easy to solve, and a |
ba03ccca |
11 | complete description of behaviour changes which may cause compatibility issues, |
1a98f036 |
12 | or warnings which are now emitted is included below to help if you have problems. |
7e2ec16e |
13 | |
5687c7f9 |
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. |
7e2ec16e |
16 | |
5687c7f9 |
17 | =head1 Known backwards compatibility breakages. |
7e2ec16e |
18 | |
38f90e49 |
19 | =head2 Issues with Class::C3 |
20 | |
21 | Catalyst 5.80 uses L<Algorithm::C3> method dispatch order. This is built into |
22 | perl 5.10, and comes via L<Class::C3> for perl 5.8. This replaces L<NEXT> |
23 | with L<Class::C3::Adopt::NEXT>, forcing all components to resolve methods using |
24 | C3, rather than the unpredictable dispatch order of L<NEXT>. |
25 | |
26 | To be able to do this, however, entails that the graph of superclasses for each |
27 | class must be linearizable using the C3 algorithm. Unfortunately, when |
28 | superclasses are being used as mixins, it is easy to get this wrong. |
29 | |
30 | Most common is the case of: |
31 | |
32 | package Component1; # Note, this is the common case |
33 | use base qw/Class::Accessor::Fast Class::Data::Inheritable/; |
34 | |
35 | package Component2; # Accidentally saying it this way round causes fail. |
36 | use base qw/Class::Data::Inheritable Class::Accessor::Fast/; |
37 | |
38 | package GoesBang; |
39 | use base qw/Component1 Component2/; |
40 | |
41 | And the Catalyst plugin most often causing this, is |
42 | L<Catalyst::Plugin::Sesssion::Store::FastMMap> - if you are using this plugin |
43 | and see issues, then please upgrade! |
44 | |
45 | This can, however, be found in your own application - the only solution is to |
46 | go through each base class of the class the error was reported against, until |
47 | you identify the ones in conflict, and resolve them. |
48 | |
6f04e56a |
49 | =head2 Components which inherit from Moose::Object before Catalyst::Component |
7e2ec16e |
50 | |
6f04e56a |
51 | Moose components which say: |
7e2ec16e |
52 | |
6f04e56a |
53 | package TestApp::Controller::Example; |
54 | use Moose; |
845bfcd2 |
55 | extends qw/Moose::Object Catalyst::Component/; |
7e2ec16e |
56 | |
1a98f036 |
57 | to use the constructor provided by Moose, whilst working (if you do some hacks |
58 | with the C< BUILDARGS > method), will not work with Catalyst 5.80 as |
6f04e56a |
59 | C<Catalyst::Component> inherits from C<Moose::Object>, and so C< @ISA > fails |
25f61108 |
60 | to linearize. |
6f04e56a |
61 | |
1a98f036 |
62 | The fix for this is to not inherit directly from C<Moose::Object> |
6f04e56a |
63 | yourself. Having components which do not inherit their constructor from |
64 | C<Catalyst::Component> is B<unsupported>, and has never been recommended, |
65 | therefore you're on your own if you're using this technique. You'll need |
66 | to detect the version of Catalyst your application is running with and deal |
67 | with it appropriately. |
7e2ec16e |
68 | |
8566c0de |
69 | You will also see this issue if you do the following: |
70 | |
6f04e56a |
71 | package TestApp::Controller::Example; |
72 | use Moose; |
8566c0de |
73 | use base 'Catalyst::Controller'; |
74 | |
75 | as C< use base > appends to @ISA. |
76 | |
6f04e56a |
77 | The correct way to use Moose in a component in a both forward and backwards |
78 | compatible way is: |
79 | |
80 | package TestApp::Controller::Root; |
81 | use Moose; |
82 | BEGIN { extends 'Catalyst::Component' }; # Or ::Controller, or whatever |
83 | |
ba03ccca |
84 | Note that the C< extends > declaration needs to occur in a begin block for |
3df46b1b |
85 | L<attributes> to operate correctly. |
86 | |
87 | You also don't get the L<Moose::Object> constructor, and therefore attribute |
88 | initialization will not work as normally expected. If you want to use Moose |
89 | attributes, then they need to be made lazy to correctly initialize. |
90 | |
91 | Note that this only applies if your component needs to maintain component |
92 | backwards compatibility for Catalyst versions before 5.71001 - in 5.71001 |
93 | attributes work as expected, and the BUILD method is called normally |
94 | (although BUILDARGS is not). |
95 | |
96 | If you depend on Catalyst 5.8, then B<all> Moose features work as expected. |
8566c0de |
97 | |
e11cac87 |
98 | =head3 use Moose in MyApp |
99 | |
100 | Similar to the above, this will also fail: |
101 | |
102 | package MyApp; |
103 | use Moose; |
104 | use Catalyst qw/ |
105 | ConfigLoader |
106 | /; |
107 | __PACKAGE__->setup; |
108 | |
109 | If you need to use Moose in your application class (e.g. for method modifiers |
110 | etc) then the correct technique is: |
111 | |
112 | package MyApp; |
113 | use Moose; |
114 | extends 'Catalyst'; |
115 | __PACKAGE__->setup(qw/ |
116 | ConfigLoader |
117 | /); |
118 | |
04a48104 |
119 | =head2 Anonymous closures installed directly into the symbol table |
120 | |
121 | If you have any code which installs anonymous subroutine references directly |
122 | into the symbol table, you may encounter breakages. The simplest solution is |
123 | to use L<Sub::Name> to name the subroutine. Example: |
124 | |
e11cac87 |
125 | # Original code, likely to break: |
1a98f036 |
126 | my $full_method_name = join('::', $package_name, $method_name); |
04a48104 |
127 | *$full_method_name = sub { ... }; |
128 | |
e11cac87 |
129 | # Fixed Code |
04a48104 |
130 | use Sub::Name 'subname'; |
131 | my $full_method_name = join('::',$package_name, $method_name); |
132 | *$full_method_name = subname $full_method_name, sub { ... }; |
133 | |
e11cac87 |
134 | Additionally, you can take advantage of Catalysts use of L<Class::MOP> and |
25f61108 |
135 | install the closure using the appropriate meta class. Example: |
04a48104 |
136 | |
137 | use Class::MOP; |
138 | my $metaclass = Moose::Meta::Class->initialize($package_name); |
139 | $metaclass->add_method($method_name => sub { ... }); |
140 | |
780654ad |
141 | =head2 Hooking into application setup |
142 | |
25f61108 |
143 | To execute code during application start-up the following snippet in MyApp.pm |
780654ad |
144 | used to work: |
145 | |
146 | sub setup { |
147 | my ($class, @args) = @_; |
148 | $class->NEXT::setup(@args); |
149 | ... # things to do after the actual setup |
150 | } |
151 | |
1a98f036 |
152 | With Catalyst 5.80 this won't work anymore. Due to the fact that Catalyst is |
153 | no longer using NEXT.pm for method resolution, this no longer works. The |
154 | functionality was only ever originally operational as L<NEXT> remembers what |
155 | methods have already been called, and will not call them again. |
780654ad |
156 | |
1a98f036 |
157 | Using this now causes infinite recursion between MyApp::setup and |
158 | Catalyst::setup, due to other backwards compatibility issues related to how |
159 | plugin setup works. Moose method modifiers like C<< before|after|around 'setup |
160 | => sub { ... }; >> also will not operate correctly on the setup method. |
780654ad |
161 | |
162 | The right way to do it is this: |
163 | |
164 | after setup_finalize => sub { |
165 | ... # things to do after the actual setup |
166 | }; |
167 | |
ade00972 |
168 | The setup_finalize hook was introduced as a way to avoid this issue. |
1a98f036 |
169 | |
e11cac87 |
170 | =head2 Components with a new method which returns false |
7e2ec16e |
171 | |
8dd2f514 |
172 | Previously, if you had a component which inherited from Catalyst::COMPONENT, |
e11cac87 |
173 | but overrode the new method to return false, then your class' configuration |
8dd2f514 |
174 | would be blessed into a hash on your behalf, and this would be returned from |
a87f5aa5 |
175 | the COMPONENT method. |
7e2ec16e |
176 | |
e11cac87 |
177 | This behaviour makes no sense, and so has been removed. Implementing your own |
1a98f036 |
178 | C< new > method in components is B<highly> discouraged, instead, you should |
179 | inherit the new method from Catalyst::Component, and use Mooses BUILD |
180 | functionality and/or Moose attributes to perform any construction work |
181 | necessary for your class. |
7e2ec16e |
182 | |
183 | =head2 __PACKAGE__->mk_accessor('meta'); |
184 | |
e11cac87 |
185 | Won't work due to a limitation of L<Moose>. This is currently being fixed |
186 | inside Moose. |
7e2ec16e |
187 | |
188 | =head2 Class::Data::Inheritable side effects |
189 | |
8dd2f514 |
190 | Previously, writing to a class data accessor would copy the accessor method |
191 | down into your package. |
192 | |
ba03ccca |
193 | This behaviour has been removed. Whilst the class data is still stored |
8dd2f514 |
194 | per-class, it is stored on the metaclass of the class defining the accessor. |
7e2ec16e |
195 | |
8dd2f514 |
196 | Therefore anything relying on the side-effect of the accessor being copied down |
197 | will be broken. |
7e2ec16e |
198 | |
1a98f036 |
199 | The following test demonstrates the problem: |
8dd2f514 |
200 | |
201 | { |
202 | package BaseClass; |
203 | use base qw/Class::Data::Inheritable/; |
204 | __PACKAGE__->mk_classdata('foo'); |
205 | } |
206 | |
207 | { |
208 | package Child; |
209 | use base qw/BaseClass/; |
210 | } |
211 | |
212 | BaseClass->foo('base class'); |
213 | Child->foo('sub class'); |
e11cac87 |
214 | |
215 | use Test::More; |
8dd2f514 |
216 | isnt(BaseClass->can('foo'), Child->can('foo')); |
7e2ec16e |
217 | |
5687c7f9 |
218 | =head2 Extending Catalyst::Request or other classes in an ad-hoc manor using mk_accessors |
7e2ec16e |
219 | |
8dd2f514 |
220 | Previously, it was possible to add additional accessors to Catalyst::Request |
221 | (or other classes) by calling the mk_accessors class method. |
7e2ec16e |
222 | |
ba03ccca |
223 | This is no longer supported - users should make a sub-class of the class whose |
224 | behaviour they would like to change, rather than globally polluting the |
e11cac87 |
225 | Catalyst objects. |
8be895a7 |
226 | |
10011c19 |
227 | =head2 Confused multiple inheritance with Catalyst::Component::COMPONENT |
8be895a7 |
228 | |
bcc773b9 |
229 | Previously, Catalyst's COMPONENT method would delegate to the method on the |
230 | right hand side, which could then delegate back again with NEXT. This (as it |
231 | is insane AND makes no sense with C3 method dispatch order), and is therefore |
232 | no longer supported. |
233 | |
ba03ccca |
234 | If a COMPONENT method is detected in the inheritance hierarchy to the right |
bcc773b9 |
235 | hand side of Catalyst::Component::COMPONENT, then the following warning |
236 | message will be emitted: |
7e2ec16e |
237 | |
8dd2f514 |
238 | There is a COMPONENT method resolving after Catalyst::Component |
5687c7f9 |
239 | in ${next_package}. |
8dd2f514 |
240 | |
bcc773b9 |
241 | The correct fix is to re-arrange your class' inheritance hierarchy so that the |
242 | COMPONENT method you would like to inherit is the first (left-hand most) |
243 | COMPONENT method in your @ISA. |
7e2ec16e |
244 | |
c571d2c8 |
245 | =head1 WARNINGS |
246 | |
ade00972 |
247 | =head2 Catalyst::Base |
248 | |
249 | Any code using L<Catalyst::Base> will now warn, and this module will be removed |
250 | in a future release. |
251 | |
c571d2c8 |
252 | =head2 Methods in Catalyst::Dispatcher |
253 | |
bcc773b9 |
254 | The following methods in Catalyst::Dispatcher are both an implementation |
255 | detail, which may change in the 5.8X release series, and therefore their use |
256 | is highly deprecated. |
c571d2c8 |
257 | |
258 | =over |
259 | |
8dd2f514 |
260 | =item tree |
c571d2c8 |
261 | |
8dd2f514 |
262 | =item dispatch_types |
c571d2c8 |
263 | |
8dd2f514 |
264 | =item registered_dispatch_types |
c571d2c8 |
265 | |
8dd2f514 |
266 | =item method_action_class |
c571d2c8 |
267 | |
8dd2f514 |
268 | =item action_hash |
c571d2c8 |
269 | |
270 | =item container_hash |
271 | |
272 | =back |
273 | |
274 | The first time one of these methods is called, a warning will be emitted: |
7e2ec16e |
275 | |
bcc773b9 |
276 | Class $class is calling the deprecated method Catalyst::Dispatcher::$public_method_name, |
277 | this will be removed in Catalyst 5.9X |
7e2ec16e |
278 | |
c571d2c8 |
279 | You should B<NEVER> be calling any of these methods from application code. |
280 | |
ba03ccca |
281 | Plugins authors and maintainers whose plugins currently call these methods |
8f5a2bd9 |
282 | should change to using the public API, or, if you do not feel the public API |
ba03ccca |
283 | adequately supports your use-case, please email the development list to |
8f5a2bd9 |
284 | discuss what API features you need so that you can be appropriately supported. |
7e2ec16e |
285 | |
bcc773b9 |
286 | =head2 Class naming to packages defined does not correspond. |
7e2ec16e |
287 | |
e11cac87 |
288 | In this version of Catalyst, if a component is loaded from disk, but no |
ba03ccca |
289 | symbols are defined in that component's name space after it is loaded, this |
bcc773b9 |
290 | warning will be issued: |
7e2ec16e |
291 | |
bcc773b9 |
292 | require $class was successful but the package is not defined. |
7e2ec16e |
293 | |
bcc773b9 |
294 | This is to protect against confusing bugs caused by mis-typing package names, |
295 | and will become a fatal error in a future version. |
296 | |
297 | Please note that 'inner packages' (via L<Devel::InnerPackage>) are still fully |
298 | supported, this warning is only issued when component file naming does not map |
299 | to B<any> of the packages defined within that component. |
7e2ec16e |
300 | |
5687c7f9 |
301 | =head2 $c->plugin method |
302 | |
25f61108 |
303 | Calling the plugin method is deprecated, and calling it at run time is B<highly |
8dd2f514 |
304 | deprecated>. |
7e2ec16e |
305 | |
8dd2f514 |
306 | Instead you are recommended to use L< Catalyst::Model::Adaptor > or similar to |
ba03ccca |
307 | compose the functionality you need outside of the main application name space. |
7e2ec16e |
308 | |
4e68badc |
309 | Calling the plugin method will not be supported past Catalyst 5.81. |
bcc773b9 |
310 | |
7e2ec16e |
311 | =cut |
4e68badc |
312 | |