From: Tomas Doran Date: Mon, 23 Nov 2009 23:06:27 +0000 (+0000) Subject: Merge 'trunk' into 'better_scripts' X-Git-Tag: 5.80014_02~38 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=49fe75ffc9bab4595f2644c192b120f1506b7035;hp=3d8f8cd53cb78fbf4d492377e39da6b0148515b4 Merge 'trunk' into 'better_scripts' r11978@t0mlaptop (orig r11943): rafl | 2009-11-20 06:22:44 +0000 Fix a doc typo. Also trim some trailing whitespace. r11979@t0mlaptop (orig r11944): rafl | 2009-11-20 06:22:51 +0000 Remove some docs for Exception::Go and ::Detach. Users really shouldn't care. r11980@t0mlaptop (orig r11945): rafl | 2009-11-20 07:05:08 +0000 Depend on MX::Role::WithOverloading 0.03 to make sure things work out on 5.8.8 and older. r11986@t0mlaptop (orig r11951): rafl | 2009-11-21 01:30:07 +0000 Remove duplicate changelog entry. r11987@t0mlaptop (orig r11952): rafl | 2009-11-21 01:43:12 +0000 Improve Exception::Interface docs. r11988@t0mlaptop (orig r11953): rafl | 2009-11-21 01:43:28 +0000 More changelogging. r11989@t0mlaptop (orig r11954): rafl | 2009-11-21 01:43:57 +0000 Refer to the right ticket in Changes. r11990@t0mlaptop (orig r11955): rafl | 2009-11-21 02:31:02 +0000 Version 5.80014. r11996@t0mlaptop (orig r11961): zby | 2009-11-21 13:03:43 +0000 warning for plugins inheriting from Catayst::Component r11998@t0mlaptop (orig r11963): t0m | 2009-11-22 12:57:30 +0000 Chop out that crap, not needed r11999@t0mlaptop (orig r11964): t0m | 2009-11-22 13:01:09 +0000 Do not be @ISA Controller, that's hideous dumb and now warns r12000@t0mlaptop (orig r11965): t0m | 2009-11-22 13:01:48 +0000 Do not use NEXT, like it says in the comments r12001@t0mlaptop (orig r11966): t0m | 2009-11-22 13:04:50 +0000 Fix unicode issues in CGI and FastCGI engines r12002@t0mlaptop (orig r11967): t0m | 2009-11-22 13:08:47 +0000 Changelog, adjust warning text, bump versions for a dev release. The 'we do get Class::C3::Adopt::NEXT warnings test is now broken, no idea why, will look later. r12003@t0mlaptop (orig r11968): t0m | 2009-11-22 19:42:30 +0000 Different phrasing for different versions r12004@t0mlaptop (orig r11969): t0m | 2009-11-22 19:53:00 +0000 Whoops, fix typo r12005@t0mlaptop (orig r11970): t0m | 2009-11-22 19:58:31 +0000 It actually wants 'true', make that more explicit r12006@t0mlaptop (orig r11971): t0m | 2009-11-22 19:59:04 +0000 release 5.80014_01 r12008@t0mlaptop (orig r11973): t0m | 2009-11-22 20:08:28 +0000 Notabs is author only r12009@t0mlaptop (orig r11974): t0m | 2009-11-22 20:11:17 +0000 Pod tests are also author only r12010@t0mlaptop (orig r11975): t0m | 2009-11-22 20:13:06 +0000 Changelog r12013@t0mlaptop (orig r11978): t0m | 2009-11-23 21:25:19 +0000 Don't do bytes::length, just use length, tests to demonstrate the issue r12014@t0mlaptop (orig r11979): t0m | 2009-11-23 21:45:55 +0000 Nasty hack for fastcgi, fixes gitalist r12021@t0mlaptop (orig r11986): t0m | 2009-11-23 22:57:40 +0000 Have a new conflict statement --- diff --git a/Changes b/Changes index cbedef1..1901419 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,31 @@ # This file documents the revision history for Perl extension Catalyst. + Bug fixes: + - Fix reporting the wrong Content-Length if the response body is an + upgraded string. Strings mean the same thing whether or not they are + upgraded, may get upgraded even after they are encoded, and will + produce the same output either way, but bytes::length returns too big + values for upgraded strings containing characters >127 + - Make FastCGI compatible with modules which use the fileno call to + determine if a file is open (E.g. IPC::Run) + + Refactoring / cleanups: + - NoTabs and Pod tests moved to t/author so that they're not run + (and then skipped) normally. + +5.80014_01 2009-11-22 20:01:23 + + Bug fixes: + - Filehandle now forced to binmode in CGI and FastCGI engines. This appears + to correct some UTF-8 issues, but may break people's code which relies + on the old behaviour. + + Refactoring / cleanups: + - Plugins which inherit from Catalyst::Controller or Catalyst::Component + are deprecated and now issue warnings. + +5.80014 2009-11-21 02:51:14 + Bug fixes: - Require MooseX::MethodAttributes 0.17. This in turn requires new MooseX::Types to stop warnings in Moose 0.91, and correctly supports @@ -9,8 +35,6 @@ - Improved the suggested fix warning when component resolution uses regex fallback for fully qualified component names. - Catalyst::Test::local_request sets ->request on the response. - - Require HTTP::Request 5.814 and HTTP::Response 5.813 from LWP 5.814 - to avoid test fails. - Log flush moved to the end of setup so that roles and plugins which hook setup_finalize can log things and have them appear in application startup, rather than with the first hit. @@ -35,7 +59,7 @@ context. - Pod fix in Catalyst::Request (RT#51490) - Pod fixes to refer to ::Controller:: rather than ::C:: as the latter - is deprecated (RT#51490) + is deprecated (RT#51489) New features: - Added disable_component_resolution_regex_fallback config option to @@ -44,6 +68,11 @@ proper PATH_INFO and SCRIPT_NAME processing for non-root applications - Enable Catalyst::Utils::home() to find home within Dist::Zilla built distributions + - Added the Catalyst::Exception::Interface role defining the interface + exception classes need to implement. + - Added Catalyst::Exception::Basic as a basic implementation of + Catalyst::Exception::Interface and made the existing exception classes + use it. Refactoring / cleanups: - Remove documentation for the case_sensitive setting diff --git a/Makefile.PL b/Makefile.PL index b98a180..790e8f8 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -24,7 +24,7 @@ requires 'MooseX::Emulate::Class::Accessor::Fast' => '0.00903'; requires 'Class::MOP' => '0.83'; requires 'Moose' => '0.90'; requires 'MooseX::MethodAttributes::Inheritable' => '0.17'; -requires 'MooseX::Role::WithOverloading'; +requires 'MooseX::Role::WithOverloading' => '0.03'; requires 'Carp'; requires 'Class::C3::Adopt::NEXT' => '0.07'; requires 'CGI::Simple::Cookie'; @@ -114,6 +114,7 @@ EOF # NOTE - This is the version number of the _incompatible_ code, # not the version number of the fixed version. my %conflicts = ( + 'Catalyst::Plugin::SubRequest' => '0.14', 'Catalyst::Model::Akismet' => '0.02', 'Catalyst::Component::ACCEPT_CONTEXT' => '0.06', 'Catalyst::Plugin::ENV' => '9999', # This plugin is just stupid, full stop @@ -157,7 +158,7 @@ sub darwin_check_no_resource_forks { my $attr = $osx_ver =~ /^10.(5|6)/ ? 'COPYFILE_DISABLE' : 'COPY_EXTENDED_ATTRIBUTES_DISABLE'; makemaker_args(dist => { PREOP => qq{\@if [ "\$\$$attr" != "true" ]; then}. - qq{ echo "You must set the ENV variable $attr to true,"; }. + qq{ echo "You must set the ENV variable $attr to 'true',"; }. ' echo "to avoid getting resource forks in your dist."; exit 255; fi' }); } } diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 5d8de24..296cf43 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -4,7 +4,6 @@ use Moose; use Moose::Meta::Class (); extends 'Catalyst::Component'; use Moose::Util qw/find_meta/; -use bytes; use B::Hooks::EndOfScope (); use Catalyst::Exception; use Catalyst::Exception::Detach; @@ -79,7 +78,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.80013'; +our $VERSION = '5.80014_01'; { my $dev_version = $VERSION =~ /_\d{2}$/; @@ -1793,7 +1792,7 @@ sub finalize_headers { } else { # everything should be bytes at this point, but just in case - $response->content_length( bytes::length( $response->body ) ); + $response->content_length( length( $response->body ) ); } } @@ -2587,7 +2586,8 @@ the plugin name does not begin with C. my $class = ref $proto || $proto; Class::MOP::load_class( $plugin ); - + $class->log->warn( "$plugin inherits from 'Catalyst::Component' - this is decated and will not work in 5.81" ) + if $plugin->isa( 'Catalyst::Component' ); $proto->_plugins->{$plugin} = 1; unless ($instant) { no strict 'refs'; diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 8416e09..4c20c62 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -85,6 +85,7 @@ sub prepare_connection { if ( $ENV{SERVER_PORT} == 443 ) { $request->secure(1); } + binmode(STDOUT); # Ensure we are sending bytes. } =head2 $self->prepare_headers($c) diff --git a/lib/Catalyst/Engine/FastCGI.pm b/lib/Catalyst/Engine/FastCGI.pm index a6e9688..b8e0635 100644 --- a/lib/Catalyst/Engine/FastCGI.pm +++ b/lib/Catalyst/Engine/FastCGI.pm @@ -144,6 +144,11 @@ sub run { $self->_fix_env( \%env ); + # hack for perl libraries that use FILENO (e.g. IPC::Run) + # trying to patch FCGI.pm, but not got there yet :/ + local *FCGI::Stream::FILENO = sub { -2 } + unless FCGI::Stream->can('FILENO'); + $class->handle_request( env => \%env ); $proc_manager && $proc_manager->pm_post_dispatch(); diff --git a/lib/Catalyst/Exception/Basic.pm b/lib/Catalyst/Exception/Basic.pm index f32a6e6..713bb5f 100644 --- a/lib/Catalyst/Exception/Basic.pm +++ b/lib/Catalyst/Exception/Basic.pm @@ -53,11 +53,11 @@ Catalyst::Exception::Basic - Basic Catalyst Exception Role package My::Exception; use Moose; use namespace::clean -except => 'meta'; - + with 'Catalyst::Exception::Basic'; - + # Elsewhere.. - My::Exception::Basic->throw( qq/Fatal exception/ ); + My::Exception->throw( qq/Fatal exception/ ); See also L and L. @@ -76,7 +76,7 @@ Holds the exception message. =head2 as_string -Stringifies the exception's message attribute. +Stringifies the exception's message attribute. Called when the object is stringified by overloading. =head2 throw( $message ) diff --git a/lib/Catalyst/Exception/Detach.pm b/lib/Catalyst/Exception/Detach.pm index 8ef9157..88f42c1 100644 --- a/lib/Catalyst/Exception/Detach.pm +++ b/lib/Catalyst/Exception/Detach.pm @@ -19,28 +19,27 @@ __END__ Catalyst::Exception::Detach - Exception for redispatching using $ctx->detach() -=head1 SYNOPSIS - - Do not use this class directly, instead you should use the singleton instance - found in $Catalyst::DETACH; - - E.g. die $Catalyst::DETACH - -See also L and L. - =head1 DESCRIPTION This is the class for the Catalyst Exception which is thrown then you call -C<< $c->detach() >>. There should be a singleton instance of this class in the -C<< $Catalyst::DETACH >> global variable. +C<< $c->detach() >>. -Users should never need to know or care about this exception, please just use -C<< $c->detach >> +This class is not intended to be used directly by users. =head2 meta Provided by Moose +=head1 SEE ALSO + +=over 4 + +=item L + +=item L + +=back + =head1 AUTHORS Catalyst Contributors, see Catalyst.pm diff --git a/lib/Catalyst/Exception/Go.pm b/lib/Catalyst/Exception/Go.pm index e4e50a3..f7d7362 100644 --- a/lib/Catalyst/Exception/Go.pm +++ b/lib/Catalyst/Exception/Go.pm @@ -19,28 +19,27 @@ __END__ Catalyst::Exception::Go - Exception for redispatching using $ctx->go() -=head1 SYNOPSIS - - Do not use this class directly, instead you should use the singleton instance - found in $Catalyst::GO; - - E.g. die $Catalyst::GO; - -See also L and L. - =head1 DESCRIPTION This is the class for the Catalyst Exception which is thrown then you call -C<< $c->go() >>. There should be a singleton instance of this class in the -C<< $Catalyst::DETACH >> global variable. +C<< $c->go() >>. -Users should never need to know or care about this exception, please just use -C<< $c->detach >> +This class is not intended to be used directly by users. =head2 meta Provided by Moose +=head1 SEE ALSO + +=over 4 + +=item L + +=item L + +=back + =head1 AUTHORS Catalyst Contributors, see Catalyst.pm diff --git a/lib/Catalyst/Exception/Interface.pm b/lib/Catalyst/Exception/Interface.pm index 65d5a54..371bfa3 100644 --- a/lib/Catalyst/Exception/Interface.pm +++ b/lib/Catalyst/Exception/Interface.pm @@ -15,22 +15,20 @@ __END__ =head1 NAME -Catalyst::Exception::Interface - Exception for redispatching using $ctx->detach() +Catalyst::Exception::Interface - Role defining the interface for Catalyst exceptions =head1 SYNOPSIS package My::Catalyst::Like::Exception; use Moose; use namespace::clean -except => 'meta'; - + + with 'Catalyst::Exception::Interface'; + # This comprises the required interface. sub as_string { 'the exception text for stringification' } sub die { shift; die @_ } sub die { shift; die @_ } - - with 'Catalyst::Exception::Interface'; - -See also L and L. =head1 DESCRIPTION @@ -57,6 +55,16 @@ must use L. Provided by Moose +=head1 SEE ALSO + +=over 4 + +=item L + +=item L + +=back + =head1 AUTHORS Catalyst Contributors, see Catalyst.pm diff --git a/lib/Catalyst/Runtime.pm b/lib/Catalyst/Runtime.pm index 0304b89..d6ec44f 100644 --- a/lib/Catalyst/Runtime.pm +++ b/lib/Catalyst/Runtime.pm @@ -7,7 +7,7 @@ BEGIN { require 5.008004; } # Remember to update this in Catalyst as well! -our $VERSION='5.80013'; +our $VERSION='5.80014_01'; $VERSION = eval $VERSION; diff --git a/t/02pod.t b/t/02pod.t deleted file mode 100644 index 05aa78a..0000000 --- a/t/02pod.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; - -eval "use Test::Pod 1.14"; -plan skip_all => 'Test::Pod 1.14 required' if $@; -plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD} || -e 'inc/.author'; - -all_pod_files_ok(); diff --git a/t/03podcoverage.t b/t/03podcoverage.t deleted file mode 100644 index 61a207b..0000000 --- a/t/03podcoverage.t +++ /dev/null @@ -1,13 +0,0 @@ -use Test::More; - -eval "use Pod::Coverage 0.19"; -plan skip_all => 'Pod::Coverage 0.19 required' if $@; -eval "use Test::Pod::Coverage 1.04"; -plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; -plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD} || -e 'inc/.author'; - -all_pod_coverage_ok( - { - also_private => ['BUILD'] - } -); diff --git a/t/04critic.t b/t/04critic.t deleted file mode 100644 index 5a4a226..0000000 --- a/t/04critic.t +++ /dev/null @@ -1,21 +0,0 @@ -use strict; -use warnings; - -use File::Spec; -use FindBin (); -use Test::More; - -if ( !-e "$FindBin::Bin/../MANIFEST.SKIP" ) { - plan skip_all => 'Critic test only for developers.'; -} -else { - eval { require Test::NoTabs }; - if ( $@ ) { - plan tests => 1; - fail( 'You must install Test::NoTabs to run 04critic.t' ); - exit; - } -} - -Test::NoTabs->import; -all_perl_files_ok(qw/lib/); diff --git a/t/aggregate/utf8_content_length.t b/t/aggregate/utf8_content_length.t new file mode 100644 index 0000000..86297e8 --- /dev/null +++ b/t/aggregate/utf8_content_length.t @@ -0,0 +1,30 @@ +use strict; +use warnings; +use FindBin qw/$Bin/; +use lib "$Bin/../lib"; +use File::Spec; +use Test::More; + +use Catalyst::Test qw/TestAppEncoding/; + +if ( $ENV{CATALYST_SERVER} ) { + plan skip_all => 'This test does not run live'; + exit 0; +} + +my $fn = "$Bin/../catalyst_130pix.gif"; +ok -r $fn, 'Can read catalyst_130pix.gif'; +my $size = -s $fn; +{ + my $r = request('/binary'); + is $r->code, 200, '/binary OK'; + is $r->header('Content-Length'), $size, '/binary correct content length'; +} +{ + my $r = request('/binary_utf8'); + is $r->code, 200, '/binary_utf8 OK'; + is $r->header('Content-Length'), $size, '/binary_utf8 correct content length'; +} + +done_testing; + diff --git a/t/author/notabs.t b/t/author/notabs.t new file mode 100644 index 0000000..5cd3ae0 --- /dev/null +++ b/t/author/notabs.t @@ -0,0 +1,10 @@ +use strict; +use warnings; + +use File::Spec; +use FindBin (); +use Test::More; +use Test::NoTabs; + +all_perl_files_ok(qw/lib/); + diff --git a/t/author/pod.t b/t/author/pod.t new file mode 100644 index 0000000..f908f73 --- /dev/null +++ b/t/author/pod.t @@ -0,0 +1,8 @@ +use strict; +use warnings; +use Test::More; + +use Test::Pod 1.14; + +all_pod_files_ok(); + diff --git a/t/author/podcoverage.t b/t/author/podcoverage.t new file mode 100644 index 0000000..e8730de --- /dev/null +++ b/t/author/podcoverage.t @@ -0,0 +1,13 @@ +use strict; +use warnings; +use Test::More; + +use Pod::Coverage 0.19; +use Test::Pod::Coverage 1.04; + +all_pod_coverage_ok( + { + also_private => ['BUILD'] + } +); + diff --git a/t/deprecated.t b/t/deprecated.t index b30df89..d9f90e0 100644 --- a/t/deprecated.t +++ b/t/deprecated.t @@ -9,7 +9,10 @@ use Test::More tests => 4; my $warnings; BEGIN { # Do this at compile time in case we generate a warning when use # DeprecatedTestApp - $SIG{__WARN__} = sub { $warnings++ if $_[0] =~ /trying to use NEXT/ }; + $SIG{__WARN__} = sub { + $warnings++ if $_[0] =~ /uses NEXT, which is deprecated/; + $warnings++ if $_[0] =~ /trying to use NEXT, which is deprecated/; + }; } use Catalyst; # Cause catalyst to be used so I can fiddle with the logging. my $mvc_warnings; diff --git a/t/lib/Catalyst/Plugin/Test/Deprecated.pm b/t/lib/Catalyst/Plugin/Test/Deprecated.pm index 688ad21..7453248 100644 --- a/t/lib/Catalyst/Plugin/Test/Deprecated.pm +++ b/t/lib/Catalyst/Plugin/Test/Deprecated.pm @@ -2,7 +2,6 @@ package Catalyst::Plugin::Test::Deprecated; use strict; use warnings; -use NEXT; sub prepare { my $class = shift; diff --git a/t/lib/Catalyst/Plugin/Test/Plugin.pm b/t/lib/Catalyst/Plugin/Test/Plugin.pm index 16f3f63..f4f835b 100644 --- a/t/lib/Catalyst/Plugin/Test/Plugin.pm +++ b/t/lib/Catalyst/Plugin/Test/Plugin.pm @@ -4,7 +4,7 @@ use strict; use warnings; use MRO::Compat; -use base qw/Catalyst::Controller Class::Data::Inheritable/; +use base qw/Class::Data::Inheritable/; __PACKAGE__->mk_classdata('ran_setup'); diff --git a/t/lib/TestApp/Controller/Root.pm b/t/lib/TestApp/Controller/Root.pm index 5aa03dc..5b29201 100644 --- a/t/lib/TestApp/Controller/Root.pm +++ b/t/lib/TestApp/Controller/Root.pm @@ -1,5 +1,6 @@ package TestApp::Controller::Root; - +use strict; +use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config->{namespace} = ''; diff --git a/t/lib/TestAppEncoding.pm b/t/lib/TestAppEncoding.pm new file mode 100644 index 0000000..53f50ff --- /dev/null +++ b/t/lib/TestAppEncoding.pm @@ -0,0 +1,11 @@ +package TestAppEncoding; +use strict; +use warnings; +use base qw/Catalyst/; +use Catalyst; + +__PACKAGE__->config(name => __PACKAGE__); +__PACKAGE__->setup; + +1; + diff --git a/t/lib/TestAppEncoding/Controller/Root.pm b/t/lib/TestAppEncoding/Controller/Root.pm new file mode 100644 index 0000000..b5b3eeb --- /dev/null +++ b/t/lib/TestAppEncoding/Controller/Root.pm @@ -0,0 +1,27 @@ +package TestAppEncoding::Controller::Root; +use strict; +use warnings; +use base 'Catalyst::Controller'; +use Test::More; + +__PACKAGE__->config->{namespace} = ''; + +sub binary : Local { + my ($self, $c) = @_; + $c->res->body(do { open(my $fh, '<', $c->path_to('..', '..', 'catalyst_130pix.gif')) or die $!; local $/ = undef; <$fh>; }); +} + +sub binary_utf8 : Local { + my ($self, $c) = @_; + $c->forward('binary'); + my $str = $c->res->body; + utf8::upgrade($str); + ok utf8::is_utf8($str), 'Body is variable width encoded string'; + $c->res->body($str); +} + +sub end : Private { + my ($self,$c) = @_; +} + +1; diff --git a/t/lib/TestAppPluginWithConstructor.pm b/t/lib/TestAppPluginWithConstructor.pm index 5b4b8c1..3d0d552 100644 --- a/t/lib/TestAppPluginWithConstructor.pm +++ b/t/lib/TestAppPluginWithConstructor.pm @@ -4,7 +4,7 @@ use Test::More; use Test::Exception; use Catalyst qw/+TestPluginWithConstructor/; use Moose; -BEGIN { extends qw/Catalyst Catalyst::Controller/ } # Ewww, FIXME. +extends qw/Catalyst/; __PACKAGE__->setup; our $MODIFIER_FIRED = 0;