[Dbix-class] Duplicate isa bug in Componentized.pm

Shevek shevek at anarres.org
Sun Apr 16 13:04:07 CEST 2006


And I bet you thought componentized.pm was too small for a bug.

Anyway.


Use Schema::Loader (as documented) passing 

components => [ qw/ResultSetManager/] and 

resultset_components => [ qw/anything/ ]

reach Loader/Generic#new():

    push(@{$self->{components}}, 'ResultSetManager')
        if @{$self->{resultset_components}};

Note that now $self->{components} contains ResultSetManager twice.

This calls (eventually) load_components in Componentized:


> sub inject_base {
>   my ($class, $target, @to_inject) = @_;
>   {
>     no strict 'refs';
>     unshift(@{"${target}::ISA"}, grep { $target ne $_ && !$target->isa($_)} @to_
> inject);
>   }

So @to_inject now contains a duplicate, which isn't yet present. grep
passes the duplicate.

Now Class::C3 fails on the same thing twice in one ISA array (which is
debatably a bug in itself). It gives an inability to resolve etc etc.

Solution: in Componentized.pm

for (@to_inject) {
  unshift(@ISA, $_) unless $target->isa($_);
}


S.

-- 
Shevek <shevek at anarres.org>




More information about the Dbix-class mailing list