Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Sympa
Commits
9abae3a6
Commit
9abae3a6
authored
Oct 14, 2018
by
IKEDA Soji
Browse files
Fixup: Now db_host parameter became optional.
On mysql & PostgreSQL, undefined db_host is treated as "localhost".
parent
7b3f9b96
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/lib/Conf.pm
View file @
9abae3a6
...
...
@@ -1319,7 +1319,7 @@ sub load_sql_filter {
'
db_type
'
=>
{'
format
'
=>
'
mysql|MySQL|Oracle|Pg|PostgreSQL|SQLite
',},
'
db_name
'
=>
{'
format
'
=>
'
.*
',
'
occurrence
'
=>
'
1
',},
'
db_host
'
=>
{'
format
'
=>
'
.*
',
'
occurrence
'
=>
'
1
',},
'
db_host
'
=>
{'
format
'
=>
'
.*
',
'
occurrence
'
=>
'
0-
1
',},
'
statement
'
=>
{'
format
'
=>
'
.*
',
'
occurrence
'
=>
'
1
',},
'
db_user
'
=>
{'
format
'
=>
'
.*
',
'
occurrence
'
=>
'
0-1
',},
'
db_passwd
'
=>
{'
format
'
=>
'
.*
',
'
occurrence
'
=>
'
0-1
',},
...
...
src/lib/Sympa/ConfDef.pm
View file @
9abae3a6
...
...
@@ -118,13 +118,14 @@ our @params = (
'
edit
'
=>
'
1
',
},
{
'
name
'
=>
'
db_host
',
'
default
'
=>
'
localhost
',
#
'default' => 'localhost',
'
sample
'
=>
'
localhost
',
'
gettext_id
'
=>
'
Hostname of the database server
',
'
gettext_comment
'
=>
'
With PostgreSQL, you can also use the path to Unix Socket Directory, e.g. "/var/run/postgresql" for connection with Unix domain socket.
',
'
file
'
=>
'
sympa.conf
',
'
edit
'
=>
'
1
',
'
optional
'
=>
1
,
},
{
'
name
'
=>
'
db_port
',
'
default
'
=>
undef
,
...
...
src/lib/Sympa/DatabaseDriver.pm
View file @
9abae3a6
...
...
@@ -33,10 +33,10 @@ use warnings;
use
base
qw(Sympa::Database)
;
use
constant
required_modules
=>
[]
;
use
constant
required_parameters
=>
[
qw(
db_host
db_name db_user)
];
use
constant
required_parameters
=>
[
qw(db_name db_user)
];
use
constant
optional_modules
=>
[]
;
use
constant
optional_parameters
=>
[
qw(db_port db_passwd
db_timeout
db_options db_env)
];
[
qw(
db_host
db_port db_passwd db_options db_env)
];
sub
translate_type
{
return
$_
[
1
];
...
...
@@ -87,7 +87,11 @@ By default, no packages are required.
I<Overridable>.
Returns an arrayref including names of required (not optional) parameters.
By default, returns C<['db_host', 'db_name', 'db_user']>.
By default, returns C<['db_name', 'db_user']>.
I<Note>:
On Sympa prior to 6.2.37b.2, it by default returned
C<['db_host', 'db_name', 'db_user']>.
=item optional_modules ( )
...
...
src/lib/Sympa/DatabaseDriver/MySQL.pm
View file @
9abae3a6
...
...
@@ -42,7 +42,9 @@ sub build_connect_string {
my
$self
=
shift
;
my
$connect_string
=
'
DBI:mysql:
'
.
$self
->
{'
db_name
'}
.
'
:
'
.
$self
->
{'
db_host
'};
'
DBI:mysql:
'
.
$self
->
{'
db_name
'}
.
'
:
'
.
(
$self
->
{'
db_host
'}
||
'
localhost
');
$connect_string
.=
'
;port=
'
.
$self
->
{'
db_port
'}
if
defined
$self
->
{'
db_port
'};
$connect_string
.=
'
;
'
.
$self
->
{'
db_options
'}
...
...
src/lib/Sympa/DatabaseDriver/Oracle.pm
View file @
9abae3a6
...
...
@@ -37,10 +37,7 @@ use base qw(Sympa::DatabaseDriver);
my
$log
=
Sympa::
Log
->
instance
;
use
constant
required_modules
=>
[
qw(DBD::Oracle)
];
use
constant
required_parameters
=>
[
qw(db_name db_user)
];
use
constant
optional_parameters
=>
[
qw(db_host db_port db_passwd db_options db_env)
];
use
constant
required_modules
=>
[
qw(DBD::Oracle)
];
sub
build_connect_string
{
my
$self
=
shift
;
...
...
src/lib/Sympa/DatabaseDriver/PostgreSQL.pm
View file @
9abae3a6
...
...
@@ -43,7 +43,10 @@ sub build_connect_string {
my
$self
=
shift
;
my
$connect_string
=
"
DBI:Pg:dbname=
$self
->{'db_name'};host=
$self
->{'db_host'}
";
'
DBI:Pg:dbname=
'
.
$self
->
{'
db_name
'}
.
'
;host=
'
.
(
$self
->
{'
db_host
'}
||
'
localhost
');
$connect_string
.=
'
;port=
'
.
$self
->
{'
db_port
'}
if
defined
$self
->
{'
db_port
'};
$connect_string
.=
'
;
'
.
$self
->
{'
db_options
'}
...
...
src/lib/Sympa/ListDef.pm
View file @
9abae3a6
...
...
@@ -1998,7 +1998,8 @@ our %pinfo = (
'
order
'
=>
2
,
'
gettext_id
'
=>
"
remote host
",
format_s
=>
'
$host
',
'
occurrence
'
=>
'
1
'
# Not required for ODBC and SQLite. Optional for Oracle.
#'occurrence' => '1'
},
'
db_port
'
=>
{
'
order
'
=>
3
,
...
...
src/lib/Sympa/Scenario.pm
View file @
9abae3a6
...
...
@@ -1545,12 +1545,8 @@ sub search {
%
{
$sql_conf
->
{'
sql_named_filter_query
'}}
);
unless
(
$db
and
$db
->
connect
())
{
$log
->
syslog
(
'
notice
',
'
Unable to connect to the SQL server %s:%d
',
$sql_conf
->
{'
db_host
'},
$sql_conf
->
{'
db_port
'}
);
$log
->
syslog
('
notice
',
'
Unable to connect to the SQL server %s
',
$db
);
return
undef
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment