diff --git a/Changes b/Changes index 021054df..5d661cb6 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,31 @@ +4.13_01 2015-02-12 + + [ RELEASE NOTES ] + - This release removes the AUTOLOAD and compile optimisations from CGI.pm + that were introduced into CGI.pm many years ago (15+?) as a response to + its large size, which meant there was a significant compile time penalty. + This essentially deprecates the -compile pragma and ->compile method (the + -compile pragma will no longer do anything, whereas the ->compile method + will raise a deprecation warning). + + - This optimisation is no longer relevant and makes the code difficult to + deal with as well as making test coverage metrics incorrect. Benchmarks + show that advantages of AUTOLOAD / lazy loading / deferred compile are + less than 0.05s, which will be dwarfed by just about any meaningful code + in a cgi script. If this is an issue for you then you should look at + running CGI.pm in a persistent environment (FCGI, etc) + + - To offset some of the time added by removing the AUTOLOAD functionality + the dependencies have been made runtime rather than compile time. The + POD has also been split into its own file. CGI.pm now contains around + 4000 lines of code, which compared to some modules on CPAN isn't really + that much + + - Although this release should be back compatible you are encouraged to + test it throughly as if you are doing anything out of the ordinary with + CGI.pm (i.e. have bugs that may have been masked by the AUTOLOAD feature) + you may see some issues. References: GH #162, GH #137. + 4.13 2014-12-18 [ RELEASE NOTES ] diff --git a/MANIFEST b/MANIFEST index 1a57f7c3..10c3334a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -61,6 +61,7 @@ t/headers/target.t t/headers/type.t t/hidden.t t/html.t +t/html_functions.t t/http.t t/init.t t/init_test.txt diff --git a/lib/CGI.pm b/lib/CGI.pm index f96fbcff..440a4545 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'; +$CGI::VERSION='4.13_01'; use CGI::Util qw(rearrange rearrange_header make_attributes unescape escape expires ebcdic2ascii ascii2ebcdic); @@ -822,47 +822,41 @@ sub binmode { } # back compatibility html tag generation functions +sub compile { + warn "->compile / -compile is DEPRECATED"; +} + sub _all_html_tags { - # https://developer.mozilla.org/en-US/docs/Web/HTML/Element return qw/ - a abbr acronym address applet area article aside audio - b base basefont bdi bdo bgsound big blink blockquote body br - canvas caption center cite code col colgroup content - data datalist dd decorator del details dfn dialog dir div dl dt - element em embed - fieldset figcaption figure font footer frame frameset - h1 h2 h3 h4 h5 h6 head hgroup hr + a abbr acronym address applet + b base basefont bdo big blink blockquote body br + caption center cite code col colgroup + dd del dfn div dl dt + em embed + fieldset font frame frameset + h1 h2 h3 h4 h5 h6 head hr i iframe img input ins - kbd keygen - label legend li link listing - main map mark marquee menu menuitem meta meter - nav nobr noframes noscript - object ol option output - p picture plaintext pre progress - q - rp rt ruby - s samp script section select shadow small source spacer span - strike strong style sub summary sup - table tbody td template tfoot th thead time title tr track tt + kbd + label legend li + menu meta + nobr noframes noscript + object ol option + p pre + samp script small span + strike strong style sup + table tbody td tfoot th thead title tt u ul - var video - wbr - xmp + var / } -foreach my $tag ( - _all_html_tags(), - ( map { uc( $_ ) } _all_html_tags() ) -) { +foreach my $tag ( _all_html_tags() ) { eval "sub $tag { return _tag_func(\$tag,\@_); }"; foreach my $start_end ( qw/ start end / ) { - my $start_end_function = "${start_end}_${tag}"; - eval "sub $start_end_function { return _tag_func(\$start_end_function,\@_); }"; diff --git a/lib/CGI/Carp.pm b/lib/CGI/Carp.pm index 549501fc..c81d2864 100644 --- a/lib/CGI/Carp.pm +++ b/lib/CGI/Carp.pm @@ -318,7 +318,7 @@ use File::Spec; $main::SIG{__WARN__}=\&CGI::Carp::warn; -$CGI::Carp::VERSION = '4.13'; +$CGI::Carp::VERSION = '4.13_01'; $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 bfc6aa6d..22468556 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'; +our $VERSION='4.13_01'; 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 51c25e05..ab8cdd39 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'; +$CGI::File::Temp::VERSION = '4.13_01'; use parent File::Temp; use parent Fh; diff --git a/lib/CGI/Pretty.pm b/lib/CGI/Pretty.pm index 1d8b088d..f9ea4f42 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'; +$CGI::Pretty::VERSION = '4.13_01'; $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 864b512c..bf2c4e50 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'; +$CGI::Push::VERSION='4.13_01'; use CGI; use CGI::Util 'rearrange'; @ISA = ('CGI'); diff --git a/lib/CGI/Util.pm b/lib/CGI/Util.pm index 84a441c8..797bc04d 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'; +our $VERSION = '4.13_01'; use constant EBCDIC => "\t" ne "\011"; diff --git a/lib/Fh.pm b/lib/Fh.pm index 35b2fd8b..958ea6c7 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'; +$Fh::VERSION = '4.13_01'; 1; diff --git a/t/end_form.t b/t/end_form.t index 6863790d..6a13e0b0 100644 --- a/t/end_form.t +++ b/t/end_form.t @@ -4,6 +4,6 @@ use warnings; use Test::More tests => 2; -BEGIN { use_ok 'CGI', qw/ -compile :form / }; +BEGIN { use_ok 'CGI', qw/ :form / }; is end_form() => '', 'end_form()'; diff --git a/t/html_functions.t b/t/html_functions.t new file mode 100644 index 00000000..ba6ac3c1 --- /dev/null +++ b/t/html_functions.t @@ -0,0 +1,27 @@ +#!perl + +use strict; +use warnings; + +use Test::More 'no_plan'; + +use CGI qw/ -compile :all /; + +# check html functions are imported into this namespace +# with the -compile pragma +is( a({ bar => "boz" }),"","-compile" ); + +my $q = CGI->new; + +foreach my $tag ( $q->_all_html_tags ) { + + is( $q->$tag( { bar => 'boz' } ),"<$tag bar=\"boz\" />","$tag function" ); + + my $start = "start_$tag"; + is( $q->$start( 'foo' ),"<$tag>","$start function" ); + + my $end = "end_$tag"; + is( $q->$end( 'foo' ),"","$end function" ); +} + +ok( $q->compile,'compile' );