1Catalyst::Upgrading(3)User Contributed Perl DocumentationCatalyst::Upgrading(3)
2
3
4

NAME

6       Catalyst::Upgrading - Instructions for upgrading to the latest Catalyst
7

Upgrading to Catalyst 5.90121

9       A new "log_stats" method has been added. This will only affect
10       subclasses that have a method with this name added.
11

Upgrading to Catalyst 5.90100

13       We changed the way the middleware stash works so that it no longer
14       localizes the PSGI env hashref.  This was done to fix bugs where people
15       set PSGI ENV hash keys and found them to disappear in certain cases.
16       It also means that now if a sub applications sets stash variables, that
17       stash will now bubble up to the parent application.  This may be a
18       breaking change for you since previous versions of this code did not
19       allow that.  A workaround is to explicitly delete stash keys in your
20       sub application before returning control to the parent application.
21

Upgrading to Catalyst 5.90097

23       In older versions of Catalyst one could construct a URI with a fragment
24       (such as https://localhost/foo/bar#fragment) by using a '#' in the path
25       or final argument, for example:
26
27           $c->uri_for($action, 'foo#fragment');
28
29       This behavior was never documented and would break if using the Unicode
30       plugin, or when adding a query to the arguments:
31
32           $c->uri_for($action, 'foo#fragment', +{ a=>1, b=>2});
33
34       would define a fragment like "#fragment?a=1&b=2".
35
36       When we introduced UTF-8 encoding by default in Catalyst 5.9008x this
37       side effect behavior was broken since we started encoding the '#' when
38       it was part of the URI path.
39
40       In version 5.90095 and 5.90096 we attempted to fix this, but all we
41       managed to do was break people with URIs that included '#' as part of
42       the path data, when it was not expected to be a fragment delimiter.
43
44       In general Catalyst prefers an explicit specification rather than
45       relying on side effects or domain specific mini languages.  As a result
46       we are now defining how to set a fragment for a URI via ->uri_for:
47
48           $c->uri_for($action_or_path, \@captures_or_args, @args, \$query, \$fragment);
49
50       If you are relying on the previous side effect behavior your URLs will
51       now encode the '#' delimiter, which is going to be a breaking change
52       for you.  You need to alter your code to match the new specification or
53       modify uri_for for your local case.  Patches to solve this are very
54       welcomed, as long as they don't break existing test cases.
55
56       NOTE If you are using the string form of the first argument:
57
58           $c->uri_for('/foo/bar#baz')
59
60       construction, we do not attempt to encode this and it will make a URL
61       with a fragment of 'baz'.
62

Upgrading to Catalyst 5.90095

64       The method "last_error" in "Catalyst" was actually returning the first
65       error.  This has been fixed but there is a small chance it could be a
66       breaking issue for you.  If this gives you trouble changing to
67       "shift_errors" is the easiest workaround (although that does modify the
68       error stack so if you are relying on that not being changed you should
69       try something like @{$c->errors}[-1] instead.  Since this method is
70       relatively new and the cases when the error stack actually has more
71       than one error in it, we feel the exposure is very low, but bug reports
72       are very welcomed.
73

Upgrading to Catalyst 5.90090

75       Catalyst::Utils has a new method 'inject_component' which works the
76       same as the method of the same name in CatalystX::InjectComponent.  You
77       should start converting any use of the non core method in your code as
78       future changes to Catalyst will be synchronized to the core method
79       first.  We reserve the right to cease support of the non core version
80       should we reach a point in time where it cannot be properly supported
81       as an external module.  Luckily this should be a trivial search and
82       replace.  Change all occurrences of:
83
84           CatalystX::InjectComponent->inject(...)
85
86       Into
87
88           Catalyst::Utils::inject_component(...)
89
90       and we expect everything to work the same (we'd consider it not working
91       the same to be a bug, and please report it.)
92
93       We also cored features from CatalystX::RoleApplicator to compose a role
94       into the request, response and stats classes.  The main difference is
95       that with CatalystX::RoleApplicator you did:
96
97           package MyApp;
98
99           use Catalyst;
100           use CatalystX::RoleApplicator;
101
102           __PACKAGE__->apply_request_class_roles(
103             qw/My::Request::Role Other::Request::Role/);
104
105       Whereas now we have three class attributes, 'request_class_traits',
106       'response_class_traits' and 'stats_class_traits', so you use like this
107       (note this value is an ArrayRef)
108
109           package MyApp;
110
111           use Catalyst;
112
113           __PACKAGE__->request_class_traits([qw/
114             My::Request::Role
115             Other::Request::Role/]);
116
117       (And the same for response_class_traits and stats_class_traits.  We
118       left off the traits for Engine, since that class does a lot less
119       nowadays, and dispatcher.  If you used those and can share a use case,
120       we'd be likely to support them.
121
122       Lastly, we have some of the feature from
123       CatalystX::ComponentsFromConfig in core.  This should mostly work the
124       same way in core, except for now the core version does not create an
125       automatic base wrapper class for your configured components (it
126       requires these to be catalyst components and injects them directly.  So
127       if you make heavy use of custom base classes in
128       CatalystX::ComponentsFromConfig you might need a bit of work to use the
129       core version (although there is no reason to stop using
130       CatalystX::ComponentsFromConfig since it should continue to work fine
131       and we'd consider issues with it to be bugs).  Here's one way to map
132       from CatalystX::ComponentsFromConfig to core:
133
134       In CatalystX::ComponentsFromConfig:
135
136           MyApp->config(
137             'Model::MyClass' => {
138                 class => 'MyClass',
139                 args => { %args },
140
141             });
142
143       and now in core:
144
145           MyApp->config(
146             inject_components => {
147               'Model::MyClass' => { from_component => 'My::Class' },
148             },
149             'Model::MyClass' => {
150               %args
151             },
152           );
153
154       Although the core behavior requires more code, it better separates
155       concerns as well as plays more into core Catalyst expectations of how
156       configuration should look.
157
158       Also we added a new develop console mode only warning when you call a
159       component with arguments that don't expect or do anything meaningful
160       with those args.  Its possible if you are logging debug mode in
161       production (please don't...) this could add verbosity to those logs if
162       you also happen to be calling for components and passing pointless
163       arguments.  We added this warning to help people not make this error
164       and to better understand the component resolution flow.
165

Upgrading to Catalyst 5.90085

167       In this version of Catalyst we made a small change to Chained
168       Dispatching so that when two or more actions all have the same path
169       specification AND they all have Args(0), we break the tie by choosing
170       the last action defined, and not the first one defined.  This was done
171       to normalize Chaining to following the 'longest Path wins, and when
172       several actions match the same Path specification we choose the last
173       defined.' rule. Previously Args(0) was hard coded to be a special case
174       such that the first action defined would match (which is not the case
175       when Args is not zero.)
176
177       Its possible that this could be a breaking change for you, if you had
178       used action roles (custom or otherwise) to add additional matching
179       rules to differentiate between several Args(0) actions that share the
180       same root action chain.  For example if you have code now like this:
181
182           sub check_default :Chained(/) CaptureArgs(0) { ... }
183
184             sub default_get :Chained('check_default') PathPart('') Args(0) GET {
185                 pop->res->body('get3');
186             }
187
188             sub default_post :Chained('check_default') PathPart('') Args(0) POST {
189                 pop->res->body('post3');
190             }
191
192             sub chain_default :Chained('check_default') PathPart('') Args(0) {
193                 pop->res->body('chain_default');
194             }
195
196       The way that chaining will work previous is that when two or more equal
197       actions can match, the 'top' one wins.  So if the request is "GET
198       .../check_default" BOTH actions 'default_get' AND 'chain_default' would
199       match.  To break the tie in the case when Args is 0, we'd previous take
200       the 'top' (or first defined) action.  Unfortunately this treatment of
201       Args(0) is special case.  In all other cases we choose the 'last
202       defined' action to break a tie.  So this version of Catalyst changed
203       the dispatcher to make Args(0) no longer a special case for breaking
204       ties.  This means that the above code must now become:
205
206           sub check_default :Chained(/) CaptureArgs(0) { ... }
207
208             sub chain_default :Chained('check_default') PathPart('') Args(0) {
209                 pop->res->body('chain_default');
210             }
211
212             sub default_get :Chained('check_default') PathPart('') Args(0) GET {
213                 pop->res->body('get3');
214             }
215
216             sub default_post :Chained('check_default') PathPart('') Args(0) POST {
217                 pop->res->body('post3');
218             }
219
220       If we want it to work as expected (for example we we GET to match
221       'default_get' and POST to match 'default_post' and any other http
222       Method to match 'chain_default').
223
224       In other words Arg(0) and chained actions must now follow the normal
225       rule where in a tie the last defined action wins and you should place
226       all your less defined or 'catch all' actions first.
227
228       If this causes you trouble and you can't fix your code to conform, you
229       may set the application configuration setting
230       "use_chained_args_0_special_case" to true and that will revert you code
231       to the previous behavior.
232
233   More backwards compatibility options with UTF-8 changes
234       In order to give better backwards compatibility with the 5.90080+ UTF-8
235       changes we've added several configuration options around control of how
236       we try to decode your URL keywords / query parameters.
237
238       "do_not_decode_query"
239
240       If true, then do not try to character decode any wide characters in
241       your request URL query or keywords.  Most readings of the relevant
242       specifications suggest these should be UTF-* encoded, which is the
243       default that Catalyst will use, however if you are creating a lot of
244       URLs manually or have external evil clients, this might cause you
245       trouble.  If you find the changes introduced in Catalyst version
246       5.90080+ break some of your query code, you may disable the UTF-8
247       decoding globally using this configuration.
248
249       This setting takes precedence over "default_query_encoding" and
250       "decode_query_using_global_encoding"
251
252       "default_query_encoding"
253
254       By default we decode query and keywords in your request URL using
255       UTF-8, which is our reading of the relevant specifications.  This
256       setting allows one to specify a fixed value for how to decode your
257       query.  You might need this if you are doing a lot of custom encoding
258       of your URLs and not using UTF-8.
259
260       This setting take precedence over "decode_query_using_global_encoding".
261
262       "decode_query_using_global_encoding"
263
264       Setting this to true will default your query decoding to whatever your
265       general global encoding is (the default is UTF-8).
266

Upgrading to Catalyst 5.90080

268       UTF8 encoding is now default.  For temporary backwards compatibility,
269       if this change is causing you trouble, you can disable it by setting
270       the application configuration option to undef:
271
272           MyApp->config(encoding => undef);
273
274       But please consider this a temporary measure since it is the intention
275       that UTF8 is enabled going forwards and the expectation is that other
276       ecosystem projects will assume this as well.  At some point you
277       application will not correctly function without this setting.
278
279       As of 5.90084 we've added two additional configuration flags for more
280       selective control over some encoding changes:
281       'skip_body_param_unicode_decoding' and
282       'skip_complex_post_part_handling'.  You may use these to more
283       selectively disable new features while you are seeking a long term fix.
284       Please review CONFIGURATION in Catalyst.
285
286       For further information, please see Catalyst::UTF8
287
288       A number of projects in the wider ecosystem required minor updates to
289       be able to work correctly.  Here's the known list:
290
291       Catalyst::View::TT, Catalyst::View::Mason, Catalyst::View::HTML::Mason,
292       Catalyst::View::Xslate, Test::WWW::Mechanize::Catalyst
293
294       You will need to update to modern versions in most cases, although
295       quite a few of these only needed minor test case and documentation
296       changes so you will need to review the changelog of each one that is
297       relevant to you to determine your true upgrade needs.
298

Upgrading to Catalyst 5.90060

300       Starting in the v5.90059_001 development release, the regexp dispatch
301       type is no longer automatically included as a dependency.  If you are
302       still using this dispatch type, you need to add
303       Catalyst::DispatchType::Regex into your build system.
304
305       The standalone distribution of Regexp will be supported for the time
306       being, but should we find that supporting it prevents us from moving
307       Catalyst forward in necessary ways, we reserve the right to drop that
308       support.  It is highly recommended that you use this last stage of
309       deprecation to change your code.
310

Upgrading to Catalyst 5.90040

312   Catalyst::Plugin::Unicode::Encoding is now core
313       The previously stand alone Unicode support module
314       Catalyst::Plugin::Unicode::Encoding has been brought into core as a
315       default plugin.  Going forward, all you need is to add a configuration
316       setting for the encoding type.  For example:
317
318           package Myapp::Web;
319
320           use Catalyst;
321
322           __PACKAGE__->config( encoding => 'UTF-8' );
323
324       Please note that this is different from the old stand alone plugin
325       which applied "UTF-8" encoding by default (that is, if you did not set
326       an explicit "encoding" configuration value, it assumed you wanted
327       UTF-8).  In order to preserve backwards compatibility you will need to
328       explicitly turn it on via the configuration setting.  THIS MIGHT CHANGE
329       IN THE FUTURE, so please consider starting to test your application
330       with proper UTF-8 support and remove all those crappy hacks you munged
331       into the code because you didn't know the Plugin existed :)
332
333       For people that are using the Plugin, you will note a startup warning
334       suggesting that you can remove it from the plugin list.  When you do
335       so, please remember to add the configuration setting, since you can no
336       longer rely on the default being UTF-8.  We'll add it for you if you
337       continue to use the stand alone plugin and we detect this, but this
338       backwards compatibility shim will likely be removed in a few releases
339       (trying to clean up the codebase after all).
340
341       If you have trouble with any of this, please bring it to the attention
342       of the Catalyst maintainer group.
343
344   basic async and event loop support
345       This version of Catalyst offers some support for using AnyEvent and
346       IO::Async event loops in your application.  These changes should work
347       fine for most applications however if you are already trying to perform
348       some streaming, minor changes in this area of the code might affect
349       your functionality.  Please see Catalyst::Response\write_fh for more
350       and for a basic example.
351
352       We consider this feature experimental.  We will try not to break it,
353       but we reserve the right to make necessary changes to fix major issues
354       that people run into when the use this functionality in the wild.
355

Upgrading to Catalyst 5.90030

357   Regex dispatch type is deprecated.
358       The Regex dispatchtype (Catalyst::DispatchType::Regex) has been
359       deprecated.
360
361       You are encouraged to move your application to Chained dispatch
362       (Catalyst::DispatchType::Chained).
363
364       If you cannot do so, please add a dependency to
365       Catalyst::DispatchType::Regex to your application's Makefile.PL
366

Upgrading to Catalyst 5.9

368       The major change is that Plack, a toolkit for using the PSGI
369       specification, now replaces most of the subclasses of Catalyst::Engine.
370       If you are using one of the standard subclasses of Catalyst::Engine
371       this should be a straightforward upgrade for you. It was a design goal
372       for this release to preserve as much backwards compatibility as
373       possible.  However, since Plack is different from Catalyst::Engine, it
374       is possible that differences exist for edge cases. Therefore, we
375       recommend that care be taken with this upgrade and that testing should
376       be greater than would be the case with a minor point update. Please
377       inform the Catalyst developers of any problems so that we can fix them
378       and incorporate tests.
379
380       It is highly recommended that you become familiar with the Plack
381       ecosystem and documentation. Being able to take advantage of Plack
382       development and middleware is a major bonus to this upgrade.
383       Documentation about how to take advantage of Plack::Middleware by
384       writing your own ".psgi" file is contained in Catalyst::PSGI.
385
386       If you have created a custom subclass of <Catalyst:Engine>, you will
387       need to convert it to be a subclass of Plack::Handler.
388
389       If you are using the Plack engine, Catalyst::Engine::PSGI, this new
390       release supersedes that code.
391
392       If you are using a subclass of Catalyst::Engine that is aimed at
393       nonstandard or internal/testing uses, such as
394       Catalyst::Engine::Embeddable, you should still be able to continue
395       using that engine.
396
397       Advice for specific subclasses of Catalyst::Engine follows:
398
399   Upgrading the FastCGI Engine
400       No upgrade is needed if your myapp_fastcgi.pl script is already
401       upgraded to use Catalyst::Script::FastCGI.
402
403   Upgrading the mod_perl / Apache Engines
404       The engines that are built upon the various iterations of mod_perl,
405       Catalyst::Engine::Apache::MP13 (for mod_perl 1, and Apache 1.x) and
406       Catalyst::Engine::Apache2::MP20 (for mod_perl 2, and Apache 2.x),
407       should be seamless upgrades and will work using Plack::Handler::Apache1
408       or Plack::Handler::Apache2 as required.
409
410       Catalyst::Engine::Apache2::MP19, however, is no longer supported, as
411       Plack does not support mod_perl version 1.99. This is unlikely to be a
412       problem for anyone, as 1.99 was a brief beta-test release for mod_perl
413       2, and all users of mod_perl 1.99 are encouraged to upgrade to a
414       supported release of Apache 2 and mod_perl 2.
415
416   Upgrading the HTTP Engine
417       The default development server that comes with the Catalyst
418       distribution should continue to work as expected with no changes as
419       long as your "myapp_server" script is upgraded to use
420       Catalyst::Script::HTTP.
421
422   Upgrading the CGI Engine
423       If you were using Catalyst::Engine::CGI there is no upgrade needed if
424       your myapp_cgi.pl script is already upgraded to use
425       Catalyst::Script::CGI.
426
427   Upgrading Catalyst::Engine::HTTP::Prefork
428       If you were using Catalyst::Engine::HTTP::Prefork then Starman is
429       automatically loaded. You should (at least) change your "Makefile.PL"
430       to depend on Starman.
431
432       You can regenerate your "myapp_server.pl" script with "catalyst.pl" and
433       implement a "MyApp::Script::Server" class that looks like this:
434
435           package MyApp::Script::Server;
436           use Moose;
437           use namespace::autoclean;
438
439           extends 'CatalystX::Script::Server::Starman';
440
441           1;
442
443       This takes advantage of the new script system, and will add a number of
444       options to the standard server script as extra options are added by
445       Starman.
446
447       More information about these options can be seen at "SYNOPSIS" in
448       CatalystX::Script::Server::Starman.
449
450       An alternate route to implement this functionality is to write a simple
451       .psgi file for your application, and then use the plackup utility to
452       start the server.
453
454   Upgrading the PSGI Engine
455       If you were using Catalyst::Engine::PSGI, this new release supersedes
456       this engine in supporting Plack. By default the Engine is now always
457       Plack. As a result, you can remove the dependency on
458       Catalyst::Engine::PSGI in your "Makefile.PL".
459
460       Applications that were using Catalyst::Engine::PSGI previously should
461       entirely continue to work in this release with no changes.
462
463       However, if you have an "app.psgi" script, then you no longer need to
464       specify the PSGI engine. Instead, the Catalyst application class now
465       has a new method "psgi_app" which returns a PSGI compatible coderef
466       which you can wrap in the middleware of your choice.
467
468       Catalyst will use the .psgi for your application if it is located in
469       the "home" directory of the application.
470
471       For example, if you were using Catalyst::Engine::PSGI in the past, you
472       will have written (or generated) a "script/myapp.psgi" file similar to
473       this one:
474
475           use Plack::Builder;
476           use MyCatalytApp;
477
478           MyCatalystApp->setup_engine('PSGI');
479
480           builder {
481               enable ... # enable your desired middleware
482               sub { MyCatalystApp->run(@_) };
483           };
484
485       Instead, you now say:
486
487           use Plack::Builder;
488           use MyCatalystApp;
489
490           builder {
491               enable ... #enable your desired middleware
492               MyCatalystApp->psgi_app;
493           };
494
495       In the simplest case:
496
497           MyCatalystApp->setup_engine('PSGI');
498           my $app = sub { MyCatalystApp->run(@_) }
499
500       becomes
501
502           my $app = MyCatalystApp->psgi_app(@_);
503
504       NOT:
505
506           my $app = sub { MyCatalystApp->psgi_app(@_) };
507           # If you make ^^ this mistake, your app won't work, and will confuse the hell out of you!
508
509       You can now move "script/myapp.psgi" to "myapp.psgi", and the built-in
510       Catalyst scripts and your test suite will start using your .psgi file.
511
512       NOTE: If you rename your .psgi file without these modifications, then
513       any tests run via Catalyst::Test will not be compatible with the new
514       release, and will result in the development server starting, rather
515       than the expected test running.
516
517       NOTE: If you are directly accessing "$c->req->env" to get the PSGI
518       environment then this accessor is moved to "$c->engine->env", you will
519       need to update your code.
520
521   Engines which are known to be broken
522       The following engines DO NOT work as of Catalyst version 5.9. The core
523       team will be happy to work with the developers and/or users of these
524       engines to help them port to the new Plack/Engine system, but for now,
525       applications which are currently using these engines WILL NOT run
526       without modification to the engine code.
527
528       Catalyst::Engine::Wx
529       Catalyst::Engine::Zeus
530       Catalyst::Engine::JobQueue::POE
531       Catalyst::Engine::XMPP2
532       Catalyst::Engine::SCGI
533
534   Engines with unknown status
535       The following engines are untested or have unknown compatibility.
536       Reports are highly encouraged:
537
538       Catalyst::Engine::Mojo
539       Catalyst::Engine::Server (marked as Deprecated)
540       Catalyst::Engine::HTTP::POE (marked as Deprecated)
541
542   Plack functionality
543       See Catalyst::PSGI.
544
545   Tests in 5.9
546       Tests should generally work the same in Catalyst 5.9, but there are
547       some differences.
548
549       Previously, if using Catalyst::Test and doing local requests (against a
550       local server), if the application threw an exception then this
551       exception propagated into the test.
552
553       This behavior has been removed, and now a 500 response will be returned
554       to the test. This change standardizes behavior, so that local test
555       requests behave similarly to remote requests.
556

Upgrading to Catalyst 5.80

558       Most applications and plugins should run unaltered on Catalyst 5.80.
559
560       However, a lot of refactoring work has taken place, and several changes
561       have been made which could cause incompatibilities. If your application
562       or plugin is using deprecated code, or relying on side effects, then
563       you could have issues upgrading to this release.
564
565       Most issues found with existing components have been easy to solve.
566       This document provides a complete description of behavior changes which
567       may cause compatibility issues, and of new Catalyst warnings which
568       might be unclear.
569
570       If you think you have found an upgrade-related issue which is not
571       covered in this document, please email the Catalyst list to discuss the
572       problem.
573

Moose features

575   Application class roles
576       You can only apply method modifiers after the application's "->setup"
577       method has been called. This means that modifiers will not work with
578       methods run during the call to "->setup".
579
580       See Catalyst::Manual::ExtendingCatalyst for more information about
581       using Moose in your applications.
582
583   Controller actions in Moose roles
584       You can use MooseX::MethodAttributes::Role if you want to declare
585       actions inside Moose roles.
586
587   Using Moose in Components
588       The correct way to use Moose in a component in a both forward and
589       backwards compatible way is:
590
591           package TestApp::Controller::Root;
592           use Moose;
593           BEGIN { extends 'Catalyst::Component' }; # Or ::Controller, or whatever
594
595       See "Components which inherit from Moose::Object before
596       Catalyst::Component".
597

Known backwards compatibility breakages

599   Applications in a single file
600       Applications must be in their own file, and loaded at compile time.
601       This issue generally only affects the tests of CPAN distributions. Your
602       application will fail if you try to define an application inline in a
603       block, and use plugins which supply a " new " method, then use that
604       application latter in tests within the same file.
605
606       This is due to the fact that Catalyst is inlining a new method on your
607       application class allowing it to be compatible with Moose. The method
608       used to do this changed in 5.80004 to avoid the possibility of
609       reporting an 'Unknown Error' if your application failed to compile.
610
611   Issues with Class::C3
612       Catalyst 5.80 uses the Algorithm::C3 method dispatch order. This is
613       built into Perl 5.10, and comes via Class::C3 for Perl 5.8. This
614       replaces NEXT with Class::C3::Adopt::NEXT, forcing all components to
615       resolve methods using C3, rather than the unpredictable dispatch order
616       of NEXT.
617
618       This issue manifests itself by your application failing to start due to
619       an error message about having a non-linear @ISA.
620
621       The Catalyst plugin most often causing this is
622       Catalyst::Plugin::Session::Store::FastMmap - if you are using this
623       plugin and see issues, then please upgrade your plugins, as it has been
624       fixed. Note that Makefile.PL in the distribution will warn about known
625       incompatible components.
626
627       This issue can, however, be found in your own application - the only
628       solution is to go through each base class of the class the error was
629       reported against, until you identify the ones in conflict, and resolve
630       them.
631
632       To be able to generate a linear @ISA, the list of superclasses for each
633       class must be resolvable using the C3 algorithm. Unfortunately, when
634       superclasses are being used as mixins (to add functionality used in
635       your class), and with multiple inheritance, it is easy to get this
636       wrong.
637
638       Most common is the case of:
639
640           package Component1; # Note, this is the common case
641           use base qw/Class::Accessor::Fast Class::Data::Inheritable/;
642
643           package Component2; # Accidentally saying it this way causes a failure
644           use base qw/Class::Data::Inheritable Class::Accessor::Fast/;
645
646           package GoesBang;
647           use base qw/Component1 Component2/;
648
649       Any situation like this will cause your application to fail to start.
650
651       For additional documentation about this issue, and how to resolve it,
652       see Class::C3::Adopt::NEXT.
653
654   Components which inherit from Moose::Object before Catalyst::Component
655       Moose components which say:
656
657           package TestApp::Controller::Example;
658           use Moose;
659           extends qw/Moose::Object Catalyst::Component/;
660
661       to use the constructor provided by Moose, while working (if you do some
662       hacks with the " BUILDARGS " method), will not work with Catalyst 5.80
663       as "Catalyst::Component" inherits from "Moose::Object", and so  @ISA
664       fails to linearize.
665
666       The correct way to use Moose in a component in a both forward and
667       backwards compatible way is:
668
669           package TestApp::Controller::Root;
670           use Moose;
671           BEGIN { extends 'Catalyst::Component' }; # Or ::Controller, or whatever
672
673       Note that the " extends " declaration needs to occur in a begin block
674       for attributes to operate correctly.
675
676       This way you do not inherit directly from "Moose::Object" yourself.
677       Having components which do not inherit their constructor from
678       "Catalyst::Component" is unsupported, and has never been recommended,
679       therefore you're on your own if you're using this technique. You'll
680       need to detect the version of Catalyst your application is running, and
681       deal with it appropriately.
682
683       You also don't get the Moose::Object constructor, and therefore
684       attribute initialization will not work as normally expected. If you
685       want to use Moose attributes, then they need to be made lazy to
686       correctly initialize.
687
688       Note that this only applies if your component needs to maintain
689       component backwards compatibility for Catalyst versions before 5.71001
690       - in 5.71001 attributes work as expected, and the BUILD method is
691       called normally (although BUILDARGS is not).
692
693       If you depend on Catalyst 5.8, then all Moose features work as
694       expected.
695
696       You will also see this issue if you do the following:
697
698           package TestApp::Controller::Example;
699           use Moose;
700           use base 'Catalyst::Controller';
701
702       as " use base " appends to @ISA.
703
704       use Moose in MyApp
705
706       Similar to the above, this will also fail:
707
708           package MyApp;
709           use Moose;
710           use Catalyst qw/
711             ConfigLoader
712           /;
713           __PACKAGE__->setup;
714
715       If you need to use Moose in your application class (e.g. for method
716       modifiers etc.) then the correct technique is:
717
718           package MyApp;
719           use Moose;
720           use Catalyst;
721
722           extends 'Catalyst';
723
724           __PACKAGE__->config( name => 'MyApp' );
725           __PACKAGE__->setup(qw/
726               ConfigLoader
727           /);
728
729   Anonymous closures installed directly into the symbol table
730       If you have any code which installs anonymous subroutine references
731       directly into the symbol table, you may encounter breakages. The
732       simplest solution is to use Sub::Name to name the subroutine. Example:
733
734           # Original code, likely to break:
735           my $full_method_name = join('::', $package_name, $method_name);
736           *$full_method_name = sub { ... };
737
738           # Fixed Code
739           use Sub::Name 'subname';
740           my $full_method_name = join('::',$package_name, $method_name);
741           *$full_method_name = subname $full_method_name, sub { ... };
742
743       Additionally, you can take advantage of Catalyst's use of Class::MOP
744       and install the closure using the appropriate metaclass. Example:
745
746           use Class::MOP;
747           my $metaclass = Moose::Meta::Class->initialize($package_name);
748           $metaclass->add_method($method_name => sub { ... });
749
750   Hooking into application setup
751       To execute code during application start-up, the following snippet in
752       MyApp.pm used to work:
753
754           sub setup {
755               my ($class, @args) = @_;
756               $class->NEXT::setup(@args);
757               ... # things to do after the actual setup
758           }
759
760       With Catalyst 5.80 this won't work anymore, because Catalyst no longer
761       uses NEXT.pm for method resolution. The functionality was only ever
762       originally operational as NEXT remembers what methods have already been
763       called, and will not call them again.
764
765       Using this now causes infinite recursion between MyApp::setup and
766       Catalyst::setup, due to other backwards compatibility issues related to
767       how plugin setup works. Moose method modifiers like
768       "before|after|around setup => sub { ... };" also will not operate
769       correctly on the setup method.
770
771       The right way to do it is this:
772
773           after setup_finalize => sub {
774               ... # things to do after the actual setup
775           };
776
777       The setup_finalize hook was introduced as a way to avoid this issue.
778
779   Components with a new method which returns false
780       Previously, if you had a component which inherited from
781       Catalyst::COMPONENT, but overrode the new method to return false, then
782       your class's configuration would be blessed into a hash on your behalf,
783       and this would be returned from the COMPONENT method.
784
785       This behavior makes no sense, and so has been removed. Implementing
786       your own " new " method in components is highly discouraged. Instead,
787       you should inherit the new method from Catalyst::Component, and use
788       Moose's BUILD functionality and/or Moose attributes to perform any
789       construction work necessary for your class.
790
791   __PACKAGE__->mk_accessor('meta');
792       Won't work due to a limitation of Moose. This is currently being fixed
793       inside Moose.
794
795   Class::Data::Inheritable side effects
796       Previously, writing to a class data accessor would copy the accessor
797       method down into your package.
798
799       This behavior has been removed. While the class data is still stored
800       per-class, it is stored on the metaclass of the class defining the
801       accessor.
802
803       Therefore anything relying on the side effect of the accessor being
804       copied down will be broken.
805
806       The following test demonstrates the problem:
807
808           {
809               package BaseClass;
810               use base qw/Class::Data::Inheritable/;
811               __PACKAGE__->mk_classdata('foo');
812           }
813
814           {
815               package Child;
816               use base qw/BaseClass/;
817           }
818
819           BaseClass->foo('base class');
820           Child->foo('sub class');
821
822           use Test::More;
823           isnt(BaseClass->can('foo'), Child->can('foo'));
824
825   Extending Catalyst::Request or other classes in an ad hoc manner using
826       mk_accessors
827       Previously, it was possible to add additional accessors to
828       Catalyst::Request (or other classes) by calling the mk_accessors class
829       method.
830
831       This is no longer supported - users should make a subclass of the class
832       whose behavior they would like to change, rather than globally
833       polluting the Catalyst objects.
834
835   Confused multiple inheritance with Catalyst::Component::COMPONENT
836       Previously, Catalyst's COMPONENT method would delegate to the method on
837       the right hand side, which could then delegate back again with NEXT.
838       This is poor practice, and in addition, makes no sense with C3 method
839       dispatch order, and is therefore no longer supported.
840
841       If a COMPONENT method is detected in the inheritance hierarchy to the
842       right hand side of Catalyst::Component::COMPONENT, then the following
843       warning message will be emitted:
844
845           There is a COMPONENT method resolving after Catalyst::Component
846           in ${next_package}.
847
848       The correct fix is to re-arrange your class's inheritance hierarchy so
849       that the COMPONENT method you would like to inherit is the first (left-
850       hand most) COMPONENT method in your @ISA.
851
852   Development server relying on environment variables
853       Previously, the development server would allow propagation of system
854       environment variables into the request environment, this has changed
855       with the adoption of Plack. You can use Plack::Middleware::ForceEnv to
856       achieve the same effect.
857

WARNINGS

859   Actions in your application class
860       Having actions in your application class will now emit a warning at
861       application startup as this is deprecated. It is highly recommended
862       that these actions are moved into a MyApp::Controller::Root (as
863       demonstrated by the scaffold application generated by catalyst.pl).
864
865       This warning, also affects tests. You should move actions in your test,
866       creating a myTest::Controller::Root, like the following example:
867
868           package MyTest::Controller::Root;
869
870           use strict;
871           use warnings;
872
873           use parent 'Catalyst::Controller';
874
875           __PACKAGE__->config(namespace => '');
876
877           sub action : Local {
878               my ( $self, $c ) = @_;
879               $c->do_something;
880           }
881
882           1;
883
884   ::[MVC]:: naming scheme
885       Having packages called MyApp::[MVC]::XX is deprecated and can no longer
886       be generated by catalyst.pl
887
888       This is still supported, but it is recommended that you rename your
889       application components to Model/View/Controller.
890
891       A warning will be issued at application startup if the ::[MVC]:: naming
892       scheme is in use.
893
894   Catalyst::Base
895       Any code using Catalyst::Base will now emit a warning; this module will
896       be removed in a future release.
897
898   Methods in Catalyst::Dispatcher
899       The following methods in Catalyst::Dispatcher are implementation
900       details, which may change in the 5.8X release series, and therefore
901       their use is highly deprecated.
902
903       tree
904       dispatch_types
905       registered_dispatch_types
906       method_action_class
907       action_hash
908       container_hash
909
910       The first time one of these methods is called, a warning will be
911       emitted:
912
913           Class $class is calling the deprecated method Catalyst::Dispatcher::$public_method_name,
914           this will be removed in Catalyst 5.9
915
916       You should NEVER be calling any of these methods from application code.
917
918       Plugin authors and maintainers whose plugins currently call these
919       methods should change to using the public API, or, if you do not feel
920       the public API adequately supports your use case, please email the
921       development list to discuss what API features you need so that you can
922       be appropriately supported.
923
924   Class files with names that don't correspond to the packages they define
925       In this version of Catalyst, if a component is loaded from disk, but no
926       symbols are defined in that component's name space after it is loaded,
927       this warning will be issued:
928
929           require $class was successful but the package is not defined.
930
931       This is to protect against confusing bugs caused by mistyping package
932       names, and will become a fatal error in a future version.
933
934       Please note that 'inner packages' (via Devel::InnerPackage) are still
935       fully supported; this warning is only issued when component file naming
936       does not map to any of the packages defined within that component.
937
938   $c->plugin method
939       Calling the plugin method is deprecated, and calling it at run time is
940       highly deprecated.
941
942       Instead you are recommended to use Catalyst::Model::Adaptor or similar
943       to compose the functionality you need outside of the main application
944       name space.
945
946       Calling the plugin method will not be supported past Catalyst 5.81.
947
948
949
950perl v5.32.1                      2021-01-26            Catalyst::Upgrading(3)
Impressum