Skip to content

Commit

Permalink
Do not ruin arguments for future candidates:
Browse files Browse the repository at this point in the history
There's a loop that goes through hook candidates and runs their
hooks. We shifted the parameters in case it was us, but it appears
that `@_` is reused, so we mustn't destroy it.

Instead we copy it over and use the copy.
  • Loading branch information
xsawyerx authored and veryrusty committed Mar 3, 2016
1 parent dd30065 commit 688c661
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Dancer2/Plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ sub _exporter_app {
# "candidate" for a hook
# See: App.pm "execute_hook" method, "around" modifier
if ( ref( $_[0] ) =~ /^Dancer2::Plugin::/ ) {
my $plugin_self = shift @_;
my $hook_name = shift @_;
# this means it's probably our hook, let's verify
# this means it's probably our hook, we need to verify it
my ( $plugin_self, $hook_name, @args ) = @_;

my $plugin_class = lc $class;
$plugin_class =~ s/^dancer2::plugin:://;
$hook_name =~ /^plugin\.$plugin_class/
Expand All @@ -281,7 +281,7 @@ sub _exporter_app {
# this is okay because the modifier is there only to
# call candidates, like us (this is in fact how and
# why we were called)
return $_->( $plugin_self, @_ )
return $_->( $plugin_self, @args )
for @{ $plugin->hooks->{$hook_name} };
}

Expand Down

0 comments on commit 688c661

Please sign in to comment.