Commit 5e1427ff authored by sikeda's avatar sikeda
Browse files

[-dev] Kill useless global variables $SDM::use_db and $Sympa::List::use_db.

git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@11803 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 77f770bc
......@@ -53,12 +53,12 @@ unless (Conf::load()) {
die 'config_error';
}
if ($Conf::Conf{'db_name'} and $Conf::Conf{'db_type'}) {
unless ($Sympa::List::use_db = SDM::probe_db()) {
die('Database %s defined in sympa.conf has not the right structure or is unreachable. If you don\'t use any database, comment db_xxx parameters in sympa.conf',
$Conf::Conf{'db_name'}
);
}
# Check database connectivity and probe database
#FIXME: Is it required?
unless (SDM::check_db_connect('just_try') and SDM::probe_db()) {
die sprintf
"Database %s defined in sympa.conf has not the right structure or is unreachable. verify db_xxx parameters in sympa.conf\n",
$Conf::Conf{'db_name'};
}
## We have a parameter that should be a template to convert
......
......@@ -55,7 +55,6 @@ my %indexes = %Sympa::DatabaseDescription::indexes;
my @former_indexes = @Sympa::DatabaseDescription::former_indexes;
our $db_source;
our $use_db;
sub do_query {
my $query = shift;
......@@ -143,9 +142,6 @@ sub connect_sympa_database {
Log::do_log('err', 'Unable to create Sympa::Database object');
return undef;
}
## Used to check that connecting to the Sympa database works and the
## Sympa::Database object is created.
$use_db = 1;
# Just in case, we connect to the database here. Probably not necessary.
unless ($db_source->connect()) {
......@@ -318,9 +314,6 @@ sub probe_db {
return undef;
}
## Used by List subroutines to check that the DB is available
$Sympa::List::use_db = 1;
## Notify listmaster
tools::send_notify_to_listmaster('*', 'db_struct_updated',
{'report' => \@report})
......
......@@ -1051,13 +1051,11 @@ sub subscribe {
}
}
if ($Sympa::List::use_db) {
my $u = Sympa::User->new($sender);
$u->lang($list->{'admin'}{'lang'}) unless $u->lang;
$u->password(Sympa::Tools::Password::tmp_passwd($sender))
unless $u->password;
$u->save;
}
my $u = Sympa::User->new($sender);
$u->lang($list->{'admin'}{'lang'}) unless $u->lang;
$u->password(Sympa::Tools::Password::tmp_passwd($sender))
unless $u->password;
$u->save;
## Now send the welcome file to the user
unless ($quiet || ($action =~ /quiet/i)) {
......@@ -1663,13 +1661,11 @@ sub add {
{'email' => $email, 'listname' => $which}, $cmd_line);
}
if ($Sympa::List::use_db) {
my $u = Sympa::User->new($email);
$u->lang($list->{'admin'}{'lang'}) unless $u->lang;
$u->password(Sympa::Tools::Password::tmp_passwd($email))
unless $u->password;
$u->save;
}
my $u = Sympa::User->new($email);
$u->lang($list->{'admin'}{'lang'}) unless $u->lang;
$u->password(Sympa::Tools::Password::tmp_passwd($email))
unless $u->password;
$u->save;
## Now send the welcome file to the user if it exists and notification
## is supposed to be sent.
......
......@@ -956,10 +956,8 @@ sub save_config {
return undef;
}
if ($SDM::use_db) {
unless ($self->_update_list_db) {
Log::do_log('err', "Unable to update list_table");
}
unless ($self->_update_list_db) {
Log::do_log('err', "Unable to update list_table");
}
return 1;
......@@ -5389,19 +5387,17 @@ sub rename_list_db {
}
Log::do_log('debug', 'Statement: %s', $statement_admin);
if ($SDM::use_db) {
unless (
SDM::do_query(
"UPDATE list_table SET name_list=%s, robot_list=%s WHERE (name_list=%s AND robot_list=%s)",
SDM::quote($new_listname),
SDM::quote($new_robot),
SDM::quote($self->{'name'}),
SDM::quote($self->{'domain'})
)
) {
Log::do_log('err', "Unable to rename list in database");
return undef;
}
unless (
SDM::do_query(
"UPDATE list_table SET name_list=%s, robot_list=%s WHERE (name_list=%s AND robot_list=%s)",
SDM::quote($new_listname),
SDM::quote($new_robot),
SDM::quote($self->{'name'}),
SDM::quote($self->{'domain'})
)
) {
Log::do_log('err', "Unable to rename list in database");
return undef;
}
return 1;
......@@ -6501,8 +6497,7 @@ sub _include_users_file {
}
close INCLUDE;
Log::do_log('info', '%d included users from file %s',
$total, $filename);
Log::do_log('info', '%d included users from file %s', $total, $filename);
return $total;
}
......@@ -6617,7 +6612,8 @@ sub _include_users_remote_file {
#FIXME: Reset http credentials
Log::do_log('info', '%d included users from remote file %s', $total, $url);
Log::do_log('info', '%d included users from remote file %s', $total,
$url);
return $total;
}
......@@ -7077,8 +7073,7 @@ sub _include_users_ldap_2level {
}
Log::do_log('debug2', 'Unbinded from LDAP server %s', $source->{'host'});
Log::do_log('info', '%d included users from LDAP query 2level',
$total);
Log::do_log('info', '%d included users from LDAP query 2level', $total);
my $result;
$result->{'total'} = $total;
......@@ -10241,14 +10236,6 @@ sub _load_list_config_file {
## Below are constraints between parameters
############################################
## Do we have a database config/access
unless ($SDM::use_db) {
Log::do_log('info',
'Sympa not setup to use DBI or no database access');
## We should notify the listmaster here...
#return undef;
}
## This default setting MUST BE THE LAST ONE PERFORMED
# if ($admin{'status'} ne 'open') {
# ## requested and closed list are just list hidden using visibility parameter
......
......@@ -301,13 +301,12 @@ sub authenticateAndRun {
my ($self, $email, $cookie, $service, $parameters) = @_;
my $session_id;
if ($parameters) {
Log::do_log('notice', '(%s, %s, %s, %s)',
$email, $cookie, $service, join(',', @$parameters));
}else{
Log::do_log('notice', '(%s, %s, %s)',
$email, $cookie, $service);
}
if ($parameters) {
Log::do_log('notice', '(%s, %s, %s, %s)',
$email, $cookie, $service, join(',', @$parameters));
} else {
Log::do_log('notice', '(%s, %s, %s)', $email, $cookie, $service);
}
unless ($cookie and $service) {
Log::do_log('err', "Missing parameter");
......@@ -376,13 +375,12 @@ sub authenticateRemoteAppAndRun {
my ($self, $appname, $apppassword, $vars, $service, $parameters) = @_;
my $robot = $ENV{'SYMPA_ROBOT'};
if ($parameters) {
Log::do_log('notice', '(%s, %s, %s, %s)',
$appname, $vars, $service, join(',', @$parameters));
}else{
Log::do_log('notice', '(%s, %s, %s)',
$appname, $vars, $service);
}
if ($parameters) {
Log::do_log('notice', '(%s, %s, %s, %s)',
$appname, $vars, $service, join(',', @$parameters));
} else {
Log::do_log('notice', '(%s, %s, %s)', $appname, $vars, $service);
}
unless ($appname and $apppassword and $service) {
die SOAP::Fault->faultcode('Client')
......@@ -1533,12 +1531,10 @@ sub subscribe {
unless $list->add_list_member($u);
}
if ($Sympa::List::use_db) {
my $u = Sympa::User->new($sender);
unless ($u->lang) {
$u->lang($list->{'admin'}{'lang'});
$u->save();
}
my $u = Sympa::User->new($sender);
unless ($u->lang) {
$u->lang($list->{'admin'}{'lang'});
$u->save();
}
## Now send the welcome file to the user
......
......@@ -288,11 +288,9 @@ sub upgrade {
'Unable to fille the robot_admin and robot_subscriber fields in database for robot %s',
$r
);
tools::send_notify_to_listmaster(
'*',
tools::send_notify_to_listmaster('*',
'upgrade_failed',
{ 'error' => $SDM::db_source->error }
);
{'error' => $SDM::db_source->error});
return undef;
}
}
......@@ -361,8 +359,7 @@ sub upgrade {
## DB fields of enum type have been changed to int
if (lower_version($previous_version, '5.2a.1')) {
if ($SDM::use_db && $Conf::Conf{'db_type'} eq 'mysql') {
if ($Conf::Conf{'db_type'} eq 'mysql') {
my %check = (
'subscribed_subscriber' => 'subscriber_table',
'included_subscriber' => 'subscriber_table',
......
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