Commit 421cae21 authored by sikeda's avatar sikeda
Browse files

[dev] Use SDM::check_db_connect() instead of SDM::connect_sympa_database() to...

[dev] Use SDM::check_db_connect() instead of SDM::connect_sympa_database() to wait for connection safely.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@8861 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent cf500458
......@@ -65,8 +65,14 @@ sub do_query {
my @params = @_;
my $sth;
unless ($sth = $db_source->do_query($query,@params)) {
&Log::do_log('err','SQL query failed to execute in the Sympa database');
if (check_db_connect()) {
unless ($sth = $db_source->do_query($query, @params)) {
Log::do_log('err',
'SQL query failed to execute in the Sympa database');
return undef;
}
} else {
Log::do_log('err', 'Unable to get a handle to Sympa database');
return undef;
}
......@@ -78,12 +84,17 @@ sub do_prepared_query {
my @params = @_;
my $sth;
connect_sympa_database() unless $db_source;
unless ($sth = $db_source->do_prepared_query($query,@params)) {
&Log::do_log('err','SQL query failed to execute in the Sympa database');
if (check_db_connect()) {
unless ($sth = $db_source->do_prepared_query($query, @params)) {
Log::do_log('err',
'SQL query failed to execute in the Sympa database');
return undef;
}
} else {
Log::do_log('err', 'Unable to get a handle to Sympa database');
return undef;
}
return $sth;
}
......@@ -114,7 +125,8 @@ sub check_db_connect {
return undef;
}
unless ($db_source->{'dbh'} && $db_source->{'dbh'}->ping()) {
unless ($db_source and $db_source->{'dbh'} and
$db_source->{'dbh'}->ping()) {
unless (connect_sympa_database(@options)) {
Log::do_log('err', 'Failed to connect to database');
return undef;
......
......@@ -87,9 +87,17 @@ sub upgrade {
return 1;
}
## Check database connectivity and probe database
unless (SDM::check_db_connect('just_try') and SDM::probe_db()) {
Log::do_log('err',
'Database %s defined in sympa.conf has not the right structure or is unreachable. verify db_xxx parameters in sympa.conf',
Site->db_name
);
return undef;
}
## Always update config.bin files while upgrading
&Conf::delete_binaries();
SDM::connect_sympa_database;
## Always update config.bin files while upgrading
## This is especially useful for character encoding reasons
Log::do_log('notice',
......
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