Skip Menu |

This queue is for tickets about the Module-Pluggable CPAN distribution.

Report information
The Basics
Id: 124129
Status: new
Priority: 0/
Queue: Module-Pluggable

People
Owner: simonw [...] cpan.org
Requestors: CHOHAG [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 5.2
Fixed in: (no value)



Subject: Plugins ordered by search_path (with patch)
Possible plugin modules are returned from plugins() in order of package name, ignoring the search path. This patch returns plugin names in the order described by the user's search_path attribute.
Subject: dedupe-and-order.diff
--- /home/mking/tmp/Object.pm 2018-01-19 06:52:25.300962000 +0000 +++ /home/mking/perl5/lib/site_perl/5.26.0/Module/Pluggable/Object.pm 2018-01-19 06:58:10.272962000 +0000 @@ -86,19 +86,19 @@ # return blank unless we've found anything return () unless @plugins; - # remove duplicates - # probably not necessary but hey ho - my %plugins; + my (@dedupe, %plugins); for(@plugins) { next unless $self->_is_legit($_); + next if $plugins{$_}; # remove duplicates $plugins{$_} = 1; + push @dedupe, $_; } # are we instantiating or requiring? if (defined $self->{'instantiate'}) { my $method = $self->{'instantiate'}; my @objs = (); - foreach my $package (sort keys %plugins) { + foreach my $package (@dedupe) { next unless $package->can($method); my $obj = eval { $package->$method(@_) }; $self->{'on_instantiate_error'}->($package, $@) if $@; @@ -107,8 +107,7 @@ return @objs; } else { # no? just return the names - my @objs= sort keys %plugins; - return @objs; + return @dedupe; } }