Christian Laursen wrote:
I have a small problem with Apache::compat.

I have got some mp1 code running under mp2 using Apache::compat,
but I had to change it a little bit in order to do that.

A few places we have the following:

use Apache::Constants qw(:common :response);

It looks like the response group is missing in Apache::Constants
when running under mp2 with Apache::compat as we get this error:

[Tue Oct 21 13:51:14 2003] [error] [client 127.0.0.1] unknown apache:: group `re
sponse' at /usr/local/lib/perl5/site_perl/5.8.0/mach/Apache2/Apache/compat.pm li
ne 151.

Changing it to "use Apache::Constants qw(:common);" makes it work, but I suspect
that a few constants will then be missing when running it under mp1.

This is with mod_perl/1.99_10. I checked the Changelog via cvsweb, and there
doesn't seem to be any changes regarding this.

As far as I can tell this is a small bug in Apache::compat. If I'm wrong feel
free to enlighten me.

nope, you're right - Apache::compat just passes whatever import tags you specify to Apache::Const, and there's no :response tag in mp2.


the only real reason I've ever seen anyone use :response is for REDIRECT, which now exists in :common, so I suspect that's why your code worked.

anyway, try this patch (against current CVS - I'm not sure if there have been changes since the last release) which weeds out attempts to import non-existent tags.

we still don't handle everything in compat.pm (such as MOVED, USE_LOCAL_COPY, etc) but I don't really see a reason for supporting these right now - :response is probably fairly common, as it exists in the eagle book and lots of examples, but the rest are pretty rare in my experience.

anyway, let me know if it works for you. if not, we'll try something else.

--Geoff
Index: lib/Apache/compat.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/lib/Apache/compat.pm,v
retrieving revision 1.88
diff -u -r1.88 compat.pm
--- lib/Apache/compat.pm        30 Aug 2003 02:33:26 -0000      1.88
+++ lib/Apache/compat.pm        21 Oct 2003 13:00:07 -0000
@@ -148,7 +148,11 @@
 sub import {
     my $class = shift;
     my $package = scalar caller;
-    Apache::Const->compile($package => @_);
+
+    # skip over import tags that don't exist in mp2
+    my @args = grep { !/:response|:server|:args_how/ } @_;
+
+    Apache::Const->compile($package => @args);
 }
 
 #no need to support in 2.0
Index: t/response/TestCompat/apache.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/t/response/TestCompat/apache.pm,v
retrieving revision 1.6
diff -u -r1.6 apache.pm
--- t/response/TestCompat/apache.pm     19 Sep 2003 00:37:09 -0000      1.6
+++ t/response/TestCompat/apache.pm     21 Oct 2003 13:00:07 -0000
@@ -11,12 +11,12 @@
 use Apache::Test;
 
 use Apache::compat ();
-use Apache::Constants qw(OK DIR_MAGIC_TYPE);
+use Apache::Constants qw(DIR_MAGIC_TYPE :common :response);
 
 sub handler {
     my $r = shift;
 
-    plan $r, tests => 8;
+    plan $r, tests => 11;
 
     $r->send_http_header('text/plain');
 
@@ -42,8 +42,20 @@
     Apache::log_error("Apache::log_error test ok");
     ok 1;
 
+    # explicitly imported
     ok t_cmp("httpd/unix-directory", DIR_MAGIC_TYPE,
              'DIR_MAGIC_TYPE');
+
+    # :response is ignored, but is now aliased in :common
+    ok t_cmp("302", REDIRECT,
+             'REDIRECT');
+
+    # from :common
+    ok t_cmp("401", AUTH_REQUIRED,
+             'AUTH_REQUIRED');
+
+    ok t_cmp("0", OK,
+             'OK');
 
     my $admin = $r->server->server_admin;
     Apache->httpd_conf('ServerAdmin [EMAIL PROTECTED]');

Reply via email to