Skip to content

Commit

Permalink
Revert "list index performance update for wwsympa.fcgi do_lists subro…
Browse files Browse the repository at this point in the history
…utine (#925)"
  • Loading branch information
ikedas authored Jan 31, 2021
1 parent 13af5d0 commit aafa983
Showing 1 changed file with 28 additions and 41 deletions.
69 changes: 28 additions & 41 deletions src/cgi/wwsympa.fcgi.in
Original file line number Diff line number Diff line change
Expand Up @@ -4196,26 +4196,16 @@ sub do_lists {
my @lists;
wwslog('info', '(%s, %s)', $in{'topic'}, $in{'subtopic'});

# Get member/owner/editor data used to avoid lookups in the loop
my $which = {member => {}, owner => {}, editor => {}};
if ($param->{'user'}{'email'}) {
my $all_lists = [];
if ($in{'topic'} and $in{'topic'} eq '@which') {
my %lists = ();
foreach my $role ('member', 'owner', 'editor') {
foreach my $list (
Sympa::List::get_which(
$param->{'user'}{'email'},
$robot, $role
)
) {
$which->{$role}->{$list->{'name'}} = $list;
}
}
}

my $all_lists = [];
if ($in{'topic'} and $in{'topic'} eq '@which') {
my %lists = ();
foreach my $role ('member', 'owner', 'editor') {
foreach my $list (values %{$which->{$role}}) {
$lists{$list->{'name'}} = $list;
}
}
Expand All @@ -4240,7 +4230,6 @@ sub do_lists {

foreach my $list (@$all_lists) {
my $sender = $param->{'user'}{'email'} || 'nobody';
my $listname = $list->{'name'};

my $result =
Sympa::Scenario->new($list, 'visibility',
Expand All @@ -4265,34 +4254,32 @@ sub do_lists {
#Compat.<6.2.32
$list_info->{'host'} = $list->{'domain'};

if ($param->{'user'}{'email'}) {
if ($which->{owner}->{$listname}) {
if ($list->is_admin(
'privileged_owner', $param->{'user'}{'email'}
)
) {
$list_info->{is_privileged_owner} = 1;
}
if (not $which->{editor}->{$listname}
and $list->is_admin(
'actual_editor', $param->{'user'}{'email'}
)
) {
$list_info->{is_editor} = 1;
}
$list_info->{is_owner} = 1;
# Compat. < 6.2b.2.
$list_info->{'admin'} = 1;
}
if ($which->{editor}->{$listname}) {
$list_info->{is_editor} = 1;
# Compat. < 6.2b.2.
$list_info->{'admin'} = 1;
}
if ($which->{member}->{$listname}) {
$list_info->{'is_subscriber'} = 1;
}
if ( $param->{'user'}{'email'}
and
$list->is_admin('privileged_owner', $param->{'user'}{'email'})) {
$list_info->{'is_privileged_owner'} = 1;
$list_info->{'is_owner'} = 1;
# Compat. < 6.2b.2.
$list_info->{'admin'} = 1;
}
if ( $param->{'user'}{'email'}
and $list->is_admin('owner', $param->{'user'}{'email'})) {
$list_info->{'is_owner'} = 1;
# Compat. < 6.2b.2.
$list_info->{'admin'} = 1;
}
if ( $param->{'user'}{'email'}
and $list->is_admin('actual_editor', $param->{'user'}{'email'})) {
$list_info->{'is_editor'} = 1;
# Compat. < 6.2b.2.
$list_info->{'admin'} = 1;
}
if ( $param->{'user'}{'email'}
and $list->is_list_member($param->{'user'}{'email'})) {
$list_info->{'is_subscriber'} = 1;
}

my $listname = $list->{'name'};

$param->{'which'} ||= {};
$param->{'which'}{$listname} = $list_info;
Expand Down

0 comments on commit aafa983

Please sign in to comment.