Skip to content

Commit

Permalink
[#691] %MT::Commenter_Auth is now lexically scoped within a closure…
Browse files Browse the repository at this point in the history
… and cannot be accessed/changed directly. Please use the `MT::commenter_authenticator()` and `MT::commenter_authenticators()` method exclusively for accessing the variable.

No mutator has been provided because the variable is populated by the `MT::init_commenter_authenticators()` method which is called by both accessors.
  • Loading branch information
jayallen committed Jan 25, 2011
1 parent 1e41e31 commit 26f2324
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions lib/MT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2801,36 +2801,38 @@ sub get_next_sched_post_for_user {
return $next_sched_utc;
} ## end sub get_next_sched_post_for_user

our %Commenter_Auth;

sub init_commenter_authenticators {
my $self = shift;
my $auths = $self->registry("commenter_authenticators") || {};
%Commenter_Auth = %$auths;
my $app = $self->app;
my $blog = $app->blog if $app->isa('MT::App');
foreach my $auth ( keys %$auths ) {
if ( my $c = $auths->{$auth}->{condition} ) {
$c = $self->handler_to_coderef($c);
if ($c) {
delete $Commenter_Auth{$auth} unless $c->($blog);
{
our %Commenter_Auth;

sub init_commenter_authenticators {
my $self = shift;
my $auths = $self->registry("commenter_authenticators") || {};
%Commenter_Auth = %$auths;
my $app = $self->app;
my $blog = $app->blog if $app->isa('MT::App');
foreach my $auth ( keys %$auths ) {
if ( my $c = $auths->{$auth}->{condition} ) {
$c = $self->handler_to_coderef($c);
if ($c) {
delete $Commenter_Auth{$auth} unless $c->($blog);
}
}
}
$Commenter_Auth{$_}{key} ||= $_ for keys %Commenter_Auth;
}
$Commenter_Auth{$_}{key} ||= $_ for keys %Commenter_Auth;
}

sub commenter_authenticator {
my $self = shift;
my ($key) = @_;
%Commenter_Auth or $self->init_commenter_authenticators();
return $Commenter_Auth{$key};
}
sub commenter_authenticator {
my $self = shift;
my ($key) = @_;
%Commenter_Auth or $self->init_commenter_authenticators();
return $Commenter_Auth{$key};
}

sub commenter_authenticators {
my $self = shift;
%Commenter_Auth or $self->init_commenter_authenticators();
return values %Commenter_Auth;
sub commenter_authenticators {
my $self = shift;
%Commenter_Auth or $self->init_commenter_authenticators();
return values %Commenter_Auth;
}
}

sub _commenter_auth_params {
Expand Down

0 comments on commit 26f2324

Please sign in to comment.