From eugene@donpac.ru  Mon Nov 21 18:39:26 2005
Return-Path: <eugene@donpac.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7386716A422
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 21 Nov 2005 18:39:26 +0000 (GMT)
	(envelope-from eugene@donpac.ru)
Received: from cerberus.rnd.cbr.ru (cerberus.rnd.cbr.ru [194.84.224.97])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B8FB743D60
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 21 Nov 2005 18:39:14 +0000 (GMT)
	(envelope-from eugene@donpac.ru)
Received: from [127.0.0.1]
	by cerberus.rnd.cbr.ru with ESMTP id jALId6ad067664
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 21 Nov 2005 21:39:06 +0300 (MSK)
	(envelope-from eugene@donpac.ru)
Received: (from eugene@localhost)
	by cerberus.rnd.cbr.ru (8.13.3/8.13.3/Submit) id jALId5qj067663
	for FreeBSD-gnats-submit@freebsd.org; Mon, 21 Nov 2005 21:39:05 +0300 (MSK)
	(envelope-from eugene@donpac.ru)
Message-Id: <20051121183905.GA67651@so.inet.rnd.cbr.ru>
Date: Mon, 21 Nov 2005 21:39:05 +0300
From: Eugene Gladchenko <eugene@donpac.ru>
To: FreeBSD-gnats-submit@freebsd.org
Subject: undefined MOD_PERL_API_VERSION in www/p5-Apache-DBI

>Number:         89387
>Category:       ports
>Synopsis:       undefined MOD_PERL_API_VERSION in www/p5-Apache-DBI
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    skv
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 21 18:40:26 GMT 2005
>Closed-Date:    Thu Jan 19 06:01:22 GMT 2006
>Last-Modified:  Thu Jan 19 06:01:22 GMT 2006
>Originator:     Eugene Gladchenko
>Release:        FreeBSD 5.4-RELEASE-p3 i386
>Organization:
>Environment:
System: FreeBSD cops.gladchenko.ru 5.4-RELEASE-p3 FreeBSD 5.4-RELEASE-p3 #5: Tue Jul 5 15:19:55 MSD 2005
>Description:
	When using www/apache13-modperl with Apache::DBI loaded by startup.pl
	I get the following error messages upon starting Apache:

	Use of uninitialized value in numeric eq (==) at
	/usr/local/lib/perl5/site_perl/5.8.7/Apache/DBI.pm line 211.
	Use of uninitialized value in numeric eq (==) at
	/usr/local/lib/perl5/site_perl/5.8.7/Apache/DBI.pm line 35.

	I've modified the existing patch patch-mp2-api a little to get rid of
	these. I just had to add a few "if exists $ENV{MOD_PERL_API_VERSION}".
>How-To-Repeat:
	Run "apachectl start" and see the error message.
>Fix:

--- patch-mp2-api begins here ---
--- AuthDBI.pm.orig	Mon May 23 09:53:24 2005
+++ AuthDBI.pm	Mon May 23 09:55:38 2005
@@ -6,13 +6,13 @@
 # 2: full debug output
 $Apache::AuthDBI::DEBUG = 0;
 
