Unverified Commit 422cd976 authored by IKEDA Soji's avatar IKEDA Soji Committed by GitHub
Browse files

Merge pull request #642 from ikedas/issue-641 by ikedas

Updating user crashes due to missing serialization of structured data. (#641)
parents 3699f7e6 5d4e2645
......@@ -3214,24 +3214,14 @@ sub do_login {
 
if ($session->{'review_page_size'}) {
# user did choose a specific page size upgrade prefs
Sympa::User::update_global_user(
$param->{'user'}{'email'},
{ data => Sympa::Tools::Data::hash_2_string(
$param->{'user'}{'prefs'}
)
}
);
Sympa::User::update_global_user($param->{'user'}{'email'},
{data => $param->{'user'}{'prefs'}});
}
 
if ($session->{'shared_mode'}) {
# user did choose a shared expert/standard mode
Sympa::User::update_global_user(
$param->{'user'}{'email'},
{ data => Sympa::Tools::Data::hash_2_string(
$param->{'user'}{'prefs'}
)
}
);
Sympa::User::update_global_user($param->{'user'}{'email'},
{data => $param->{'user'}{'prefs'}});
}
 
web_db_log(
......@@ -3655,34 +3645,24 @@ sub do_sso_login {
## the user
## Either with a defined header prefix (http_header_prefix)
## Or with an explicit list of header fields (http_header_list)
my @sso_attr;
if ($Conf::Conf{'auth_services'}{$robot}[$sso_id]{'http_header_list'})
my $sso_attrs;
if (my $list_of_headers =
$Conf::Conf{'auth_services'}{$robot}[$sso_id]{'http_header_list'})
{
my $list_of_headers =
$Conf::Conf{'auth_services'}{$robot}[$sso_id]
{'http_header_list'};
foreach my $field (split(/,/, $list_of_headers)) {
if (defined $ENV{$field}) {
push @sso_attr, $field . '__PAIRS_SEP__' . $ENV{$field};
}
}
} elsif ($Conf::Conf{'auth_services'}{$robot}[$sso_id]
$sso_attrs = {
map { ($_ => $ENV{$_}) } grep { defined $ENV{$_} }
split(/\s*,\s*/, $list_of_headers)
};
} elsif (my $prefix = $Conf::Conf{'auth_services'}{$robot}[$sso_id]
{'http_header_prefix'}) {
my $prefix =
$Conf::Conf{'auth_services'}{$robot}[$sso_id]
{'http_header_prefix'};
foreach my $k (keys %ENV) {
if ($k =~ /^$prefix/) {
push @sso_attr, $k . '__PAIRS_SEP__' . $ENV{$k};
}
}
$sso_attrs = {
map { ($_ => $ENV{$_}) } grep {/^($prefix)/}
keys %ENV
};
} else {
$sso_attrs = {};
}
 
my $all_sso_attr = join '__ATT_SEP__', @sso_attr;
## Create user entry if required
unless (Sympa::User::is_global_user($email)) {
unless (Sympa::User::add_global_user({'email' => $email})) {
......@@ -3703,7 +3683,7 @@ sub do_sso_login {
 
unless (
Sympa::User::update_global_user(
$email, {'attributes' => $all_sso_attr}
$email, {attributes => $sso_attrs}
)
) {
Sympa::WWW::Report::reject_report_web('intern',
......@@ -4783,13 +4763,8 @@ sub _review_member {
if ($param->{'user'}{'prefs'}{'review_page_size'} ne $in{'size'}) {
# update user pref as soon as connected user change page size
$param->{'user'}{'prefs'}{'review_page_size'} = $in{'size'};
Sympa::User::update_global_user(
$param->{'user'}{'email'},
{ data => Sympa::Tools::Data::hash_2_string(
$param->{'user'}{'prefs'}
)
}
);
Sympa::User::update_global_user($param->{'user'}{'email'},
{data => $param->{'user'}{'prefs'}});
}
} else {
$size =
......@@ -8759,13 +8734,8 @@ sub do_arc {
# they consult archives
$param->{'user'}{'prefs'}{'arc_mode'} =
$session->{'arc_mode'};
Sympa::User::update_global_user(
$param->{'user'}{'email'},
{ data => Sympa::Tools::Data::hash_2_string(
$param->{'user'}{'prefs'}
)
}
);
Sympa::User::update_global_user($param->{'user'}{'email'},
{data => $param->{'user'}{'prefs'}});
}
}
 
......@@ -11745,13 +11715,8 @@ sub do_d_read {
if ($param->{'user'}{'prefs'}{'shared_mode'} ne 'expert') {
# update user pref as soon as connected user change shared mode
$param->{'user'}{'prefs'}{'shared_mode'} = 'expert';
Sympa::User::update_global_user(
$param->{'user'}{'email'},
{ data => Sympa::Tools::Data::hash_2_string(
$param->{'user'}{'prefs'}
)
}
);
Sympa::User::update_global_user($param->{'user'}{'email'},
{data => $param->{'user'}{'prefs'}});
}
$param->{'expert_page'} = 1;
 
......@@ -11760,13 +11725,8 @@ sub do_d_read {
if ($param->{'user'}{'prefs'}{'shared_mode'} ne 'basic') {
# update user pref as soon as connected user change shared mode
$param->{'user'}{'prefs'}{'shared_mode'} = 'basic';
Sympa::User::update_global_user(
$param->{'user'}{'email'},
{ data => Sympa::Tools::Data::hash_2_string(
$param->{'user'}{'prefs'}
)
}
);
Sympa::User::update_global_user($param->{'user'}{'email'},
{data => $param->{'user'}{'prefs'}});
}
$param->{'expert_page'} = 0;
} else {
......
......@@ -679,6 +679,16 @@ sub update_global_user {
if ($numeric_field{$map_field{$field}}) {
$value ||= 0; ## Can't have a null value
$set = sprintf '%s=%s', $map_field{$field}, $value;
} elsif ($field eq 'data' and ref $value eq 'HASH') {
$set = sprintf '%s=%s', $map_field{$field},
$sdm->quote(Sympa::Tools::Data::hash_2_string($value));
} elsif ($field eq 'attributes' and ref $value eq 'HASH') {
$set = sprintf '%s=%s', $map_field{$field},
$sdm->quote(
join '__ATT_SEP__',
map { sprintf '%s__PAIRS_SEP__%s', $_, $value->{$_} }
sort keys %$value
);
} else {
$set = sprintf '%s=%s', $map_field{$field}, $sdm->quote($value);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment