You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Geoffrey Young <ge...@modperlcookbook.org> on 2007/01/16 15:00:46 UTC
Re: MP 2.0.3 & Apache 2.2.3 -> auth tests fail
> Back to 2.2.4 - MP2.0.3 worked with one alteration. It seems that
> ap_get_server_version is not only depreciated, but also changed
> functionality. That is... one test fails because it calls
> get_server_version, expects "Apache 2.2.4 (Unix)" but gets "Apache
> 2.2.4".
ugh. I guess we haven't been paying attention. the relevant changes
are these:
Changes with Apache 2.2.4
*) The full server version information is now included in the error log at
startup as well as server status reports, irrespective of the setting
of the ServerTokens directive. ap_get_server_version() is now
deprecated, and is replaced by ap_get_server_banner() and
ap_get_server_description(). [Jeff Trawick]
Changes with Apache 2.3.0
*) ap_get_server_version() has been removed. Third-party modules must
now use ap_get_server_banner() or ap_get_server_description().
[Jeff Trawick]
so we'll need to address these.
fwiw, there are lots of changes in 2.2.0 and above that simplay haven't
been incorporated into mod_perl yet, simply for lack of developer tuits.
so, help/patches in this respect most welcome. come on and join
dev@perl.a.o if you're interested :)
> This can be solved by applying the following patch:
> But note that this is not a backwards compatible patch.
yeah, we can't bork back compat. but there is a way to maintain compat
between moving APIs via modperl_apache_compat.c. right now that file is
empty, but you can see what entries would look like by peeking at old
versions in svn.
I suspect what we'd want would be to hack the map to
o add ap_get_server_banner and ap_get_server_description to the apache
function map and mark them both as mod_perl implemented
o add code to modperl_apache_compat.(c|h) to implement stubs for those
routines if not currently defined, or callback to them if defined
o mark ap_get_server_version as mod_perl implemented
o add a stub for ap_get_server_version if not defined with a warning
that the function is deprecated (else issue the callback)
we did a similar workaround for something else, but I forget what it
was. svn history will know, however.
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: MP 2.0.3 & Apache 2.2.3 -> auth tests fail
Posted by Fred Moyer <fr...@taperfriendlymusic.org>.
Philippe M. Chiasson wrote:
> Geoffrey Young wrote:
>>
>> we did a similar workaround for something else, but I forget what it
>> was. svn history will know, however.
>
> Or just have a look at this patch ;-)
>
> Index: src/modules/perl/modperl_apache_compat.c
> ===================================================================
> --- src/modules/perl/modperl_apache_compat.c (revision 504721)
> +++ src/modules/perl/modperl_apache_compat.c (working copy)
> @@ -27,3 +27,45 @@
> * and don't forget to insert comments explaining exactly
> * which httpd release allows us to remove the compat code
> */
> +
> +/* pre-APACHE_2.2.4 */
> +#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4)
Mmmmm, mod_perl internals, yummy :) Here is a doc patch I
s/(version)/($1|description|banner)/ ^W^W wrote up for it.
Index: docs/api/Apache2/ServerUtil.pod
===================================================================
--- docs/api/Apache2/ServerUtil.pod (revision 500867)
+++ docs/api/Apache2/ServerUtil.pod (working copy)
@@ -27,9 +27,11 @@
@handlers = @{ $s->get_handlers('PerlChildExitHandler') || []};
# server build and version info:
- $when_built = Apache2::ServerUtil::get_server_built();
+ $when_built = Apache2::ServerUtil::get_server_built();
+ $description = Apache2::ServerUtil::get_server_description();
$version = Apache2::ServerUtil::get_server_version();
-
+ $banner = Apache2::ServerUtil::get_server_banner();
+
# ServerRoot value
$server_root = Apache2::ServerUtil::server_root();
@@ -384,6 +386,56 @@
+=head2 C<get_server_banner>
+
+Get the server banner
+
+ $banner = Apache2::ServerUtil::get_server_banner();
+
+=over 4
+
+=item ret: C<$banner> ( string )
+
+The server banner
+
+=item since: 2.0.4
+
+=back
+
+
+
+
+
+
+
+
+
+=head2 C<get_server_description>
+
+Get the server description
+
+ $description = Apache2::ServerUtil::get_server_description();
+
+=over 4
+
+=item ret: C<$description> ( string )
+
+The server description
+
+=item since: 2.0.4
+
+=back
+
+
+
+
+
+
+
+
+
+
+
=head2 C<group_id>
Get the group id corresponding to the C<Group> directive in
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: MP 2.0.3 & Apache 2.2.3 -> auth tests fail
Posted by Philip Gollucci <pg...@p6m7g8.com>.
On Fri, 23 Mar 2007, Philip M. Gollucci wrote:
> Gozer,
>
> This looks good to me. It fixes t/api/server_const.t
> and the test suite now/still passes 100% for me.
>
> Do you want to commit it or should I.
> Thats a +1 btw.
>
> FYI:
> FreeBSD 6.2-RELEASE
> gcc 3.4.6
> perl 5.8.8 w/o ithreads
> httpd 2.2.4 ap(r,u) 1.2.8 w/o threads
> + apr_dbd_mysql and mysql 5.0.33
> mod_perl r521590 (aka trunk) including Fred's recent security patch.
Also tested 2.0.59.
Committed Revision: 532829
Doc's Revision: 532831
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: MP 2.0.3 & Apache 2.2.3 -> auth tests fail
Posted by Philip Gollucci <pg...@p6m7g8.com>.
On Fri, 23 Mar 2007, Philip M. Gollucci wrote:
> Gozer,
>
> This looks good to me. It fixes t/api/server_const.t
> and the test suite now/still passes 100% for me.
>
> Do you want to commit it or should I.
> Thats a +1 btw.
>
> FYI:
> FreeBSD 6.2-RELEASE
> gcc 3.4.6
> perl 5.8.8 w/o ithreads
> httpd 2.2.4 ap(r,u) 1.2.8 w/o threads
> + apr_dbd_mysql and mysql 5.0.33
> mod_perl r521590 (aka trunk) including Fred's recent security patch.
Also tested 2.0.59.
Committed Revision: 532829
Doc's Revision: 532831
Re: MP 2.0.3 & Apache 2.2.3 -> auth tests fail
Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Gozer,
This looks good to me. It fixes t/api/server_const.t
and the test suite now/still passes 100% for me.
Do you want to commit it or should I.
Thats a +1 btw.
FYI:
FreeBSD 6.2-RELEASE
gcc 3.4.6
perl 5.8.8 w/o ithreads
httpd 2.2.4 ap(r,u) 1.2.8 w/o threads
+ apr_dbd_mysql and mysql 5.0.33
mod_perl r521590 (aka trunk) including Fred's recent security patch.
> Index: src/modules/perl/modperl_apache_compat.c
> ===================================================================
> --- src/modules/perl/modperl_apache_compat.c (revision 504721)
> +++ src/modules/perl/modperl_apache_compat.c (working copy)
> @@ -27,3 +27,45 @@
> * and don't forget to insert comments explaining exactly
> * which httpd release allows us to remove the compat code
> */
> +
> +/* pre-APACHE_2.2.4 */
> +#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4)
> +
> +#define modperl_warn_fallback_http_function(ver, fallback) \
> + { \
> + dTHX; \
> + Perl_warn(aTHX_ "%s() not available until httpd/%s " \
> + "falling back to %s()", \
> + __func__, ver, fallback); \
> + }
> +
> +/* added in APACHE_2.2.4 */
> +AP_DECLARE(const char *) ap_get_server_description(void) {
> + modperl_warn_fallback_http_function("2.2.4", "ap_get_server_version");
> + return ap_get_server_version();
> +}
> +
> +AP_DECLARE(const char *) ap_get_server_banner(void) {
> + modperl_warn_fallback_http_function("2.2.4", "ap_get_server_version");
> + return ap_get_server_version();
> +}
> +
> +#endif /* pre-APACHE_2.2.4 */
> +
> +/* since-APACHE-2.3.0 */
> +#if AP_MODULE_MAGIC_AT_LEAST(20060905,0)
> +#define modperl_warn_deprecated_http_function(ver, fallback) \
> + { \
> + dTHX; \
> + Perl_warn(aTHX_ "%s() is deprecated since httpd/%s " \
> + "try using %s() instead", \
> + __func__, ver, fallback); \
> + }
> +
> +AP_DECLARE(const char *) ap_get_server_version(void) {
> + modperl_warn_deprecated_http_function("2.3.0",
> + "ap_get_server_(description|banner)");
> + return ap_get_server_banner();
> +}
> +
> +#endif /* since-APACHE-2.3.0 */
> Index: src/modules/perl/modperl_apache_compat.h
> ===================================================================
> --- src/modules/perl/modperl_apache_compat.h (revision 504721)
> +++ src/modules/perl/modperl_apache_compat.h (working copy)
> @@ -36,6 +36,23 @@
> * which httpd release allows us to remove the compat code
> */
>
> +/* pre-APACHE_2.2.4 */
> +#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4)
> +
> +/* added in APACHE_2.2.4 */
> +AP_DECLARE(const char *) ap_get_server_description(void);
> +AP_DECLARE(const char *) ap_get_server_banner(void);
> +
> +#endif /* pre-APACHE_2.2.4 */
> +
> +/* since-APACHE-2.3.0 */
> +#if AP_MODULE_MAGIC_AT_LEAST(20060905,0)
> +
> +/* removed in APACHE-2.3.0 */
> +AP_DECLARE(const char *) ap_get_server_version(void);
> +
> +#endif /* since-APACHE-2.3.0 */
> +
> /* ap_http_scheme is called ap_http_method in httpd 2.0 */
> #ifndef ap_http_scheme
> #define ap_http_scheme(r) ap_http_method(r)
> Index: xs/maps/apache2_functions.map
> ===================================================================
> --- xs/maps/apache2_functions.map (revision 504721)
> +++ xs/maps/apache2_functions.map (working copy)
> @@ -176,6 +176,8 @@
> !ap_get_local_host
> ~ap_get_server_built
> ~ap_get_server_version
> +~ap_get_server_banner
> +~ap_get_server_description
> ~ap_server_root
>
>
> Index: xs/Apache2/ServerUtil/Apache2__ServerUtil.h
> ===================================================================
> --- xs/Apache2/ServerUtil/Apache2__ServerUtil.h (revision 504721)
> +++ xs/Apache2/ServerUtil/Apache2__ServerUtil.h (working copy)
> @@ -195,4 +195,10 @@
>
> newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_version",
> newSVpv(ap_get_server_version(), 0));
> +
> + newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_banner",
> + newSVpv(ap_get_server_banner(), 0));
> +
> + newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_description",
> + newSVpv(ap_get_server_description(), 0));
> }
> Index: xs/tables/current/Apache2/FunctionTable.pm
> ===================================================================
> --- xs/tables/current/Apache2/FunctionTable.pm (revision 504721)
> +++ xs/tables/current/Apache2/FunctionTable.pm (working copy)
> @@ -1476,6 +1476,16 @@
> },
> {
> 'return_type' => 'const char *',
> + 'name' => 'ap_get_server_description',
> + 'args' => []
> + },
> + {
> + 'return_type' => 'const char *',
> + 'name' => 'ap_get_server_banner',
> + 'args' => []
> + },
> + {
> + 'return_type' => 'const char *',
> 'name' => 'ap_get_status_line',
> 'args' => [
> {
> Index: t/response/TestAPI/server_const.pm
> ===================================================================
> --- t/response/TestAPI/server_const.pm (revision 504721)
> +++ t/response/TestAPI/server_const.pm (working copy)
> @@ -24,7 +24,7 @@
>
> my $r = shift;
>
> - plan $r, tests => 3;
> + plan $r, tests => 5;
>
> # test Apache2::ServerUtil constant subroutines
>
> @@ -36,10 +36,20 @@
> $built,
> 'Apache2::ServerUtil::get_server_built()');
>
> - ok t_cmp(Apache2::ServerUtil::get_server_version,
> + ok t_cmp(Apache2::ServerUtil::get_server_description,
> $version,
> + 'Apache2::ServerUtil::get_server_description()');
> +
> + my $server_version = Apache2::ServerUtil::get_server_version;
> + ok t_cmp($version,
> + qr/^$server_version/,
> 'Apache2::ServerUtil::get_server_version()');
>
> + my $server_banner = Apache2::ServerUtil::get_server_banner;
> + ok t_cmp($version,
> + qr/^$server_banner/,
> + 'Apache2::ServerUtil::get_server_banner()');
> +
> Apache2::Const::OK;
> }
>
>
>
> --------------------------------------------------------------------------------
> Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
> http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
>
--
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/EC88A0BF 0DE5 C55C 6BF3 B235 2DAB B89E 1324 9B4F EC88 A0BF
Work like you don't need the money,
love like you'll never get hurt,
and dance like nobody's watching.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: MP 2.0.3 & Apache 2.2.3 -> auth tests fail
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Or just have a look at this patch ;-)
wicked cool!
> - ok t_cmp(Apache2::ServerUtil::get_server_version,
> + ok t_cmp(Apache2::ServerUtil::get_server_description,
all the tests will need some sort of get_min_apache_version() foo
wrapping, no?
other than that, excellent. gozer++
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: MP 2.0.3 & Apache 2.2.3 -> auth tests fail
Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Gozer,
This looks good to me. It fixes t/api/server_const.t
and the test suite now/still passes 100% for me.
Do you want to commit it or should I.
Thats a +1 btw.
FYI:
FreeBSD 6.2-RELEASE
gcc 3.4.6
perl 5.8.8 w/o ithreads
httpd 2.2.4 ap(r,u) 1.2.8 w/o threads
+ apr_dbd_mysql and mysql 5.0.33
mod_perl r521590 (aka trunk) including Fred's recent security patch.
> Index: src/modules/perl/modperl_apache_compat.c
> ===================================================================
> --- src/modules/perl/modperl_apache_compat.c (revision 504721)
> +++ src/modules/perl/modperl_apache_compat.c (working copy)
> @@ -27,3 +27,45 @@
> * and don't forget to insert comments explaining exactly
> * which httpd release allows us to remove the compat code
> */
> +
> +/* pre-APACHE_2.2.4 */
> +#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4)
> +
> +#define modperl_warn_fallback_http_function(ver, fallback) \
> + { \
> + dTHX; \
> + Perl_warn(aTHX_ "%s() not available until httpd/%s " \
> + "falling back to %s()", \
> + __func__, ver, fallback); \
> + }
> +
> +/* added in APACHE_2.2.4 */
> +AP_DECLARE(const char *) ap_get_server_description(void) {
> + modperl_warn_fallback_http_function("2.2.4", "ap_get_server_version");
> + return ap_get_server_version();
> +}
> +
> +AP_DECLARE(const char *) ap_get_server_banner(void) {
> + modperl_warn_fallback_http_function("2.2.4", "ap_get_server_version");
> + return ap_get_server_version();
> +}
> +
> +#endif /* pre-APACHE_2.2.4 */
> +
> +/* since-APACHE-2.3.0 */
> +#if AP_MODULE_MAGIC_AT_LEAST(20060905,0)
> +#define modperl_warn_deprecated_http_function(ver, fallback) \
> + { \
> + dTHX; \
> + Perl_warn(aTHX_ "%s() is deprecated since httpd/%s " \
> + "try using %s() instead", \
> + __func__, ver, fallback); \
> + }
> +
> +AP_DECLARE(const char *) ap_get_server_version(void) {
> + modperl_warn_deprecated_http_function("2.3.0",
> + "ap_get_server_(description|banner)");
> + return ap_get_server_banner();
> +}
> +
> +#endif /* since-APACHE-2.3.0 */
> Index: src/modules/perl/modperl_apache_compat.h
> ===================================================================
> --- src/modules/perl/modperl_apache_compat.h (revision 504721)
> +++ src/modules/perl/modperl_apache_compat.h (working copy)
> @@ -36,6 +36,23 @@
> * which httpd release allows us to remove the compat code
> */
>
> +/* pre-APACHE_2.2.4 */
> +#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4)
> +
> +/* added in APACHE_2.2.4 */
> +AP_DECLARE(const char *) ap_get_server_description(void);
> +AP_DECLARE(const char *) ap_get_server_banner(void);
> +
> +#endif /* pre-APACHE_2.2.4 */
> +
> +/* since-APACHE-2.3.0 */
> +#if AP_MODULE_MAGIC_AT_LEAST(20060905,0)
> +
> +/* removed in APACHE-2.3.0 */
> +AP_DECLARE(const char *) ap_get_server_version(void);
> +
> +#endif /* since-APACHE-2.3.0 */
> +
> /* ap_http_scheme is called ap_http_method in httpd 2.0 */
> #ifndef ap_http_scheme
> #define ap_http_scheme(r) ap_http_method(r)
> Index: xs/maps/apache2_functions.map
> ===================================================================
> --- xs/maps/apache2_functions.map (revision 504721)
> +++ xs/maps/apache2_functions.map (working copy)
> @@ -176,6 +176,8 @@
> !ap_get_local_host
> ~ap_get_server_built
> ~ap_get_server_version
> +~ap_get_server_banner
> +~ap_get_server_description
> ~ap_server_root
>
>
> Index: xs/Apache2/ServerUtil/Apache2__ServerUtil.h
> ===================================================================
> --- xs/Apache2/ServerUtil/Apache2__ServerUtil.h (revision 504721)
> +++ xs/Apache2/ServerUtil/Apache2__ServerUtil.h (working copy)
> @@ -195,4 +195,10 @@
>
> newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_version",
> newSVpv(ap_get_server_version(), 0));
> +
> + newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_banner",
> + newSVpv(ap_get_server_banner(), 0));
> +
> + newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_description",
> + newSVpv(ap_get_server_description(), 0));
> }
> Index: xs/tables/current/Apache2/FunctionTable.pm
> ===================================================================
> --- xs/tables/current/Apache2/FunctionTable.pm (revision 504721)
> +++ xs/tables/current/Apache2/FunctionTable.pm (working copy)
> @@ -1476,6 +1476,16 @@
> },
> {
> 'return_type' => 'const char *',
> + 'name' => 'ap_get_server_description',
> + 'args' => []
> + },
> + {
> + 'return_type' => 'const char *',
> + 'name' => 'ap_get_server_banner',
> + 'args' => []
> + },
> + {
> + 'return_type' => 'const char *',
> 'name' => 'ap_get_status_line',
> 'args' => [
> {
> Index: t/response/TestAPI/server_const.pm
> ===================================================================
> --- t/response/TestAPI/server_const.pm (revision 504721)
> +++ t/response/TestAPI/server_const.pm (working copy)
> @@ -24,7 +24,7 @@
>
> my $r = shift;
>
> - plan $r, tests => 3;
> + plan $r, tests => 5;
>
> # test Apache2::ServerUtil constant subroutines
>
> @@ -36,10 +36,20 @@
> $built,
> 'Apache2::ServerUtil::get_server_built()');
>
> - ok t_cmp(Apache2::ServerUtil::get_server_version,
> + ok t_cmp(Apache2::ServerUtil::get_server_description,
> $version,
> + 'Apache2::ServerUtil::get_server_description()');
> +
> + my $server_version = Apache2::ServerUtil::get_server_version;
> + ok t_cmp($version,
> + qr/^$server_version/,
> 'Apache2::ServerUtil::get_server_version()');
>
> + my $server_banner = Apache2::ServerUtil::get_server_banner;
> + ok t_cmp($version,
> + qr/^$server_banner/,
> + 'Apache2::ServerUtil::get_server_banner()');
> +
> Apache2::Const::OK;
> }
>
>
>
> --------------------------------------------------------------------------------
> Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
> http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
>
--
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/EC88A0BF 0DE5 C55C 6BF3 B235 2DAB B89E 1324 9B4F EC88 A0BF
Work like you don't need the money,
love like you'll never get hurt,
and dance like nobody's watching.
Re: MP 2.0.3 & Apache 2.2.3 -> auth tests fail
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Or just have a look at this patch ;-)
wicked cool!
> - ok t_cmp(Apache2::ServerUtil::get_server_version,
> + ok t_cmp(Apache2::ServerUtil::get_server_description,
all the tests will need some sort of get_min_apache_version() foo
wrapping, no?
other than that, excellent. gozer++
--Geoff
Re: MP 2.0.3 & Apache 2.2.3 -> auth tests fail
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Geoffrey Young wrote:
>> Back to 2.2.4 - MP2.0.3 worked with one alteration. It seems that
>> ap_get_server_version is not only depreciated, but also changed
>> functionality. That is... one test fails because it calls
>> get_server_version, expects "Apache 2.2.4 (Unix)" but gets "Apache
>> 2.2.4".
>
> [...]
>
>> This can be solved by applying the following patch:
>
>> But note that this is not a backwards compatible patch.
>
> yeah, we can't bork back compat. but there is a way to maintain compat
> between moving APIs via modperl_apache_compat.c. right now that file is
> empty, but you can see what entries would look like by peeking at old
> versions in svn.
Yes, that is probably the correct way to handle something like this, that
can be easily made backwards compatible.
> I suspect what we'd want would be to hack the map to
>
> o add ap_get_server_banner and ap_get_server_description to the apache
> function map and mark them both as mod_perl implemented
>
> o add code to modperl_apache_compat.(c|h) to implement stubs for those
> routines if not currently defined, or callback to them if defined
>
> o mark ap_get_server_version as mod_perl implemented
>
> o add a stub for ap_get_server_version if not defined with a warning
> that the function is deprecated (else issue the callback)
>
> we did a similar workaround for something else, but I forget what it
> was. svn history will know, however.
Or just have a look at this patch ;-)
Index: src/modules/perl/modperl_apache_compat.c
===================================================================
--- src/modules/perl/modperl_apache_compat.c (revision 504721)
+++ src/modules/perl/modperl_apache_compat.c (working copy)
@@ -27,3 +27,45 @@
* and don't forget to insert comments explaining exactly
* which httpd release allows us to remove the compat code
*/
+
+/* pre-APACHE_2.2.4 */
+#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4)
+
+#define modperl_warn_fallback_http_function(ver, fallback) \
+ { \
+ dTHX; \
+ Perl_warn(aTHX_ "%s() not available until httpd/%s " \
+ "falling back to %s()", \
+ __func__, ver, fallback); \
+ }
+
+/* added in APACHE_2.2.4 */
+AP_DECLARE(const char *) ap_get_server_description(void) {
+ modperl_warn_fallback_http_function("2.2.4", "ap_get_server_version");
+ return ap_get_server_version();
+}
+
+AP_DECLARE(const char *) ap_get_server_banner(void) {
+ modperl_warn_fallback_http_function("2.2.4", "ap_get_server_version");
+ return ap_get_server_version();
+}
+
+#endif /* pre-APACHE_2.2.4 */
+
+/* since-APACHE-2.3.0 */
+#if AP_MODULE_MAGIC_AT_LEAST(20060905,0)
+#define modperl_warn_deprecated_http_function(ver, fallback) \
+ { \
+ dTHX; \
+ Perl_warn(aTHX_ "%s() is deprecated since httpd/%s " \
+ "try using %s() instead", \
+ __func__, ver, fallback); \
+ }
+
+AP_DECLARE(const char *) ap_get_server_version(void) {
+ modperl_warn_deprecated_http_function("2.3.0",
+ "ap_get_server_(description|banner)");
+ return ap_get_server_banner();
+}
+
+#endif /* since-APACHE-2.3.0 */
Index: src/modules/perl/modperl_apache_compat.h
===================================================================
--- src/modules/perl/modperl_apache_compat.h (revision 504721)
+++ src/modules/perl/modperl_apache_compat.h (working copy)
@@ -36,6 +36,23 @@
* which httpd release allows us to remove the compat code
*/
+/* pre-APACHE_2.2.4 */
+#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4)
+
+/* added in APACHE_2.2.4 */
+AP_DECLARE(const char *) ap_get_server_description(void);
+AP_DECLARE(const char *) ap_get_server_banner(void);
+
+#endif /* pre-APACHE_2.2.4 */
+
+/* since-APACHE-2.3.0 */
+#if AP_MODULE_MAGIC_AT_LEAST(20060905,0)
+
+/* removed in APACHE-2.3.0 */
+AP_DECLARE(const char *) ap_get_server_version(void);
+
+#endif /* since-APACHE-2.3.0 */
+
/* ap_http_scheme is called ap_http_method in httpd 2.0 */
#ifndef ap_http_scheme
#define ap_http_scheme(r) ap_http_method(r)
Index: xs/maps/apache2_functions.map
===================================================================
--- xs/maps/apache2_functions.map (revision 504721)
+++ xs/maps/apache2_functions.map (working copy)
@@ -176,6 +176,8 @@
!ap_get_local_host
~ap_get_server_built
~ap_get_server_version
+~ap_get_server_banner
+~ap_get_server_description
~ap_server_root
Index: xs/Apache2/ServerUtil/Apache2__ServerUtil.h
===================================================================
--- xs/Apache2/ServerUtil/Apache2__ServerUtil.h (revision 504721)
+++ xs/Apache2/ServerUtil/Apache2__ServerUtil.h (working copy)
@@ -195,4 +195,10 @@
newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_version",
newSVpv(ap_get_server_version(), 0));
+
+ newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_banner",
+ newSVpv(ap_get_server_banner(), 0));
+
+ newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_description",
+ newSVpv(ap_get_server_description(), 0));
}
Index: xs/tables/current/Apache2/FunctionTable.pm
===================================================================
--- xs/tables/current/Apache2/FunctionTable.pm (revision 504721)
+++ xs/tables/current/Apache2/FunctionTable.pm (working copy)
@@ -1476,6 +1476,16 @@
},
{
'return_type' => 'const char *',
+ 'name' => 'ap_get_server_description',
+ 'args' => []
+ },
+ {
+ 'return_type' => 'const char *',
+ 'name' => 'ap_get_server_banner',
+ 'args' => []
+ },
+ {
+ 'return_type' => 'const char *',
'name' => 'ap_get_status_line',
'args' => [
{
Index: t/response/TestAPI/server_const.pm
===================================================================
--- t/response/TestAPI/server_const.pm (revision 504721)
+++ t/response/TestAPI/server_const.pm (working copy)
@@ -24,7 +24,7 @@
my $r = shift;
- plan $r, tests => 3;
+ plan $r, tests => 5;
# test Apache2::ServerUtil constant subroutines
@@ -36,10 +36,20 @@
$built,
'Apache2::ServerUtil::get_server_built()');
- ok t_cmp(Apache2::ServerUtil::get_server_version,
+ ok t_cmp(Apache2::ServerUtil::get_server_description,
$version,
+ 'Apache2::ServerUtil::get_server_description()');
+
+ my $server_version = Apache2::ServerUtil::get_server_version;
+ ok t_cmp($version,
+ qr/^$server_version/,
'Apache2::ServerUtil::get_server_version()');
+ my $server_banner = Apache2::ServerUtil::get_server_banner;
+ ok t_cmp($version,
+ qr/^$server_banner/,
+ 'Apache2::ServerUtil::get_server_banner()');
+
Apache2::Const::OK;
}
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Re: MP 2.0.3 & Apache 2.2.3 -> auth tests fail
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Geoffrey Young wrote:
>> Back to 2.2.4 - MP2.0.3 worked with one alteration. It seems that
>> ap_get_server_version is not only depreciated, but also changed
>> functionality. That is... one test fails because it calls
>> get_server_version, expects "Apache 2.2.4 (Unix)" but gets "Apache
>> 2.2.4".
>
> [...]
>
>> This can be solved by applying the following patch:
>
>> But note that this is not a backwards compatible patch.
>
> yeah, we can't bork back compat. but there is a way to maintain compat
> between moving APIs via modperl_apache_compat.c. right now that file is
> empty, but you can see what entries would look like by peeking at old
> versions in svn.
Yes, that is probably the correct way to handle something like this, that
can be easily made backwards compatible.
> I suspect what we'd want would be to hack the map to
>
> o add ap_get_server_banner and ap_get_server_description to the apache
> function map and mark them both as mod_perl implemented
>
> o add code to modperl_apache_compat.(c|h) to implement stubs for those
> routines if not currently defined, or callback to them if defined
>
> o mark ap_get_server_version as mod_perl implemented
>
> o add a stub for ap_get_server_version if not defined with a warning
> that the function is deprecated (else issue the callback)
>
> we did a similar workaround for something else, but I forget what it
> was. svn history will know, however.
Or just have a look at this patch ;-)
Index: src/modules/perl/modperl_apache_compat.c
===================================================================
--- src/modules/perl/modperl_apache_compat.c (revision 504721)
+++ src/modules/perl/modperl_apache_compat.c (working copy)
@@ -27,3 +27,45 @@
* and don't forget to insert comments explaining exactly
* which httpd release allows us to remove the compat code
*/
+
+/* pre-APACHE_2.2.4 */
+#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4)
+
+#define modperl_warn_fallback_http_function(ver, fallback) \
+ { \
+ dTHX; \
+ Perl_warn(aTHX_ "%s() not available until httpd/%s " \
+ "falling back to %s()", \
+ __func__, ver, fallback); \
+ }
+
+/* added in APACHE_2.2.4 */
+AP_DECLARE(const char *) ap_get_server_description(void) {
+ modperl_warn_fallback_http_function("2.2.4", "ap_get_server_version");
+ return ap_get_server_version();
+}
+
+AP_DECLARE(const char *) ap_get_server_banner(void) {
+ modperl_warn_fallback_http_function("2.2.4", "ap_get_server_version");
+ return ap_get_server_version();
+}
+
+#endif /* pre-APACHE_2.2.4 */
+
+/* since-APACHE-2.3.0 */
+#if AP_MODULE_MAGIC_AT_LEAST(20060905,0)
+#define modperl_warn_deprecated_http_function(ver, fallback) \
+ { \
+ dTHX; \
+ Perl_warn(aTHX_ "%s() is deprecated since httpd/%s " \
+ "try using %s() instead", \
+ __func__, ver, fallback); \
+ }
+
+AP_DECLARE(const char *) ap_get_server_version(void) {
+ modperl_warn_deprecated_http_function("2.3.0",
+ "ap_get_server_(description|banner)");
+ return ap_get_server_banner();
+}
+
+#endif /* since-APACHE-2.3.0 */
Index: src/modules/perl/modperl_apache_compat.h
===================================================================
--- src/modules/perl/modperl_apache_compat.h (revision 504721)
+++ src/modules/perl/modperl_apache_compat.h (working copy)
@@ -36,6 +36,23 @@
* which httpd release allows us to remove the compat code
*/
+/* pre-APACHE_2.2.4 */
+#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4)
+
+/* added in APACHE_2.2.4 */
+AP_DECLARE(const char *) ap_get_server_description(void);
+AP_DECLARE(const char *) ap_get_server_banner(void);
+
+#endif /* pre-APACHE_2.2.4 */
+
+/* since-APACHE-2.3.0 */
+#if AP_MODULE_MAGIC_AT_LEAST(20060905,0)
+
+/* removed in APACHE-2.3.0 */
+AP_DECLARE(const char *) ap_get_server_version(void);
+
+#endif /* since-APACHE-2.3.0 */
+
/* ap_http_scheme is called ap_http_method in httpd 2.0 */
#ifndef ap_http_scheme
#define ap_http_scheme(r) ap_http_method(r)
Index: xs/maps/apache2_functions.map
===================================================================
--- xs/maps/apache2_functions.map (revision 504721)
+++ xs/maps/apache2_functions.map (working copy)
@@ -176,6 +176,8 @@
!ap_get_local_host
~ap_get_server_built
~ap_get_server_version
+~ap_get_server_banner
+~ap_get_server_description
~ap_server_root
Index: xs/Apache2/ServerUtil/Apache2__ServerUtil.h
===================================================================
--- xs/Apache2/ServerUtil/Apache2__ServerUtil.h (revision 504721)
+++ xs/Apache2/ServerUtil/Apache2__ServerUtil.h (working copy)
@@ -195,4 +195,10 @@
newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_version",
newSVpv(ap_get_server_version(), 0));
+
+ newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_banner",
+ newSVpv(ap_get_server_banner(), 0));
+
+ newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_description",
+ newSVpv(ap_get_server_description(), 0));
}
Index: xs/tables/current/Apache2/FunctionTable.pm
===================================================================
--- xs/tables/current/Apache2/FunctionTable.pm (revision 504721)
+++ xs/tables/current/Apache2/FunctionTable.pm (working copy)
@@ -1476,6 +1476,16 @@
},
{
'return_type' => 'const char *',
+ 'name' => 'ap_get_server_description',
+ 'args' => []
+ },
+ {
+ 'return_type' => 'const char *',
+ 'name' => 'ap_get_server_banner',
+ 'args' => []
+ },
+ {
+ 'return_type' => 'const char *',
'name' => 'ap_get_status_line',
'args' => [
{
Index: t/response/TestAPI/server_const.pm
===================================================================
--- t/response/TestAPI/server_const.pm (revision 504721)
+++ t/response/TestAPI/server_const.pm (working copy)
@@ -24,7 +24,7 @@
my $r = shift;
- plan $r, tests => 3;
+ plan $r, tests => 5;
# test Apache2::ServerUtil constant subroutines
@@ -36,10 +36,20 @@
$built,
'Apache2::ServerUtil::get_server_built()');
- ok t_cmp(Apache2::ServerUtil::get_server_version,
+ ok t_cmp(Apache2::ServerUtil::get_server_description,
$version,
+ 'Apache2::ServerUtil::get_server_description()');
+
+ my $server_version = Apache2::ServerUtil::get_server_version;
+ ok t_cmp($version,
+ qr/^$server_version/,
'Apache2::ServerUtil::get_server_version()');
+ my $server_banner = Apache2::ServerUtil::get_server_banner;
+ ok t_cmp($version,
+ qr/^$server_banner/,
+ 'Apache2::ServerUtil::get_server_banner()');
+
Apache2::Const::OK;
}
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5