hi Lincoln.

the attached patch updates the CGI.pm distribution to work with the new
mod_perl 2.0 API.

because of the massive API changes that have occured recently, it is a
forward only update - older versions of mod_perl 2.0 (from the start of the
project up to the current CPAN release) are not supported by this patch.

once we get your "sure, I'll integrate it into the next CGI.pm release" (or
whatever other feedback you give :) we expect to roll the next mod_perl 2.0
release candidate (RC5).  as it stands now, though, we don't want to move
forward without some interaction with you, since a release on our part will
essentially leave all CGI.pm users without a migration path.

thanks

--Geoff
diff -ru CGI.pm-3.07/CGI/Carp.pm CGI.pm-3.07-new/CGI/Carp.pm
--- CGI.pm-3.07/CGI/Carp.pm	2005-03-07 13:51:47.000000000 -0500
+++ CGI.pm-3.07-new/CGI/Carp.pm	2005-04-07 13:00:39.000000000 -0400
@@ -465,17 +465,20 @@
   ;
 
   if ($mod_perl) {
-    require mod_perl;
-    if ($mod_perl::VERSION >= 1.99) {
+    my $r;
+    if ($ENV{MOD_PERL_API_VERSION}) {
       $mod_perl = 2;
-      require Apache::RequestRec;
-      require Apache::RequestIO;
-      require Apache::RequestUtil;
+      require Apache2::RequestRec;
+      require Apache2::RequestIO;
+      require Apache2::RequestUtil;
       require APR::Pool;
       require ModPerl::Util;
-      require Apache::Response;
+      require Apache2::Response;
+      $r = Apache2::RequestUtil->request;
+    }
+    else {
+      $r = Apache->request;
     }
-    my $r = Apache->request;
     # If bytes have already been sent, then
     # we print the message out directly.
     # Otherwise we make a custom error
diff -ru CGI.pm-3.07/CGI/Cookie.pm CGI.pm-3.07-new/CGI/Cookie.pm
--- CGI.pm-3.07/CGI/Cookie.pm	2005-03-14 11:17:15.000000000 -0500
+++ CGI.pm-3.07-new/CGI/Cookie.pm	2005-04-07 13:01:32.000000000 -0400
@@ -23,18 +23,13 @@
 # Turn on special checking for Doug MacEachern's modperl
 my $MOD_PERL = 0;
 if (exists $ENV{MOD_PERL}) {
-  eval "require mod_perl";
-  if (defined $mod_perl::VERSION) {
-    my $float = $mod_perl::VERSION;
-    $float += 0;
-    if ($float >= 1.99) {
+  if ($ENV{MOD_PERL_API_VERSION} == 2) {
       $MOD_PERL = 2;
-      require Apache::RequestUtil;
-      eval "require APR::Table";  # Changing APIs? I hope not.
-    } else {
-      $MOD_PERL = 1;
-      require Apache;
-    }
+      require Apache2::RequestUtil;
+      require APR::Table;
+  } else {
+    $MOD_PERL = 1;
+    require Apache;
   }
 }
 
@@ -74,7 +69,9 @@
 
 sub get_raw_cookie {
   my $r = shift;
-  $r ||= eval { Apache->request() } if $MOD_PERL;
+  $r ||= eval { $MOD_PERL == 2                    ? 
+                  Apache2::RequestUtil->request() :
+                  Apache->request } if $MOD_PERL;
   if ($r) {
     $raw_cookie = $r->headers_in->{'Cookie'};
   } else {
diff -ru CGI.pm-3.07/CGI/Pretty.pm CGI.pm-3.07-new/CGI/Pretty.pm
--- CGI.pm-3.07/CGI/Pretty.pm	2003-12-10 12:31:05.000000000 -0500
+++ CGI.pm-3.07-new/CGI/Pretty.pm	2005-04-07 13:00:23.000000000 -0400
@@ -148,11 +148,12 @@
     my $this = $class->SUPER::new( @_ );
 
     if ($CGI::MOD_PERL) {
-        my $r = Apache->request;
         if ($CGI::MOD_PERL == 1) {
+            my $r = Apache->request;
             $r->register_cleanup(\&CGI::Pretty::_reset_globals);
         }
         else {
+            my $r = Apache2::RequestUtil->request;
             $r->pool->cleanup_register(\&CGI::Pretty::_reset_globals);
         }
     }
diff -ru CGI.pm-3.07/CGI.pm CGI.pm-3.07-new/CGI.pm
--- CGI.pm-3.07/CGI.pm	2005-03-14 11:30:20.000000000 -0500
+++ CGI.pm-3.07-new/CGI.pm	2005-04-07 13:01:18.000000000 -0400
@@ -19,7 +19,7 @@
 #   http://stein.cshl.org/WWW/software/CGI/
 
 $CGI::revision = '$Id: CGI.pm,v 1.178 2005/03/14 16:30:20 lstein Exp $';
-$CGI::VERSION=3.07;
+$CGI::VERSION=3.08;
 
 # HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES.
 # UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING.
@@ -177,20 +177,17 @@
 
 # Turn on special checking for Doug MacEachern's modperl
 if (exists $ENV{MOD_PERL}) {
-  eval "require mod_perl";
   # mod_perl handlers may run system() on scripts using CGI.pm;
   # Make sure so we don't get fooled by inherited $ENV{MOD_PERL}
-  if (defined $mod_perl::VERSION) {
-    if ($mod_perl::VERSION >= 1.99) {
-      $MOD_PERL = 2;
-      require Apache::Response;
-      require Apache::RequestRec;
-      require Apache::RequestUtil;
-      require APR::Pool;
-    } else {
-      $MOD_PERL = 1;
-      require Apache;
-    }
+  if ($ENV{MOD_PERL_API_VERSION} == 2) {
+    $MOD_PERL = 2;
+    require Apache2::Response;
+    require Apache2::RequestRec;
+    require Apache2::RequestUtil;
+    require APR::Pool;
+  } else {
+    $MOD_PERL = 1;
+    require Apache;
   }
 }
 
@@ -330,7 +327,7 @@
   if (ref($initializer[0])
       && (UNIVERSAL::isa($initializer[0],'Apache')
 	  ||
-	  UNIVERSAL::isa($initializer[0],'Apache::RequestRec')
+	  UNIVERSAL::isa($initializer[0],'Apache2::RequestRec')
 	 )) {
     $self->r(shift @initializer);
   }
@@ -339,14 +336,16 @@
     $self->upload_hook(shift @initializer, shift @initializer);
   }
   if ($MOD_PERL) {
-    $self->r(Apache->request) unless $self->r;
-    my $r = $self->r;
     if ($MOD_PERL == 1) {
+      $self->r(Apache->request) unless $self->r;
+      my $r = $self->r;
       $r->register_cleanup(\&CGI::_reset_globals);
     }
     else {
       # XXX: once we have the new API
       # will do a real PerlOptions -SetupEnv check
+      $self->r(Apache2::RequestUtil->request) unless $self->r;
+      my $r = $self->r;
       $r->subprocess_env unless exists $ENV{REQUEST_METHOD};
       $r->pool->cleanup_register(\&CGI::_reset_globals);
     }
diff -ru CGI.pm-3.07/Changes CGI.pm-3.07-new/Changes
--- CGI.pm-3.07/Changes	2005-03-14 11:30:13.000000000 -0500
+++ CGI.pm-3.07-new/Changes	2005-04-07 13:05:58.000000000 -0400
@@ -1,3 +1,7 @@
+  Version 3.08
+    1. update support for mod_perl 2.0.  versions prior to
+       mod_perl 1.999_22 (2.0.0-RC5) are no longer supported.
+
   Version 3.07
     1. Fixed typo in mod_perl detection.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to