change the way we do this logic for older perl compat
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Delta.pod
CommitLineData
8c57b129 1=head1 NAME
6c18e892 2
8c57b129 3Catalyst::Delta - Overview of changes between versions of Catalyst
4
5=head1 DESCRIPTION
6
46fff667 7This is an overview of the user-visible changes to Catalyst between major
8Catalyst releases.
9
5e7e6b27 10=head2 VERSION 5.90100
11
12Support for type constraints in Args and CaptureArgs has been improved. You may
13now inherit from a base controller that declares type constraints and use roles
14that declare type constraints. See L<Catalyst::RouteMatching> for more.
15
16You may now. also use a full type constraint namespace instead of inporting type
17constraints into your package namespace.
18
19We changed the way the middleware stash works so that it no longer localizes
20the PSGI env hashref. This was done to fix bugs where people set PSGI ENV hash
21keys and found them to dissappear in certain cases. It also means that now if
22a sub applications sets stash variables, that stash will now bubble up to the
23parent application. This may be a breaking change for you since previous
24versions of this code did not allow that. A workaround is to explicitly delete
25stash keys in your sub application before returning control to the parent
26application.
27
6b9f9ef7 28=head2 VERSION 5.90097
29
30=head3 Defined how $c->uri_for adds a URI fragment.
31
32We now have a specification for creating URIs with fragments (or HTML anchors).
33Previously you could do this as a side effect of how we create URIs but this
34side effect behavior was never documented or tested, and was broken when we
35introduced default UTF-8 encoding. When creating URIs with fragments please
36follow the new, supported specification:
37
38 $c->uri_for($action_or_path, \@captures_or_args, @args, \$query, \$fragment);
39
40This will be a breaking change for some codebases, we recommend testing if
41you are creating URLs with fragments.
42
02336198 43B<NOTE> If you are using the alternative:
44
45 $c->uri_for('/foo/bar#baz')
46
47construction, we do not attempt to encode this and it will make a URL with a
48fragment of 'baz'.
49
743f6b46 50=head2 VERSION 5.90094
51
52=head3 Multipart form POST with character set headers
53
54When we did the UTF8 work, we punted on Form POSTs when the POST envelope was
55multipart and each part had complex headers such as content-types, character
56sets and so forth. In those cases instead of returning a possibly incorrect
57value, we returned an object describing the part so that you could figure it
58out manually. This turned out to be a bad workaround as people did not expect
59to find that object. So we changed this to try much harder to get a correct
60value. We still return an object if we fail but we try much harder now. If
61you used to check for the object you might find that code is no longer needed
62(although checking for it should not hurt or break anything either).
63
8860df07 64=head2 VERSION 5.90091
65
66=head3 'case_sensitive' configuration
67
68At one point in time we allowed you to set a 'case_sensitive' configuraion value so
69that you could find actions by their private names using mixed case. We highly
70discourage that. If you are using this 'feature' you should be on notice that we
71plan to remove the code around it in the near future.
72
cbe13760 73=head2 VERSION 5.90090+
74
8860df07 75=head3 Type constraints on Args and CaptureArgs.
cbe13760 76
77You may now use a type constraint (using L<Moose>, L<MooseX::Types> or preferably
c1192f1e 78L<Type::Tiny> in your Args or CaptureArgs action attributes. This can be used
cbe13760 79to restrict the value of the Arg. For example:
80
81 sub myaction :Local Args(Int) { ... }
82
83Would match '.../myaction/5' but not '.../myaction/string'.
84
85When an action (or action chain) has Args (or CaptureArgs) that declare type constraints
86your arguments to $c->uri_for(...) must match those constraints.
87
88See L<Catalyst::RouteMatching> for more.
89
8860df07 90=head3 Move CatalystX::InjectComponent into core
ec4d7259 91
92L<Catalyst::Utils> has a new method 'inject_component' which works the same as the method of
93the same name in L<CatalystX::InjectComponent>.
94
8860df07 95=head3 inject_components
044e7667 96
97New configuration key allows you to inject components directly into your application without
98any subclasses. For example:
99
100 MyApp->config({
101 inject_components => {
102 'Controller::Err' => { from_component => 'Local::Controller::Errors' },
103 'Model::Zoo' => { from_component => 'Local::Model::Foo' },
104 'Model::Foo' => { from_component => 'Local::Model::Foo', roles => ['TestRole'] },
105 },
106 'Controller::Err' => { a => 100, b=>200, namespace=>'error' },
107 'Model::Zoo' => { a => 2 },
108 'Model::Foo' => { a => 100 },
109 });
110
111Injected components are useful to reduce the ammount of nearly empty boilerplate classes
112you might have, particularly when first starting an application.
113
8860df07 114=head3 Component setup changes.
044e7667 115
116Previously you could not depend on an application scoped component doing setup_components
117since components were setup 'in order'. Now all components are first registered and then
118setup, so you can now reliably use any component doing setup_components.
119
77b5811a 120=head2 VERSION 5.90080+
121
122The biggest change in this release is that UTF8 encoding is now enabled by
123default. So you no longer need any plugins (such as L<Catalyst::Plugin::Unicode::Encoding>)
124which you can just no go ahead and remove. You also don't need to set
125the encoding configuration (__PACKAGE__->config(encoding=>'UTF-8')) anymore
566678d0 126as well (although its presence hurts nothing).
77b5811a 127
128If this change causes you trouble, you can disable it:
129
130 __PACKAGE__->config(encoding=>undef);
131
d63cc9c8 132For further information, please see L<Catalyst::UTF8>
133
77b5811a 134But please report bugs. You will find that a number of common Views have been
135updated for this release (such as L<Catalyst::View::TT>). In all cases that the
136author is aware of these updates were to fix test cases only. You shouldn't
137need to update unless you are installing fresh and want tests to pass.
138
139L<Catalyst::Plugin::Compress> was updated to be compatible with this release.
b8b29bac 140You will need to upgrade if you are using this plugin. L<Catalyst::Upgrading>
141also has details.
77b5811a 142
143A small change is that the configuration setting C<using_frontend_proxy>
144was not doing the right thing if you started your application with C<psgi_app>
566678d0 145and did not apply the default middleware. This setting is now honored in
77b5811a 146all the ways an application may be started. This could cause trouble if you
147are using the configuration value and also adding the proxy middleware
148manually with a custom application startup. The solution is that you only
149need the configuration value set, or the middleware manually added (not both).
150
46fff667 151=head2 VERSION 5.90060+
152
8f3c0676 153=head3 Catalyst::Log object autoflush on by default
154
155Starting in 5.90065, the Catalyst::Log object has 'autoflush' which is on
156by default. This causes all messages to be written to the log immediately
157instead of at the end of startup and then at the end of each request. In
158order to access the old behavior, you must now call:
159
160 $c->log->autoflush(0);
161
efa8265f 162=head3 Deprecate Catalyst::Utils::ensure_class_loaded
3dc04d08 163
164Going forward we recommend you use L<Module::Runtime>. In fact we will
165be converting all uses of L<Class::Load> to L<Module::Runtime>. We will
166also convert L<Catalyst::Utils\ensure_class_loaded> to be based on
167L<Module::Runtime> to allow some time for you to update code, however at
168some future point this method will be removed so you should stop
169using it now.
170
fb29a8be 171=head3 Support passing Body filehandles directly to your Plack server.
0fb94688 172
46fff667 173We changed the way we return body content (from response) to whatever
174Plack handler you are using (Starman, FastCGI, etc.) We no longer
175always use the streaming interface for the cases when the body is a
176simple scalar, object or filehandle like. In those cases we now just
177pass the simple response on to the plack handler. This might lead to
178some minor differences in how streaming is handled. For example, you
efa8265f 179might notice that streaming starts properly supporting chunked encoding when
46fff667 180on a server that supports that, or that previously missing headers
181(possible content-length) might appear suddenly correct. Also, if you
182are using middleware like L<Plack::Middleware::XSendfile> and are using
183a filehandle that sets a readable path, your server might now correctly
184handle the file (rather than as before where Catalyst would stream it
185very likely very slowly).
186
187In other words, some things might be meaninglessly different and some
188things that were broken codewise but worked because of Catalyst being
189incorrect might suddenly be really broken. The behavior is now more
190correct in that Catalyst plays better with features that Plack offers
191but if you are making heavy use of the streaming interface there could
192be some differences so you should test carefully (this is probably not
193the vast majority of people). In particular if you are developing
194using one server but deploying using a different one, differences in
195what those server do with streaming should be noted.
196
0fb94688 197Please see note below about changes to filehandle support and existing
efa8265f 198Plack middleware to aid in backwards compatibility.
0fb94688 199
200=head3 Distinguish between body null versus undef.
201
46fff667 202We also now more carefully distingush the different between a body set
203to '' and a body that is undef. This might lead to situations where
204again you'll get a content-length were you didn't get one before or
205where a supporting server will start chunking output. If this is an
206issue you can apply the middleware L<Plack::Middleware::BufferedStreaming>
207or report specific problems to the dev team.
b31499bc 208
0fb94688 209=head3 More Catalyst Middleware
210
211We have started migrating code in Catalyst to equivilent Plack
212Middleware when such exists and is correct to do so. For example we now use
213L<Plack::Middleware::ContentLength> to determine content length of a response
214when none is provided. This replaces similar code inlined with L<Catalyst>
215The main advantages to doing this is 1) more similar Catalyst core that is
216focused on the Catalyst special sauce, 2) Middleware is more broadly shared
217so we benefit from better collaboration with developers outside Catalyst, 3)
218In the future you'll be able to change or trim the middleware stack to get
219additional performance when you don't need all the checks and constraints.
220
efa8265f 221=head3 Deprecate Filehandle like objects that do read but not getline
8e098614 222
223We also deprecated setting the response body to an object that does 'read'
224but not 'getline'. If you are using a custom IO-Handle like object for
225response you should verify that 'getline' is supported in your interface.
e27f6633 226Unless we here this case is a major issue for people, we will be removing support
0fb94688 227in a near future release of Catalyst. When the code encounters this it
228will issue a warning. You also may run into this issue with L<MogileFS::Client>
229which does read but not getline. For now we will just warn when encountering
230such an object and fallback to the previous behavior (where L<Catalyst::Engine>
231itself unrolls the filehandle and performs blocking streams). However
efa8265f 232this backwards compatibility will be removed in an upcoming release so you should either
0fb94688 233rewrite your custom filehandle objects to support getline or start using the
234middleware that adapts read for getline L<Plack::Middleware::AdaptFilehandleRead>.
235
efa8265f 236=head3 Response->headers become read-only after finalizing
8a3dcb98 237
238Once the response headers are finalized, trying to change them is not allowed
239(in the past you could change them and this would lead to unexpected results).
240
efa8265f 241=head3 Officially deprecate L<Catalyst::Engine::PSGI>
8e098614 242
243L<Catalyst::Engine::PSGI> is also officially no longer supported. We will
efa8265f 244no long run test cases against this and can remove backwards compatibility code for it
245as deemed necessary for the evolution of the platform. You should simply
246discontinue use of this engine, as L<Catalyst> has been PSGI at the core for
247several years.
aa20e9f5 248
efa8265f 249=head3 Officially deprecate finding the PSGI $env anyplace other than Request
0fb94688 250
251A few early releases of Cataplack had the PSGI $env in L<Catalyst::Engine>.
efa8265f 252Code has been maintained here for backwards compatibility reasons. This is no
253longer supported and will be removed in upcoming release, so you should update
0fb94688 254your code and / or upgrade to a newer version of L<Catalyst>
255
efa8265f 256=head3 Deprecate setting Response->body after using write/write_fh
8a3dcb98 257
258Setting $c->res->body to a filehandle after using $c->res->write or
259$c->res->write_fh is no longer considered allowed, since we can't send
260the filehandle to the underlying Plack handler. For now we will continue
3157d22a 261to support setting body to a simple value since this is possible, but at
262some future release a choice to use streaming indicates that you will do
263so for the rest of the request.
8a3dcb98 264
e27f6633 265
5bb2a5b3 266=head2 VERSION 5.90053
267
268We are now clarifying the behavior of log, plugins and configuration during
269the setup phase. Since Plugins might require a log during setup, setup_log
270must run BEFORE setup_plugins. This has the unfortunate side effect that
271anyone using the popular ConfigLoader plugin will not be able to supply
272configuration to custom logs since the configuration is not yet finalized
273when setup_log is run (when using ConfigLoader, which is a plugin and is
274not loaded until later.)
275
276As a workaround, you can supply custom log configuration directly into
277the configuration:
278
279 package MyApp;
280 use Catalyst;
281
282 __PACKAGE__->config(
283 my_custom_log_info => { %custom_args },
284 );
285
286 __PACKAGE__->setup;
287
288If you wish to configure the custom logger differently based on ENV, you can
289try:
290
291 package MyApp;
292
293 use Catalyst;
294 use Catalyst::Utils;
295
296 __PACKAGE__->config(
297 Catalyst::Utils::merge_hashes(
298 +{ my_custom_log_info => { %base_custom_args } },
299 +{ do __PACKAGE__->path_to( $ENV{WHICH_CONF}."_conf.pl") },
300 ),
301 );
302
303 __PACKAGE__->setup;
304
305Or create a standalone Configuration class that does the right thing.
306
307Basically if you want to configure a logger via Catalyst global configuration
308you can't use ConfigLoader because it will always be loaded too late to be of
309any use. Patches and workaround options welcomed!
310
9b3b1b9c 311=head2 VERSION 5.9XXXX 'cataplack'
c20710a1 312
313The Catalyst::Engine sub-classes have all been removed and deprecated,
314to be replaced with Plack handlers.
315
316Plack is an implementation of the L<PSGI> specification, which is
317a standard interface between web servers and application frameworks.
318
319This should be no different for developers, and you should not have to
320migrate your applications unless you are using a custom engine already.
321
322This change benefits Catalyst significantly by reducing the amount of
323code inside the framework, and means that the framework gets upstream
324bug fixes in L<Plack>, and automatically gains support for any web server
325which a L<PSGI> compliant handler is written for.
326
327It also allows you more flexibility with your application, and allows
328the use of cross web framework 'middleware'.
329
330Developers are recommended to read L<Catalyst::Upgrading> for notes about
331upgrading, especially if you are using an unusual deployment method.
332
333Documentation for how to take advantage of L<PSGI> can be found in
334L<Catalyst::PSGI>, and information about deploying your application
335has been moved to L<Catalyst::Manual::Deployment>.
336
337=head3 Updated modules:
338
339A number of modules have been updated to pass their tests or not
340produce deprecation warnings with the latest version of Catalyst.
341It is recommended that you upgrade any of these that you are using
342after installing this version of Catalyst.
343
344These extensions are:
345
346=over
347
348=item L<Catalyst::Engine::HTTP::Prefork>
349
350This is now deprecated, see L<Catalyst::Upgrading>.
351
352=item L<Test::WWW::Mechanize::Catalyst>
353
354Has been updated to not produce deprecation warnings, upgrade recommended.
355
356=item Catalyst::ActionRole::ACL
357
358Has been updated to fix failing tests (although older versions still
359function perfectly with this version of Catalyst).
360
361=item Catalyst::Plugin::Session::Store::DBIC
362
363Has been updated to fix failing tests (although older versions still
364function perfectly with this version of Catalyst).
365
14eb7697 366=item Catalyst::Plugin::Authentication
367
368Has been updated to fix failing tests (although older versions still
369function perfectly with this version of Catalyst).
370
c20710a1 371=back
1fae8c61 372
373=head1 PREVIOUS VERSIONS
374
9b3b1b9c 375=head2 VERSION 5.8XXXX 'catamoose'
1fae8c61 376
377=head3 Deprecations
b31499bc 378
e88235ff 379Please see L<Catalyst::Upgrading> for a full description of how changes in the
380framework may affect your application.
381
382Below is a brief list of features which have been deprecated in this release:
383
796a8358 384=over
b31499bc 385
796a8358 386=item ::[MVC]:: style naming scheme has been deprecated and will warn
b31499bc 387
e88235ff 388=item NEXT is deprecated for all applications and components, use MRO::Compat
b31499bc 389
e88235ff 390=item Dispatcher methods which are an implementation detail made private, public versions now warn.
b31499bc 391
e88235ff 392=item MyApp->plugin method is deprecated, use L<Catalyst::Model::Adaptor> instead.
796a8358 393
efa8265f 394=item __PACKAGE__->mk_accessors() is supported for backwards compatibility only, use Moose attributes instead in new code.
0a3b8de0 395
7df44a71 396=item Use of Catalyst::Base now warns
397
796a8358 398=back
399
1fae8c61 400=head3 New features
0a3b8de0 401
402=head3 Dispatcher
b31499bc 403
7df44a71 404=over
405
406=item Fix forwarding to Catalyst::Action objects.
407
408=item Add the dispatch_type method
409
410=back
b31499bc 411
0a3b8de0 412=head3 Restarter
b31499bc 413
6171ddd5 414The development server restarter has been improved to be compatible with
415immutable Moose classes, and also to optionally use
416L<B::Hooks::OP::Check::StashChange> to handle more complex application layouts
417correctly.
b31499bc 418
7df44a71 419=head3 $c->uri_for_action method.
b31499bc 420
7df44a71 421Give a private path to the Catalyst action you want to create a URI for.
6c18e892 422
0a3b8de0 423=head3 Logging
b31499bc 424
7df44a71 425Log levels have been made additive.
b31499bc 426
0a3b8de0 427=head3 L<Catalyst::Test>
428
429=over
430
431=item Change to use L<Sub::Exporter>.
432
0a3b8de0 433=item Support mocking multiple virtual hosts
434
435=item New methods like action_ok and action_redirect to write more compact tests
436
437=back
438
7df44a71 439=head3 Catalyst::Response
0a3b8de0 440
7df44a71 441=over
442
443=item *
444
445New print method which prints @data to the output stream, separated by $,.
446This lets you pass the response object to functions that want to write to an
447L<IO::Handle>.
448
449=item *
450
451Added code method as an alias for C<< $res->status >>
0a3b8de0 452
d5a6de01 453=back
454
1fae8c61 455=head3 Consequences of the Moose back end
b31499bc 456
796a8358 457=over
458
459=item *
460
7df44a71 461Components are fully compatible with Moose, and all Moose features, such as
462method modifiers, attributes, roles, BUILD and BUILDARGS methods are fully
463supported and may be used in components and applications.
464
465=item *
466
467Many reusable extensions which would previously have been plugins or base
468classes are better implemented as Moose roles.
469
470=item *
471
a0c37f08 472L<MooseX::MethodAttributes::Role::AttrContainer::Inheritable> is used to contain action
7df44a71 473attributes. This means that attributes are represented in the MOP, and
474decouples action creation from attributes.
796a8358 475
476=item *
477
0a3b8de0 478There is a reasonable API in Catalyst::Controller for working with
796a8358 479and registering actions, allowing a controller sub-class to replace
25f61108 480subroutine attributes for action declarations with an alternate
0a3b8de0 481syntax.
796a8358 482
483=item *
484
0a3b8de0 485Refactored capturing of $app from L<Catalyst::Controller> into
486L<Catalyst::Component::ApplicationAttribute> for easier reuse in other
7df44a71 487components.
488
489=item *
490
491Your application class is forced to become immutable at the end of compilation.
492
493=back
494
1fae8c61 495=head3 Bug fixes
7df44a71 496
497=over
498
499=item *
500
25f61108 501Don't ignore SIGCHLD while handling requests with the development server, so that
7df44a71 502system() and other ways of creating child processes work as expected.
503
504=item *
505
506Fixes for FastCGI when used with IIS 6.0
507
508=item *
509
510Fix a bug in uri_for which could cause it to generate paths with multiple
511slashes in them.
796a8358 512
513=item *
514
7df44a71 515Fix a bug in Catalyst::Stats, stopping garbage being inserted into
516the stats if a user calls begin => but no end
796a8358 517
518=back
519