Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GLPI
glpi
Commits
8569ab8f
Commit
8569ab8f
authored
Feb 10, 2020
by
Cédric Anne
Committed by
Johan Cwiklinski
Feb 10, 2020
Browse files
Add ability to install DB unsing a socket connection; fixes #6919
parent
a2ac6cec
Changes
2
Hide whitespace changes
Inline
Side-by-side
inc/console/database/abstractconfigurecommand.class.php
View file @
8569ab8f
...
...
@@ -215,7 +215,13 @@ abstract class AbstractConfigureCommand extends AbstractCommand implements Force
}
$mysqli
=
new
\
mysqli
();
@
$mysqli
->
connect
(
$db_host
,
$db_user
,
$db_pass
,
null
,
$db_port
);
if
(
intval
(
$db_port
)
>
0
)
{
// Network port
@
$mysqli
->
connect
(
$db_host
,
$db_user
,
$db_pass
,
null
,
$db_port
);
}
else
{
// Unix Domain Socket
@
$mysqli
->
connect
(
$db_host
,
$db_user
,
$db_pass
,
null
,
0
,
$db_port
);
}
if
(
0
!==
$mysqli
->
connect_errno
)
{
$message
=
sprintf
(
...
...
inc/console/database/installcommand.class.php
View file @
8569ab8f
...
...
@@ -176,43 +176,48 @@ class InstallCommand extends AbstractConfigureCommand {
}
}
else
{
// Ask to confirm installation based on existing configuration.
$run
=
$this
->
askForDbConfigConfirmation
(
$input
,
$output
,
$DB
->
dbhost
,
$DB
->
dbdefault
,
$DB
->
dbuser
);
if
(
!
$run
)
{
$output
->
writeln
(
'<comment>'
.
__
(
'Installation aborted.'
)
.
'</comment>'
,
OutputInterface
::
VERBOSITY_VERBOSE
);
return
0
;
}
// $DB->dbhost can be array when using round robin feature
$hostport
=
explode
(
':'
,
is_array
(
$DB
->
dbhost
)
?
$DB
->
dbhost
[
0
]
:
$DB
->
dbhost
);
$db_hostport
=
is_array
(
$DB
->
dbhost
)
?
$DB
->
dbhost
[
0
]
:
$DB
->
dbhost
;
$hostport
=
explode
(
':'
,
$db_hostport
);
$db_host
=
$hostport
[
0
];
if
(
count
(
$hostport
)
<
2
)
{
// Host only case
$db_port
=
null
;
}
else
if
(
intval
(
$hostport
[
1
])
>
0
)
{
// Host:port case
$db_port
=
$hostport
[
1
];
}
else
{
// :Socket case
// TODO Handle socket connection
throw
new
\
UnexpectedValueException
(
'DB connection through socket is not yet handled in installation command'
);
// Host:port case or :Socket case
$db_port
=
$hostport
[
1
];
}
$db_name
=
$DB
->
dbdefault
;
$db_user
=
$DB
->
dbuser
;
$db_pass
=
rawurldecode
(
$DB
->
dbpassword
);
//rawurldecode as in DBmysql::connect()
$run
=
$this
->
askForDbConfigConfirmation
(
$input
,
$output
,
$db_hostport
,
$db_name
,
$db_user
);
if
(
!
$run
)
{
$output
->
writeln
(
'<comment>'
.
__
(
'Installation aborted.'
)
.
'</comment>'
,
OutputInterface
::
VERBOSITY_VERBOSE
);
return
0
;
}
}
$mysqli
=
new
\
mysqli
();
@
$mysqli
->
connect
(
$db_host
,
$db_user
,
$db_pass
,
null
,
$db_port
);
if
(
intval
(
$db_port
)
>
0
)
{
// Network port
@
$mysqli
->
connect
(
$db_host
,
$db_user
,
$db_pass
,
null
,
$db_port
);
}
else
{
// Unix Domain Socket
@
$mysqli
->
connect
(
$db_host
,
$db_user
,
$db_pass
,
null
,
0
,
$db_port
);
}
if
(
0
!==
$mysqli
->
connect_errno
)
{
$message
=
sprintf
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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