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 | |
e11cac87 |
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 |
8 | incompatibility. |
5687c7f9 |
9 | |
e11cac87 |
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. |
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 | |
6f04e56a |
19 | =head2 Components which inherit from Moose::Object before Catalyst::Component |
7e2ec16e |
20 | |
6f04e56a |
21 | Moose components which say: |
7e2ec16e |
22 | |
6f04e56a |
23 | package TestApp::Controller::Example; |
24 | use Moose; |
845bfcd2 |
25 | extends qw/Moose::Object Catalyst::Component/; |
7e2ec16e |
26 | |
6f04e56a |
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 |
30 | to linearise. |
31 | |
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. |
7e2ec16e |
38 | |
8566c0de |
39 | You will also see this issue if you do the following: |
40 | |
6f04e56a |
41 | package TestApp::Controller::Example; |
42 | use Moose; |
8566c0de |
43 | use base 'Catalyst::Controller'; |
44 | |
45 | as C< use base > appends to @ISA. |
46 | |
6f04e56a |
47 | The correct way to use Moose in a component in a both forward and backwards |
48 | compatible way is: |
49 | |
50 | package TestApp::Controller::Root; |
51 | use Moose; |
52 | BEGIN { extends 'Catalyst::Component' }; # Or ::Controller, or whatever |
53 | |
54 | Note that the C< extends > decleration needs to occur in a begin block for |
55 | L<attributes> to operate correctly. |
8566c0de |
56 | |
e11cac87 |
57 | =head3 use Moose in MyApp |
58 | |
59 | Similar to the above, this will also fail: |
60 | |
61 | package MyApp; |
62 | use Moose; |
63 | use Catalyst qw/ |
64 | ConfigLoader |
65 | /; |
66 | __PACKAGE__->setup; |
67 | |
68 | If you need to use Moose in your application class (e.g. for method modifiers |
69 | etc) then the correct technique is: |
70 | |
71 | package MyApp; |
72 | use Moose; |
73 | extends 'Catalyst'; |
74 | __PACKAGE__->setup(qw/ |
75 | ConfigLoader |
76 | /); |
77 | |
04a48104 |
78 | =head2 Anonymous closures installed directly into the symbol table |
79 | |
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: |
83 | |
e11cac87 |
84 | # Original code, likely to break: |
04a48104 |
85 | my $full_method_name = join('::',$package_name, $method_name); |
86 | *$full_method_name = sub { ... }; |
87 | |
e11cac87 |
88 | # Fixed Code |
04a48104 |
89 | use Sub::Name 'subname'; |
90 | my $full_method_name = join('::',$package_name, $method_name); |
91 | *$full_method_name = subname $full_method_name, sub { ... }; |
92 | |
e11cac87 |
93 | Additionally, you can take advantage of Catalysts use of L<Class::MOP> and |
04a48104 |
94 | install the closure using the appropriate metaclass. Example: |
95 | |
96 | use Class::MOP; |
97 | my $metaclass = Moose::Meta::Class->initialize($package_name); |
98 | $metaclass->add_method($method_name => sub { ... }); |
99 | |
780654ad |
100 | =head2 Hooking into application setup |
101 | |
102 | To execute code during application startup the following snippet in MyApp.pm |
103 | used to work: |
104 | |
105 | sub setup { |
106 | my ($class, @args) = @_; |
107 | $class->NEXT::setup(@args); |
108 | ... # things to do after the actual setup |
109 | } |
110 | |
111 | With Catalyst 5.80 this won't work anymore. Because instead of using NEXT.pm it |
e11cac87 |
112 | relies on L<Class::C3::Adopt::NEXT>, which uses plain C3 method resolution. |
113 | |
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. |
780654ad |
116 | |
e11cac87 |
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. |
780654ad |
120 | |
121 | The right way to do it is this: |
122 | |
123 | after setup_finalize => sub { |
124 | ... # things to do after the actual setup |
125 | }; |
126 | |
e11cac87 |
127 | =head2 Components with a new method which returns false |
7e2ec16e |
128 | |
8dd2f514 |
129 | Previously, if you had a component which inherited from Catalyst::COMPONENT, |
e11cac87 |
130 | but overrode the new method to return false, then your class' configuration |
8dd2f514 |
131 | would be blessed into a hash on your behalf, and this would be returned from |
a87f5aa5 |
132 | the COMPONENT method. |
7e2ec16e |
133 | |
e11cac87 |
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. |
7e2ec16e |
138 | |
139 | =head2 __PACKAGE__->mk_accessor('meta'); |
140 | |
e11cac87 |
141 | Won't work due to a limitation of L<Moose>. This is currently being fixed |
142 | inside Moose. |
7e2ec16e |
143 | |
144 | =head2 Class::Data::Inheritable side effects |
145 | |
8dd2f514 |
146 | Previously, writing to a class data accessor would copy the accessor method |
147 | down into your package. |
148 | |
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. |
7e2ec16e |
151 | |
8dd2f514 |
152 | Therefore anything relying on the side-effect of the accessor being copied down |
153 | will be broken. |
7e2ec16e |
154 | |
8dd2f514 |
155 | The following example demonstrates the problem: |
156 | |
157 | { |
158 | package BaseClass; |
159 | use base qw/Class::Data::Inheritable/; |
160 | __PACKAGE__->mk_classdata('foo'); |
161 | } |
162 | |
163 | { |
164 | package Child; |
165 | use base qw/BaseClass/; |
166 | } |
167 | |
168 | BaseClass->foo('base class'); |
169 | Child->foo('sub class'); |
e11cac87 |
170 | |
171 | use Test::More; |
8dd2f514 |
172 | isnt(BaseClass->can('foo'), Child->can('foo')); |
7e2ec16e |
173 | |
5687c7f9 |
174 | =head2 Extending Catalyst::Request or other classes in an ad-hoc manor using mk_accessors |
7e2ec16e |
175 | |
8dd2f514 |
176 | Previously, it was possible to add additional accessors to Catalyst::Request |
177 | (or other classes) by calling the mk_accessors class method. |
7e2ec16e |
178 | |
e11cac87 |
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 |
181 | Catalyst objects. |
8be895a7 |
182 | |
10011c19 |
183 | =head2 Confused multiple inheritance with Catalyst::Component::COMPONENT |
8be895a7 |
184 | |
5687c7f9 |
185 | Warning message: |
7e2ec16e |
186 | |
8dd2f514 |
187 | There is a COMPONENT method resolving after Catalyst::Component |
5687c7f9 |
188 | in ${next_package}. |
8dd2f514 |
189 | |
190 | This means that one of the packages on the right hand side of |
e11cac87 |
191 | Catalyst::Component in your Class' inheritance hierarchy defines a COMPONENT |
192 | method. |
7e2ec16e |
193 | |
e11cac87 |
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 |
197 | dispatch order. |
5687c7f9 |
198 | |
e11cac87 |
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 |
201 | method in your @ISA. |
7e2ec16e |
202 | |
c571d2c8 |
203 | =head1 WARNINGS |
204 | |
205 | =head2 Methods in Catalyst::Dispatcher |
206 | |
8dd2f514 |
207 | The following methods in Catalyst::Dispatcher are likely to change |
c571d2c8 |
208 | significantly in the 5.8X release series, and therefore their use is highly |
209 | deprecated. |
210 | |
211 | =over |
212 | |
8dd2f514 |
213 | =item tree |
c571d2c8 |
214 | |
8dd2f514 |
215 | =item dispatch_types |
c571d2c8 |
216 | |
8dd2f514 |
217 | =item registered_dispatch_types |
c571d2c8 |
218 | |
8dd2f514 |
219 | =item method_action_class |
c571d2c8 |
220 | |
8dd2f514 |
221 | =item action_hash |
c571d2c8 |
222 | |
223 | =item container_hash |
224 | |
225 | =back |
226 | |
227 | The first time one of these methods is called, a warning will be emitted: |
7e2ec16e |
228 | |
229 | Class $class is calling the deprecated method Catalyst::Dispatcher::$public_method_name,\n" |
230 | . "this will be removed in Catalyst 5.9X" |
231 | |
c571d2c8 |
232 | You should B<NEVER> be calling any of these methods from application code. |
233 | |
8dd2f514 |
234 | Plugins authors and maintainers whos plugins need to call these methods should |
235 | email the development list to discuss your use-case, and what a better API |
236 | should look like. |
7e2ec16e |
237 | |
5687c7f9 |
238 | =head2 require $class was successful but the package is not defined. |
7e2ec16e |
239 | |
e11cac87 |
240 | In this version of Catalyst, if a component is loaded from disk, but no |
241 | symbols are defined in that component's namespace after it is loaded, this |
242 | warning will be issued. |
7e2ec16e |
243 | |
10011c19 |
244 | This is to protect against confusing bugs caused by mis-typing package names. |
7e2ec16e |
245 | |
5687c7f9 |
246 | This will become a fatal error in a future version. |
7e2ec16e |
247 | |
5687c7f9 |
248 | =head2 $c->plugin method |
249 | |
8dd2f514 |
250 | Calling the plugin method is deprecated, and calling it at runtime is B<highly |
251 | deprecated>. |
7e2ec16e |
252 | |
8dd2f514 |
253 | Instead you are recommended to use L< Catalyst::Model::Adaptor > or similar to |
254 | compose the functionality you need outside of the main application namespace. |
7e2ec16e |
255 | |
256 | =cut |