Hi,

attached is a patch which makes Apache::PAR run under mod_perl > RC4 again (at least the server starts again). It should work on older versions, too but I did't test it yet.

Greetings from the Austrian Perl Workshop,
Nine
--- Apache/PAR.pm.old	2003-08-26 04:01:30.000000000 +0200
+++ Apache/PAR.pm	2005-06-11 19:19:38.000000000 +0200
@@ -11,9 +11,15 @@
 use vars qw($VERSION %PARFILE_LIST %MTIME_LIST %UNPACK_LIST);
 
 $VERSION = '0.30';
-
 unless ($mod_perl::VERSION < 1.99) {
-	require Apache::ServerUtil;
+	unless($mod_perl::VERSION < 2.00) {
+		require Apache2::ServerUtil;
+		require Apache2::ServerRec;
+		require Apache2::Process;
+	}
+	else {
+		require Apache::ServerUtil;
+	}
 	require APR::Table;
 
 }
@@ -25,9 +31,10 @@
 use Archive::Zip qw( AZ_OK );
 Archive::Zip::setErrorHandler(sub {});
 
-my @pardir      = Apache->server->dir_config->get('PARDir');
-my @parfiles    = Apache->server->dir_config->get('PARFile');
-my @parloc      = Apache->server->dir_config->get('PARInclude');
+my $server	= $mod_perl::VERSION < 2.00 ? Apache->server : Apache2::ServerUtil->server;
+my @pardir      = $server->dir_config->get('PARDir');
+my @parfiles    = $server->dir_config->get('PARFile');
+my @parloc      = $server->dir_config->get('PARInclude');
 
 sub handler {
 	my $r = shift;
@@ -36,7 +43,8 @@
 		if($mtime > $MTIME_LIST{$_}) {
 			PAR::reload_libs($_);
 			if($UNPACK_LIST{$_}) {
-				unpack_par(undef, $_, Apache->server->dir_config->get('PARTempDir'))
+				my $server = $mod_perl::VERSION < 2.00 ? Apache->server : Apache2::ServerUtil->server;
+				unpack_par(undef, $_, $server->dir_config->get('PARTempDir'))
 			}
 			$MTIME_LIST{$_} = $mtime;
 		}
@@ -48,12 +56,13 @@
 sub import {
 	my $class = shift;
 	my @parentries = @_;
-	my $parext    = Apache->server->dir_config('PARExt') || 'par';
-	my $conf_file = Apache->server->dir_config('PARConf') || 'web.conf';
+	my $server	= $mod_perl::VERSION < 2.00 ? Apache->server : Apache2::ServerUtil->server;
+	my $parext    = $server->dir_config('PARExt') || 'par';
+	my $conf_file = $server->dir_config('PARConf') || 'web.conf';
 
 	my %parlist = ();
 	foreach my $parentry (@parentries) {
-		$parentry = Apache->server_root_relative($parentry);
+		$parentry = $mod_perl::VERSION < 2.00 ? Apache->server_root_relative($parentry) : Apache2::ServerUtil::server_root_relative(Apache2::ServerUtil->server->process->pool, $parentry);
 		$parentry =~ s/\/$//;
 		if(!(-e $parentry)) {
 			print STDERR "PAR: No such file or directory: $parentry\n";
@@ -100,7 +109,7 @@
 	
 		$conf =~ s/##PARFILE##/$file/g;
 		if ($conf =~ /##UNPACKDIR##/) {
-			my $tempdir = Apache->server->dir_config->get('PARTempDir');
+			my $tempdir = $server->dir_config->get('PARTempDir');
 			if(uc($tempdir) eq 'NONE') {
 				print STDERR "PARTempDir setting disallows load of $file.  Skipping.\n";
 				next;
@@ -115,9 +124,8 @@
 			# TODO: Use UNPACK_LIST in handler, etc to reload changed content.
 		}
 
-
 		unless ($mod_perl::VERSION < 1.99) {
-			$err = Apache->server->add_config([split /\n/, $conf]);
+			$err = $server->add_config([split /\n/, $conf]);
 		} else
 		{
 			Apache->httpd_conf($conf);

Reply via email to