Unverified Commit de0ec702 authored by Luc Didry's avatar Luc Didry
Browse files

Tidy up all files

parent df26e55f
......@@ -63,3 +63,6 @@ Makefile
/.includepath
/.project
# Vim tmp file
*.swp
......@@ -257,7 +257,7 @@ sub load {
'force_reload' => $force_reload
}
)
) {
) {
return undef;
}
##_create_robot_like_config_for_main_robot();
......@@ -290,7 +290,7 @@ sub load_robots {
'force_reload' => $param->{'force_reload'}
}
)
) {
) {
$log->syslog(
'err',
'The config for robot %s contain errors: it could not be correctly loaded',
......@@ -438,7 +438,7 @@ sub get_db_conf {
WHERE robot_conf = ? AND label_conf = ?},
$robot, $label
)
) {
) {
$log->syslog(
'err',
'Unable retrieve value of parameter %s for robot %s from the database',
......@@ -480,7 +480,7 @@ sub set_robot_conf {
WHERE robot_conf = ? AND label_conf = ?},
$robot, $label
)
) {
) {
$log->syslog(
'err',
'Unable to check presence of parameter %s for robot %s in database',
......@@ -501,7 +501,7 @@ sub set_robot_conf {
VALUES (?, ?, ?)},
$robot, $label, $value
)
) {
) {
$log->syslog(
'err',
'Unable add value %s for parameter %s in the robot %s DB conf',
......@@ -520,7 +520,7 @@ sub set_robot_conf {
$robot, $label, $value,
$robot, $label
)
) {
) {
$log->syslog(
'err',
'Unable set parameter %s value to %s in the robot %s DB conf',
......@@ -562,7 +562,7 @@ sub conf_2_db {
. '/robot.conf'
}
)
) {
) {
$config = $result_of_config_loading->{'config'};
}
_remove_unvalid_robot_entry($config);
......@@ -573,7 +573,7 @@ sub conf_2_db {
if (($conf_parameters[$i]->{'vhost'} eq '1')
&& #skip parameters that can't be define by robot so not to be loaded in db at that stage
($config->{$conf_parameters[$i]->{'name'}})
) {
) {
Conf::set_robot_conf(
$robot,
$conf_parameters[$i]->{'name'},
......@@ -642,7 +642,7 @@ sub checkfiles_as_root {
group => Sympa::Constants::GROUP,
mode => 0644,
)
) {
) {
$log->syslog('err', 'Unable to set rights on %s',
$Conf{'db_name'});
return undef;
......@@ -666,7 +666,7 @@ sub checkfiles_as_root {
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
)
) {
) {
$log->syslog('err', 'Unable to set rights on %s',
$Conf{'db_name'});
return undef;
......@@ -781,7 +781,7 @@ sub checkfiles {
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
)
) {
) {
$log->syslog('err', 'Unable to set rights on %s',
$Conf{$qdir});
$config_err++;
......@@ -1060,7 +1060,7 @@ sub _load_auth {
}
unless ($value =~
/^$valid_keywords{$current_paragraph->{'auth_type'}}{$keyword}$/
) {
) {
$log->syslog('err',
'Unknown format "%s" for keyword "%s" in %s line %d',
$value, $keyword, $config_file, $line_num);
......@@ -1263,7 +1263,7 @@ sub lang2charset {
my $locale2charset;
if ($lang and %Conf::Conf # configuration loaded
and $locale2charset = $Conf::Conf{'locale2charset'}
) {
) {
foreach my $l (Sympa::Language::implicated_langs($lang)) {
if (exists $locale2charset->{$l}) {
return $locale2charset->{$l};
......@@ -1323,7 +1323,7 @@ sub load_sql_filter {
'db_user' => {'format' => '.*', 'occurrence' => '0-1',},
'db_passwd' => {'format' => '.*', 'occurrence' => '0-1',},
'db_options' => {'format' => '.*', 'occurrence' => '0-1',},
'db_env' => {'format' => '.*', 'occurrence' => '0-1',},
'db_env' => {'format' => '.*', 'occurrence' => '0-1',},
'db_port' => {'format' => '\d+', 'occurrence' => '0-1',},
'db_timeout' => {'format' => '\d+', 'occurrence' => '0-1',},
}
......@@ -1591,7 +1591,7 @@ sub load_generic_conf_file {
unless ($paragraph[$i] =~
/^\s*$key\s+($structure{$pname}{'format'}{$key}{'format'})\s*$/i
) {
) {
$log->syslog('notice',
'Bad entry "%s" in paragraph "%s" in %s',
$paragraph[$i], $key, $pname, $config_file);
......@@ -1843,7 +1843,7 @@ sub _infer_server_specific_parameter_values {
Sympa::Tools::Data::smart_eq(
$param->{'config_hash'}{'dkim_feature'}, 'on'
)
) {
) {
# dkim_signature_apply_ on nothing if dkim_feature is off
# Sets empty array.
$param->{'config_hash'}{'dkim_signature_apply_on'} = [''];
......@@ -1884,7 +1884,7 @@ sub _infer_server_specific_parameter_values {
foreach my $parameter (
'rfc2369_header_fields', 'anonymous_header_fields',
'remove_headers', 'remove_outgoing_headers'
) {
) {
if ($param->{'config_hash'}{$parameter} eq 'none') {
delete $param->{'config_hash'}{$parameter};
} else {
......
......@@ -71,7 +71,7 @@ sub check {
Hello => $smtp_helo,
Timeout => 30
)
) {
) {
$smtp->mail('');
my $conf = 0;
foreach my $address (@addresses) {
......
......@@ -62,8 +62,8 @@ sub _aliases {
Conf::get_robot_conf($domain, 'return_path_suffix'),
# No longer used by default.
'robot' => $domain,
'default_domain' => $Conf::Conf{'domain'},
'robot' => $domain,
'default_domain' => $Conf::Conf{'domain'},
};
my $aliases_dump;
......@@ -91,7 +91,7 @@ sub add {
return 0
if lc Conf::get_robot_conf($list->{'domain'}, 'sendmail_aliases') eq
'none';
'none';
# Create a lock
my $lock_fh;
......@@ -160,7 +160,7 @@ sub del {
return 0
if lc Conf::get_robot_conf($list->{'domain'}, 'sendmail_aliases') eq
'none';
'none';
# Create a lock
my $lock_fh;
......
......@@ -87,7 +87,7 @@ sub _create_spool {
user => Sympa::Constants::USER(),
group => Sympa::Constants::GROUP()
)
) {
) {
die sprintf 'Cannot create %s: %s', $directory, $ERRNO;
}
}
......@@ -767,7 +767,7 @@ sub _clean_archive_directory {
$answer->{'dir_to_rebuild'},
$answer->{'cleaned_dir'}
)
) {
) {
$log->syslog(
'err',
'Unable to create a temporary directory where to store files for HTML escaping (%s). Cancelling',
......
......@@ -69,7 +69,7 @@ sub _create_spool {
$Conf::Conf{queuebulk}, $self->{msg_directory},
$self->{pct_directory}, $self->{bad_directory},
$self->{bad_msg_directory}, $self->{bad_pct_directory}
) {
) {
unless (-d $directory) {
$log->syslog('info', 'Creating spool %s', $directory);
unless (
......@@ -79,7 +79,7 @@ sub _create_spool {
user => Sympa::Constants::USER(),
group => Sympa::Constants::GROUP()
)
) {
) {
die sprintf 'Cannot create %s: %s', $directory, $ERRNO;
}
}
......@@ -361,7 +361,7 @@ sub _get_recipient_tabs_by_domain {
or
# number of recipients in general
(@sendto and $nrcpt >= Conf::get_robot_conf($robot_id, 'nrcpt'))
) {
) {
undef %rcpt_by_dom;
# do not replace this line by "push @sendtobypacket, \@sendto" !!!
my @tab = @sendto;
......
......@@ -569,16 +569,17 @@ our @params = (
'edit' => '1',
'gettext_comment' =>
'Restrict list ownership to addresses in the specified domains. This can be used to reserve list ownership to a group of trusted users from a set of domains associated with an organization, while allowing editors and subscribers from the Internet at large.',
'default' => undef,
'default' => undef,
},
{ 'name' => 'owner_domain_min',
'sample' => '1',
'gettext_id' => 'Minimum number of owners for each list that must match owner_domain restriction',
'file' => 'sympa.conf',
'default' => '0',
'optional' => '1',
'vhost' => '1',
'edit' => '1',
{ 'name' => 'owner_domain_min',
'sample' => '1',
'gettext_id' =>
'Minimum number of owners for each list that must match owner_domain restriction',
'file' => 'sympa.conf',
'default' => '0',
'optional' => '1',
'vhost' => '1',
'edit' => '1',
'gettext_comment' =>
'Minimum number of owners for each list must satisfy the owner_domain restriction. The default of zero (0) means *all* list owners must match. Setting to 1 requires only one list owner to match owner_domain; all other owners can be from any domain. This setting can be used to ensure that there is always at least one known contact point for any mailing list.',
},
......@@ -2061,7 +2062,7 @@ our @params = (
'file' => 'sympa.conf',
'default' => '300',
},
{ 'name' => 'voot_feature', # Not implemented yet.
{ 'name' => 'voot_feature', # Not implemented yet.
'default' => 'off',
'file' => 'sympa.conf',
},
......
......@@ -91,7 +91,7 @@ sub _init_schema_item {
my %options = @_;
return undef
unless ref $pitem->{format} ne 'HASH' and exists $pitem->{default};
unless ref $pitem->{format} ne 'HASH' and exists $pitem->{default};
my $default = $pitem->{default};
......@@ -670,13 +670,11 @@ sub _validate_changes {
# review the entire new configuration as a whole
foreach my $validation (CORE::keys %global_validations) {
next unless ref $global_validations{$validation} eq 'CODE';
my ($error, $err_info) = $global_validations{$validation}->($self, $new);
my ($error, $err_info) =
$global_validations{$validation}->($self, $new);
next unless $error;
push @$errors,
[
'user', $error, $err_info
];
push @$errors, ['user', $error, $err_info];
$ret = 'invalid';
}
return '' unless %$new;
......@@ -965,7 +963,9 @@ sub _merge_changes_paragraph {
sub get_id {
my $that = shift->{context};
(ref $that eq 'Sympa::List') ? $that->get_id : (defined $that) ? $that : '';
(ref $that eq 'Sympa::List') ? $that->get_id
: (defined $that) ? $that
: '';
}
1;
......
......@@ -73,9 +73,8 @@ sub new {
(exists $params{$_} and defined $params{$_})
? ($_ => $params{$_})
: ()
} (
@{$driver->required_parameters}, @{$driver->optional_parameters}
)
} ( @{$driver->required_parameters}, @{$driver->optional_parameters}
)
);
}
......@@ -155,7 +154,8 @@ sub connect {
unless ($self->ping) {
unless ($persistent_connection_of{$self->{_id}}) {
$log->syslog('err', 'Can\'t connect to Database %s: %s', $self, $DBI::errstr);
$log->syslog('err', 'Can\'t connect to Database %s: %s',
$self, $DBI::errstr);
$self->{_status} = 'failed';
return undef;
}
......
......@@ -102,7 +102,7 @@ sub is_autoinc {
$param->{'table'},
$param->{'field'}
)
) {
) {
$log->syslog('err',
'Unable to gather autoincrement field named %s for table %s',
$param->{'field'}, $param->{'table'});
......@@ -127,7 +127,7 @@ sub set_autoinc {
$param->{'table'}, $param->{'field'},
$param->{'field'}, $field_type
)
) {
) {
$log->syslog('err',
'Unable to set field %s in table %s as autoincrement',
$param->{'field'}, $param->{'table'});
......@@ -171,7 +171,7 @@ sub add_table {
"CREATE TABLE %s (temporary INT) DEFAULT CHARACTER SET utf8",
$param->{'table'}
)
) {
) {
$log->syslog('err', 'Could not create table %s in database %s',
$param->{'table'}, $self->{'db_name'});
return undef;
......@@ -224,7 +224,7 @@ sub update_field {
$param->{'table'}, $param->{'field'}, $param->{'field'},
$param->{'type'}, $options
)
) {
) {
$log->syslog('err', 'Could not change field "%s" in table "%s"',
$param->{'field'}, $param->{'table'});
return undef;
......@@ -262,7 +262,7 @@ sub add_field {
$param->{'field'}, $param->{'type'},
$options
)
) {
) {
$log->syslog('err',
'Could not add field %s to table %s in database %s',
$param->{'field'}, $param->{'table'}, $self->{'db_name'});
......@@ -288,7 +288,7 @@ sub delete_field {
"ALTER TABLE %s DROP COLUMN `%s`", $param->{'table'},
$param->{'field'}
)
) {
) {
$log->syslog('err',
'Could not delete field %s from table %s in database %s',
$param->{'field'}, $param->{'table'}, $self->{'db_name'});
......@@ -362,7 +362,7 @@ sub set_primary_key {
"ALTER TABLE %s ADD PRIMARY KEY (%s)", $param->{'table'},
$fields
)
) {
) {
$log->syslog(
'err',
'Could not set fields %s as primary key for table %s in database %s',
......@@ -417,7 +417,7 @@ sub unset_index {
"ALTER TABLE %s DROP INDEX %s", $param->{'table'},
$param->{'index'}
)
) {
) {
$log->syslog('err',
'Could not drop index %s from table %s in database %s',
$param->{'index'}, $param->{'table'}, $self->{'db_name'});
......@@ -447,7 +447,7 @@ sub set_index {
"ALTER TABLE %s ADD INDEX %s (%s)", $param->{'table'},
$param->{'index_name'}, $fields
)
) {
) {
$log->syslog(
'err',
'Could not add index %s using field %s for table %s in database %s',
......
......@@ -108,7 +108,7 @@ sub is_autoinc {
uc($param->{'table'}),
uc('trg_' . $param->{'field'})
)
) {
) {
$log->syslog('err',
'Unable to gather autoincrement field named %s for table %s',
$param->{'field'}, $param->{'table'});
......@@ -151,7 +151,7 @@ sub set_autoinc {
FROM dual;
END;}, $field, $table, $field, $field
)
) {
) {
$log->syslog('err',
'Unable to set field %s in table %s as autoincrement',
$field, $table);
......@@ -207,7 +207,7 @@ sub get_fields {
FROM all_tab_columns
WHERE table_name = ?}, uc($param->{'table'})
)
) {
) {
$log->syslog('err',
'Could not get the list of fields from table %s in database %s',
$param->{'table'}, $self->{'db_name'});
......@@ -263,7 +263,7 @@ sub update_field {
MODIFY (%s %s %s)},
$param->{'table'}, $param->{'field'}, $param->{'type'}, $options
)
) {
) {
$log->syslog('err', 'Could not change field "%s" in table "%s"',
$param->{'field'}, $param->{'table'});
return undef;
......@@ -296,7 +296,7 @@ sub add_field {
ADD (%s %s %s)},
$param->{'table'}, $param->{'field'}, $param->{'type'}, $options
)
) {
) {
$log->syslog('err',
'Could not add field %s to table %s in database %s',
$param->{'field'}, $param->{'table'}, $self->{'db_name'});
......@@ -324,7 +324,7 @@ sub delete_field {
$param->{'table'},
$param->{'field'}
)
) {
) {
$log->syslog('err',
'Could not delete field %s from table %s in database %s',
$param->{'field'}, $param->{'table'}, $self->{'db_name'});
......@@ -358,7 +358,7 @@ sub get_primary_key {
cons.table_name = ?},
uc($param->{'table'})
)
) {
) {
$log->syslog('err',
'Could not get field list from table %s in database %s',
$param->{'table'}, $self->{'db_name'});
......@@ -384,7 +384,7 @@ sub unset_primary_key {
q{ALTER TABLE %s
DROP PRIMARY KEY}, $param->{'table'}
)
) {
) {
$log->syslog('err',
'Could not drop primary key from table %s in database %s',
$param->{'table'}, $self->{'db_name'});
......@@ -414,7 +414,7 @@ sub set_primary_key {
ADD CONSTRAINT %s PRIMARY KEY (%s)},
$param->{'table'}, $pkname, $fields
)
) {
) {
$log->syslog(
'err',
'Could not set fields %s as primary key for table %s in database %s',
......@@ -446,7 +446,7 @@ sub get_indexes {
WHERE generated = 'N' AND table_name = ?},
uc $param->{'table'}
)
) {
) {
$log->syslog(
'err',
'Could not get the list of indexes from table %s in database %s',
......@@ -504,7 +504,7 @@ sub set_index {
ON %s (%s)},
$param->{'index_name'}, $param->{'table'}, $fields
)
) {
) {
$log->syslog(
'err',
'Could not add index %s using field %s for table %s in database %s',
......
......@@ -142,7 +142,7 @@ sub is_autoinc {
)},
$seqname
)
) {
) {
$log->syslog('err',
'Unable to gather autoincrement field named %s for table %s',
$param->{'field'}, $param->{'table'});
......@@ -167,7 +167,7 @@ sub set_autoinc {
"ALTER TABLE %s ALTER COLUMN %s TYPE BIGINT", $param->{'table'},
$param->{'field'}
)
) {
) {
$log->syslog('err',
'Unable to set type of field %s in table %s as bigint',
$param->{'field'}, $param->{'table'});
......@@ -178,7 +178,7 @@ sub set_autoinc {
"ALTER TABLE %s ALTER COLUMN %s SET DEFAULT NEXTVAL('%s')",
$param->{'table'}, $param->{'field'}, $seqname
)
) {
) {
$log->syslog(
'err',
'Unable to set default value of field %s in table %s as next value of sequence table %s',
......@@ -193,7 +193,7 @@ sub set_autoinc {
"UPDATE %s SET %s = NEXTVAL('%s')", $param->{'table'},
$param->{'field'}, $seqname
)
) {
) {
$log->syslog('err',
'Unable to set sequence %s as value for field %s, table %s',
$seqname, $param->{'field'}, $param->{'table'});
......@@ -270,7 +270,7 @@ sub get_fields {
"SELECT a.attname AS field, t.typname AS type, a.atttypmod AS length FROM pg_class c, pg_attribute a, pg_type t WHERE a.attnum > 0 and a.attrelid = c.oid and c.relname = '%s' and a.atttypid = t.oid order by a.attnum",
$param->{'table'}
)
) {
) {
$log->syslog('err',
'Could not get the list of fields from table %s in database %s',
$param->{'table'}, $self->{'db_name'});
......@@ -361,7 +361,7 @@ sub add_field {
$param->{'field'}, $param->{'type'},
$options
)
) {
) {
$log->syslog('err',
'Could not add field %s to table %s in database %s',
$param->{'field'}, $param->{'table'}, $self->{'db_name'});
......@@ -387,7 +387,7 @@ sub delete_field {
"ALTER TABLE %s DROP COLUMN %s", $param->{'table'},
$param->{'field'}
)
) {
) {
$log->syslog('err',
'Could not delete field %s from table %s in database %s',
$param->{'field'}, $param->{'table'}, $self->{'db_name'});
......@@ -415,7 +415,7 @@ sub get_primary_key {
"SELECT pg_attribute.attname AS field FROM pg_index, pg_class, pg_attribute WHERE pg_class.oid ='%s'::regclass AND indrelid = pg_class.oid AND pg_attribute.attrelid = pg_class.oid AND pg_attribute.attnum = any(pg_index.indkey) AND indisprimary",
$param->{'table'}
)
) {
) {
$log->syslog('err',
'Could not get the primary key from table %s in database %s',
$param->{'table'}, $self->{'db_name'});
......@@ -448,7 +448,7 @@ sub unset_primary_key {
tc.constraint_type = 'PRIMARY KEY'},
$self->quote($self->{'db_name'}), $self->quote($param->{'table'})
)
) {
) {
$log->syslog('err',
'Could not search primary key from table %s in database %s',
$param->{'table'}, $self->{'db_name'});
......@@ -469,7 +469,7 @@ sub unset_primary_key {
q{ALTER TABLE %s DROP CONSTRAINT "%s"}, $param->{'table'},
$key_name
)
) {
) {
$log->syslog('err',
'Could not drop primary key "%s" from table %s in database %s',
$key_name, $param->{'table'}, $self->{'db_name'});
......@@ -504,7 +504,7 @@ sub set_primary_key {
q{ALTER TABLE %s ADD %s (%s)}, $param->{'table'},
$key, $fields
)
) {
) {
$log->syslog(
'err',
'Could not set fields %s as primary key for table %s in database %s',
......@@ -538,7 +538,7 @@ sub get_indexes {
pg_catalog.pg_table_is_visible(c.oid)},
$param->{'table'}
)
) {
) {
$log->syslog('err',
'Could not get the oid for table %s in database %s',
$param->{'table'}, $self->{'db_name'});
......@@ -551,7 +551,7 @@ sub get_indexes {
"SELECT c2.relname, pg_catalog.pg_get_indexdef(i.indexrelid, 0, true) AS description FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i WHERE c.oid = \'%s\' AND c.oid = i.indrelid AND i.indexrelid = c2.oid AND NOT i.indisprimary ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname",
$ref->{'oid'}
)
) {
) {
$log->syslog(
'err',
'Could not get the list of indexes from table %s in database %s',
......@@ -610,7 +610,7 @@ sub set_index {
"CREATE INDEX %s ON %s (%s)", $param->{'index_name'},
$param->{'table'}, $fields
)