From 5f47d5799bb96245f445fdfd5f4a6d16334051e6 Mon Sep 17 00:00:00 2001 From: Lee Johnson Date: Sun, 8 Mar 2015 17:04:36 +0100 Subject: [PATCH] resolve leejo/cgi-fast#11 - restore CGI::Fast imports CGI::Fast used to be a drop in replacement for CGI up until i broke this behaviour by adding an explicit import sub in CGI::Fast which means the caller stack needs to be shifted down by one to make sure the functions are imported into the correct namespace[1] [1] i'm not so sure this is the "right thing" to do, but from a back compat point of view it needs to remain --- Changes | 6 +++++- lib/CGI.pm | 11 ++++++++++- lib/CGI/Carp.pm | 2 +- lib/CGI/Cookie.pm | 2 +- lib/CGI/File/Temp.pm | 2 +- lib/CGI/Pretty.pm | 2 +- lib/CGI/Push.pm | 2 +- lib/CGI/Util.pm | 2 +- lib/Fh.pm | 2 +- 9 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Changes b/Changes index 0e6e9681..bf095a66 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,4 @@ -4.13_03 2015-03-01 +4.13_04 2015-03-08 [ RELEASE NOTES ] - This release removes the AUTOLOAD and compile optimisations from CGI.pm @@ -47,6 +47,10 @@ - Fix warning for lack of HTTP_USER_AGENT in CGI::Carp (GH #168) + - Fix imports when called from CGI::Fast, restores the import of CGI functions + into the callers namespace for users of CGI::Fast (GH leejo/cgi-fast#11 and + GH leejo/cgi-fast#12) + [ INTERNALS ] - Remove dependency on constant - internal DEBUG, XHTML_DTD and EBCDIC constants changes to $_DEBUG, $_XHTML_DTD, and $_EBCDIC diff --git a/lib/CGI.pm b/lib/CGI.pm index 4b3d8e07..c335af98 100644 --- a/lib/CGI.pm +++ b/lib/CGI.pm @@ -3,7 +3,7 @@ require 5.008001; use if $] >= 5.019, 'deprecate'; use Carp 'croak'; -$CGI::VERSION='4.13_03'; +$CGI::VERSION='4.13_04'; use CGI::Util qw(rearrange rearrange_header make_attributes unescape escape expires ebcdic2ascii ascii2ebcdic); @@ -264,6 +264,15 @@ sub import { $self->_setup_symbols(@_); my ($callpack, $callfile, $callline) = caller; + if ( $callpack eq 'CGI::Fast' ) { + # fixes GH #11 (and GH #12 in CGI::Fast since + # sub import was added to CGI::Fast in 9537f90 + # so we need to move up a level to export the + # routines to the namespace of whatever is using + # CGI::Fast + ($callpack, $callfile, $callline) = caller(1); + } + # To allow overriding, search through the packages # Till we find one in which the correct subroutine is defined. my @packages = ($self,@{"$self\:\:ISA"}); diff --git a/lib/CGI/Carp.pm b/lib/CGI/Carp.pm index e7e3c040..5850ba09 100644 --- a/lib/CGI/Carp.pm +++ b/lib/CGI/Carp.pm @@ -322,7 +322,7 @@ use File::Spec; $main::SIG{__WARN__}=\&CGI::Carp::warn; -$CGI::Carp::VERSION = '4.13_03'; +$CGI::Carp::VERSION = '4.13_04'; $CGI::Carp::CUSTOM_MSG = undef; $CGI::Carp::DIE_HANDLER = undef; $CGI::Carp::TO_BROWSER = 1; diff --git a/lib/CGI/Cookie.pm b/lib/CGI/Cookie.pm index b42accfa..136338d9 100644 --- a/lib/CGI/Cookie.pm +++ b/lib/CGI/Cookie.pm @@ -5,7 +5,7 @@ use warnings; use if $] >= 5.019, 'deprecate'; -our $VERSION='4.13_03'; +our $VERSION='4.13_04'; use CGI::Util qw(rearrange unescape escape); use overload '""' => \&as_string, 'cmp' => \&compare, 'fallback' => 1; diff --git a/lib/CGI/File/Temp.pm b/lib/CGI/File/Temp.pm index e9958f4f..d470a62d 100644 --- a/lib/CGI/File/Temp.pm +++ b/lib/CGI/File/Temp.pm @@ -3,7 +3,7 @@ # you use it directly and your code breaks horribly. package CGI::File::Temp; -$CGI::File::Temp::VERSION = '4.13_03'; +$CGI::File::Temp::VERSION = '4.13_04'; use parent File::Temp; use parent Fh; diff --git a/lib/CGI/Pretty.pm b/lib/CGI/Pretty.pm index 2f7c3a33..f1d1e4df 100644 --- a/lib/CGI/Pretty.pm +++ b/lib/CGI/Pretty.pm @@ -4,7 +4,7 @@ use strict; use if $] >= 5.019, 'deprecate'; use CGI (); -$CGI::Pretty::VERSION = '4.13_03'; +$CGI::Pretty::VERSION = '4.13_04'; $CGI::DefaultClass = __PACKAGE__; $CGI::Pretty::AutoloadClass = 'CGI'; @CGI::Pretty::ISA = qw( CGI ); diff --git a/lib/CGI/Push.pm b/lib/CGI/Push.pm index a4a39d96..8fd1aa49 100644 --- a/lib/CGI/Push.pm +++ b/lib/CGI/Push.pm @@ -1,7 +1,7 @@ package CGI::Push; use if $] >= 5.019, 'deprecate'; -$CGI::Push::VERSION='4.13_03'; +$CGI::Push::VERSION='4.13_04'; use CGI; use CGI::Util 'rearrange'; @ISA = ('CGI'); diff --git a/lib/CGI/Util.pm b/lib/CGI/Util.pm index b8b41a0f..538fc5ef 100644 --- a/lib/CGI/Util.pm +++ b/lib/CGI/Util.pm @@ -6,7 +6,7 @@ use if $] >= 5.019, 'deprecate'; our @EXPORT_OK = qw(rearrange rearrange_header make_attributes unescape escape expires ebcdic2ascii ascii2ebcdic); -our $VERSION = '4.13_03'; +our $VERSION = '4.13_04'; our $_EBCDIC = "\t" ne "\011"; diff --git a/lib/Fh.pm b/lib/Fh.pm index 87accda6..6cd66467 100644 --- a/lib/Fh.pm +++ b/lib/Fh.pm @@ -2,6 +2,6 @@ # that the filehandle object is a Fh package Fh; -$Fh::VERSION = '4.13_03'; +$Fh::VERSION = '4.13_04'; 1;