Commit 22cdd5f6 authored by david.verdin's avatar david.verdin
Browse files

[bug][#5820][Reported by M. Jozsef, Budapest University of Technology and...

[bug][#5820][Reported by M. Jozsef, Budapest University of Technology and Economics] When fetching queries result into a hash, the case of each key string was unsure, as some RDMS could return higher cased field name, for example. This led to aparetnly empty queries result when trying to acces a lower case field value that had been returned with a higher case name. Fixed by systematically lowercasing the field name when fetching results in a hash.


git-svn-id: https://subversion.renater.fr/sympa/trunk@5555 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent c62969cc
......@@ -106,7 +106,7 @@ sub next {
return undef;
}
my $result = $sth->fetchrow_hashref;
my $result = $sth->fetchrow_hashref('NAME_lc');
$sth->finish();
return $result;
......@@ -146,7 +146,7 @@ sub messageasstring {
do_log('err','Unable to execute SQL statement "%s" : %s', $statement, $dbh->errstr);
return undef;
}
my $messageasstring = $sth->fetchrow_hashref ;
my $messageasstring = $sth->fetchrow_hashref('NAME_lc') ;
$sth->finish;
return( MIME::Base64::decode($messageasstring->{'message'}) );
......@@ -288,7 +288,7 @@ sub purge_bulkspool {
}
my $count = 0;
while (my $key = $sth->fetchrow_hashref) {
while (my $key = $sth->fetchrow_hashref('NAME_lc')) {
if ( &Bulk::remove_bulkspool_message('bulkspool',$key->{'messagekey'}) ) {
$count++;
}else{
......
......@@ -4670,7 +4670,7 @@ sub get_user_db {
return undef;
}
my $user = $sth->fetchrow_hashref;
my $user = $sth->fetchrow_hashref('NAME_lc');
$sth->finish();
......@@ -4790,7 +4790,7 @@ sub get_subscriber {
return undef;
}
my $user = $sth->fetchrow_hashref;
my $user = $sth->fetchrow_hashref('NAME_lc');
if (defined $user) {
$user->{'reception'} ||= 'mail';
......@@ -4864,7 +4864,7 @@ sub get_subscriber_by_bounce_address {
do_log('err','Unable to execute SQL statement "%s" : %s', $statement, $dbh->errstr);
return undef;
}
while (my $subscriber = $sth->fetchrow_hashref) {
while (my $subscriber = $sth->fetchrow_hashref('NAME_lc')) {
push @subscribers, $subscriber;
}
$sth->finish();
......@@ -4916,7 +4916,7 @@ sub get_admin_user {
return undef;
}
my $admin_user = $sth->fetchrow_hashref;
my $admin_user = $sth->fetchrow_hashref('NAME_lc');
if (defined $admin_user) {
$admin_user->{'reception'} ||= 'mail';
......@@ -5189,7 +5189,7 @@ sub get_first_user {
return undef;
}
my $user = $sth->fetchrow_hashref;
my $user = $sth->fetchrow_hashref('NAME_lc');
if (defined $user) {
&do_log('err','Warning: entry with empty email address in list %s', $self->{'name'})
if (! $user->{'email'});
......@@ -5533,7 +5533,7 @@ sub get_first_admin_user {
return undef;
}
my $admin_user = $sth->fetchrow_hashref;
my $admin_user = $sth->fetchrow_hashref('NAME_lc');
if (defined $admin_user) {
&do_log('err','Warning: entry with empty email address in list %s', $self->{'name'})
if (! $admin_user->{'email'});
......@@ -5573,7 +5573,7 @@ sub get_next_user {
return undef;
}
my $user = $sth->fetchrow_hashref;
my $user = $sth->fetchrow_hashref('NAME_lc');
if (defined $user) {
&do_log('err','Warning: entry with empty email address in list %s', $self->{'name'})
......@@ -5632,7 +5632,7 @@ sub get_next_admin_user {
return undef;
}
my $admin_user = $sth->fetchrow_hashref;
my $admin_user = $sth->fetchrow_hashref('NAME_lc');
if (defined $admin_user) {
&do_log('err','Warning: entry with empty email address in list %s', $self->{'name'})
......@@ -5717,7 +5717,7 @@ sub get_first_bouncing_user {
return undef;
}
my $user = $sth->fetchrow_hashref;
my $user = $sth->fetchrow_hashref('NAME_lc');
if (defined $user) {
&do_log('err','Warning: entry with empty email address in list %s', $self->{'name'})
......@@ -5749,7 +5749,7 @@ sub get_next_bouncing_user {
return undef;
}
my $user = $sth->fetchrow_hashref;
my $user = $sth->fetchrow_hashref('NAME_lc');
if (defined $user) {
&do_log('err','Warning: entry with empty email address in list %s', $self->{'name'})
......@@ -9198,7 +9198,7 @@ sub get_which_db {
return undef;
}
while ($l = $sth->fetchrow_hashref) {
while ($l = $sth->fetchrow_hashref('NAME_lc')) {
my ($name, $robot) = ($l->{'list_subscriber'}, $l->{'robot_subscriber'});
$name =~ s/\s*$//; ## usefull for PostgreSQL
$which{$robot}{$name}{'member'} = 1;
......@@ -9230,7 +9230,7 @@ sub get_which_db {
return undef;
}
while ($l = $sth->fetchrow_hashref) {
while ($l = $sth->fetchrow_hashref('NAME_lc')) {
$which{$l->{'robot_admin'}}{$l->{'list_admin'}}{$l->{'role_admin'}} = 1;
}
......@@ -9517,7 +9517,7 @@ sub get_db_field_type {
return undef;
}
while (my $ref = $sth->fetchrow_hashref()) {
while (my $ref = $sth->fetchrow_hashref('NAME_lc')) {
next unless ($ref->{'Field'} eq $field);
return $ref->{'Type'};
......@@ -9571,7 +9571,7 @@ sub lowercase_field {
return undef;
}
while (my $user = $sth->fetchrow_hashref) {
while (my $user = $sth->fetchrow_hashref('NAME_lc')) {
my $lower_cased = lc($user->{$field});
next if ($lower_cased eq $user->{$field});
......
......@@ -421,7 +421,7 @@ sub get_first_db_log {
return {};
}
my $log = $sth->fetchrow_hashref;
my $log = $sth->fetchrow_hashref('NAME_lc');
## We can't use the "AS date" directive in the SELECT statement because "date" is a reserved keywork with Oracle
$log->{date} = $log->{date_logs} if defined($log->{date_logs});
return $log;
......@@ -433,7 +433,7 @@ sub return_rows_nb {
}
sub get_next_db_log {
my $log = $sth->fetchrow_hashref;
my $log = $sth->fetchrow_hashref('NAME_lc');
unless (defined $log) {
$sth->finish;
......
......@@ -963,7 +963,7 @@ sub probe_db {
return undef;
}
while (my $ref = $sth->fetchrow_hashref()) {
while (my $ref = $sth->fetchrow_hashref('NAME_lc')) {
$real_struct{$t}{$ref->{'field'}} = $ref->{'type'};
}
......@@ -1557,7 +1557,7 @@ sub md5_encode_password {
my $total = 0;
my $total_md5 = 0 ;
while (my $user = $sth->fetchrow_hashref) {
while (my $user = $sth->fetchrow_hashref('NAME_lc')) {
my $clear_password ;
if ($user->{'password_user'} =~ /^[1-9a-f]{32}/){
......
......@@ -52,7 +52,7 @@ my $user;
my $count = 0;
while ($user = $sth->fetchrow_hashref) {
while ($user = $sth->fetchrow_hashref('NAME_lc')) {
next unless $user->{'password_user'};
printf "\n%s", $user->{'email_user'};
......
......@@ -42,7 +42,7 @@ $sth->execute || die "Unable to execute SQL statement";
my $user;
while ($user = $sth->fetchrow_hashref) {
while ($user = $sth->fetchrow_hashref('NAME_lc')) {
printf "\nUser: %s", $user->{'user_subscriber'};
unless ($user->{'comment_subscriber'}) {
......
......@@ -453,7 +453,7 @@ sub get_one_time_ticket {
return {'result'=>'error'};
}
my $ticket = $sth->fetchrow_hashref;
my $ticket = $sth->fetchrow_hashref('NAME_lc');
$sth->finish();
unless ($ticket) {
......
......@@ -101,7 +101,7 @@ sub load {
do_log('err','Unable to execute SQL statement "%s" : %s', $statement, $dbh->errstr);
return undef;
}
my $challenge = $sth->fetchrow_hashref;
my $challenge = $sth->fetchrow_hashref('NAME_lc');
$sth->finish();
unless ($challenge) {
......
......@@ -137,7 +137,7 @@ sub load {
do_log('err','Unable to execute SQL statement "%s" : %s', $statement, $dbh->errstr);
return undef;
}
my $session = $sth->fetchrow_hashref;
my $session = $sth->fetchrow_hashref('NAME_lc');
$sth->finish();
unless ($session) {
......@@ -426,7 +426,7 @@ sub list_sessions {
return undef;
}
while (my $session = ($sth->fetchrow_hashref)) {
while (my $session = ($sth->fetchrow_hashref('NAME_lc'))) {
$session->{'formated_date'} = &Language::gettext_strftime ("%d %b %y %H:%M", localtime($session->{'date_session'}));
$session->{'formated_start_date'} = &Language::gettext_strftime ("%d %b %y %H:%M", localtime($session->{'start_date_session'}));
......
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