Subject: | Apache::Singleton::Request is not loaded by default under mod_perl |
If I derive a class from Apache::Singleton, leaving it to its own
devices to decide whether to use Apache::Singleton::Request or
Apache::Singleton::Process as appropriate, then under mod_perl-2 I get
the error:
Can't locate object method "_get_instance" via package
"Apache::Singleton::Request" (perhaps you forgot to load
"Apache::Singleton::Request"?) at C:/Perl/site/lib/Apache/Singleton.pm
line 38.
It seems that the Singleton module loads Process when not under
mod_perl, but fails to load Request when under mod_perl.
The attached patch fixes this.
It would also be worth noting that the global request object is required
for mod_perl-2 operation, i.e. set PerlOptions +GlobalRequest in the
httpd.conf or call Apache2::RequestUtil->request($r) in the handler,
otherwise the Apache2::RequestUtil->request() call in Request.pm fails
with the error "Global $r object is not available".
Subject: | request.patch |
diff -ruN Apache-Singleton-0.13.orig/lib/Apache/Singleton.pm Apache-Singleton-0.13/lib/Apache/Singleton.pm
--- Apache-Singleton-0.13.orig/lib/Apache/Singleton.pm 2011-05-29 20:32:02.000000000 +0100
+++ Apache-Singleton-0.13/lib/Apache/Singleton.pm 2011-09-25 17:21:02.125000000 +0100
@@ -7,7 +7,10 @@
use strict;
-unless ($ENV{MOD_PERL}) {
+if ($ENV{MOD_PERL}) {
+ require Apache::Singleton::Request;
+}
+else {
require Apache::Singleton::Process;
}