-use constant MP2 => $mod_perl::VERSION >= 1.99;
+use constant MP2 => $ENV{MOD_PERL_API_VERSION} == 2 ? 1 : 0;
  
 BEGIN {
   my @constants = qw( OK AUTH_REQUIRED FORBIDDEN DECLINED SERVER_ERROR );
   if (MP2) {
-    require Apache::Const;
-    import Apache::Const @constants;
+    require Apache2::Const;
+    import Apache2::Const @constants;
   }
   else {
     require Apache::Constants;
@@ -25,7 +25,9 @@
 
 sub push_handlers {
   if ( MP2 ) {
-    Apache->server->push_handlers(@_);
+    require Apache2::ServerUtil;
+    my $s = Apache2::ServerUtil->server;
+    $s->push_handlers(@_);
   }
   else {
     Apache->push_handlers(@_);
--- DBI.pm.orig	Mon May 23 09:49:38 2005
+++ DBI.pm	Mon May 23 10:08:40 2005
@@ -4,6 +4,7 @@
 # $Id: DBI.pm,v 1.12 2004/02/18 00:18:50 ask Exp $
 
 BEGIN { eval { require Apache } }
+BEGIN { eval { require mod_perl2; require Apache2::Module; } }
 use DBI ();
 use Carp qw(carp);
 
@@ -31,11 +32,19 @@
 sub connect_on_init { 
     # provide a handler which creates all connections during server startup
 
-    # TODO - Should check for mod_perl 2 and do the right thing there
-    carp "Apache.pm was not loaded\n" and return unless $INC{'Apache.pm'};
-    if(!@ChildConnect and Apache->can('push_handlers')) {
-        Apache->push_handlers(PerlChildInitHandler => \&childinit);
+    if (exists $ENV{MOD_PERL_API_VERSION} && $ENV{MOD_PERL_API_VERSION} == 2) {
+	if (!@ChildConnect) {
+	    require Apache2::ServerUtil;
+	    my $s = Apache2::ServerUtil->server;
+	    $s->push_handlers(PerlChildInitHandler => \&childinit);
+	}
+    } else {
+	carp "Apache.pm was not loaded\n" and return unless $INC{'Apache.pm'};
+	if (!@ChildConnect and Apache->can('push_handlers')) {
+	    Apache->push_handlers(PerlChildInitHandler => \&childinit);
+	}
     }
+
     # store connections
     push @ChildConnect, [@_];
 }
@@ -93,10 +102,16 @@
 
     # this PerlCleanupHandler is supposed to initiate a rollback after the script has finished if AutoCommit is off.
     my $needCleanup = ($Idx =~ /AutoCommit[^\d]+0/) ? 1 : 0;
-    # TODO - Fix mod_perl 2.0 here
     if(!$Rollback{$Idx} and $needCleanup and Apache->can('push_handlers')) {
         print STDERR "$prefix push PerlCleanupHandler \n" if $Apache::DBI::DEBUG > 1;
-        Apache->push_handlers("PerlCleanupHandler", \&cleanup);
+	if (exists $ENV{MOD_PERL_API_VERSION} && $ENV{MOD_PERL_API_VERSION} == 2) {
+		require Apache2::ServerUtil;
+		my $s = Apache2::ServerUtil->server;
+		$s->push_handlers('PerlCleanupHandler', \&cleanup);
+	} else {
+		Apache->push_handlers('PerlCleanupHandler', \&cleanup);
+	}
+	
         # make sure, that the rollback is called only once for every 
         # request, even if the script calls connect more than once
         $Rollback{$Idx} = 1;
@@ -193,9 +208,21 @@
 
 
 # prepare menu item for Apache::Status
-
-Apache::Status->menu_item(
-
+if (exists $ENV{MOD_PERL_API_VERSION} && $ENV{MOD_PERL_API_VERSION} == 2) {
+    Apache2::Status->menu_item(
+    'DBI' => 'DBI connections',
+    sub {
+        my($r, $q) = @_;
+        my(@s) = qw(<TABLE><TR><TD>Datasource</TD><TD>Username</TD></TR>);
+        for (keys %Connected) {
+            push @s, '<TR><TD>', join('</TD><TD>', (split($;, $_))[0,1]), "</TD></TR>\n";
+        }
+        push @s, '</TABLE>';
+        return \@s;
+    }
+    ) if Apache2::Module::loaded('Apache2::Status');
+} else {
+    Apache::Status->menu_item(
     'DBI' => 'DBI connections',
     sub {
         my($r, $q) = @_;
@@ -206,10 +233,10 @@
         push @s, '</TABLE>';
         return \@s;
    }
-
-) if ($INC{'Apache.pm'}                      # is Apache.pm loaded?
+   ) if ($INC{'Apache.pm'}		      # is Apache.pm loaded?
       and Apache->can('module')               # really?
       and Apache->module('Apache::Status'));  # Apache::Status too?
+}
 
 1;
 
--- patch-mp2-api ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->skv 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Mon Nov 21 18:42:13 GMT 2005 
Responsible-Changed-Why:  
Over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=89387 

From: "Philip M. Gollucci" <pgollucci@p6m7g8.com>
To: bug-followup@FreeBSD.org, eugene@donpac.ru
Cc:  
Subject: Re: ports/89387: undefined MOD_PERL_API_VERSION in www/p5-Apache-DBI
Date: Wed, 18 Jan 2006 23:13:24 -0500

 This is fixed in its entirety by an upgrade to 0.9901 which is on CPAN.
 
 Doing so will also remove the need to have any local FreeBSD patches in 
 teh files directory.
 
 I'm also the CPAN maintainer, so if you have corrections, submit there
 and I'll see to it they are in the next release.
 
 I'm going in for Surgery Tomorrow, so I might not get to this until 
 early next week (depending on how the recovery goes).
 
 I thought I had updated the port to .9901 anyway.  Looks like its at 
 .98..... I'm looking to release 1.0 sometime in February to CPAN and 
 will update the FreeBSD port when I do that as well.
 
 Feel free to e-mail me with questions.
 
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Thu Jan 19 05:54:47 UTC 2006 
State-Changed-Why:  
See maintainer update in ports/91526. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=89387 
>Unformatted:
