Subject: | inheritance broken in Maypole::Application |
Hi Aaron,
I've finally upgraded to 2.10.
In Maypole::Application, plugins are pushed onto @plugin_modules, which is then pushed onto the caller's @ISA, and then $class (Maypole::Application) is pushed onto the caller's @ISA.
Meanwhile, plugins are also unshifted onto Maypole::Application::ISA. So in an app I have that loads a bunch of plugins, I end up with this:
package LTSIFB;
use Maypole::Application qw( LTSIFB Config::Apache ColumnGroups
MasonX FormBuilder Relationship
LinkTools QuickTable Session
-Debug -Setup
);
LTSIFB ISA: Maypole::Plugin::LTSIFB
Maypole::Plugin::Config::Apache
Maypole::Plugin::ColumnGroups
Maypole::Plugin::FormBuilder
Maypole::Plugin::Relationship
Maypole::Plugin::LinkTools
Maypole::Plugin::QuickTable
Maypole::Plugin::Session
Maypole::Application
Maypole::Application ISA: Maypole::Plugin::Session
Maypole::Plugin::QuickTable
Maypole::Plugin::LinkTools
Maypole::Plugin::Relationship
Maypole::Plugin::FormBuilder
Maypole::Plugin::ColumnGroups
Maypole::Plugin::Config::Apache
Maypole::Plugin::LTSIFB
MasonX::Maypole
which causes bugs, especially when I'm loading multiple apps in the same mod_perl server.
Here's a patch that fixes it:
dave@evesham$ diff -u Application.pm-2.10 Application.pm-PATCHED
--- Application.pm-2.10 Tue Jul 5 19:05:12 2005
+++ Application.pm-PATCHED Thu Aug 11 22:28:58 2005
@@ -26,7 +26,9 @@
$frontend ||= 'CGI::Maypole';
$frontend->require or die "Loading $frontend frontend failed: $@";
- push @ISA, $frontend;
+
+ # inheritance may already be set up in a multi-app mod_perl environment
+ push @ISA, $frontend unless __PACKAGE__->isa( $frontend );
my $autosetup=0;
my @plugin_modules;
@@ -44,7 +46,6 @@
my $plugin = "Maypole::Plugin::$_";
if ($plugin->require) {
push @plugin_modules, "Maypole::Plugin::$_";
- unshift @ISA, "Maypole::Plugin::$_";
warn "Loaded plugin: $plugin for $caller"
if $caller->can('debug') && $caller->debug;
} else {