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
signature.asc
Description: OpenPGP digital signature