Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
provision
Commits
e5b656c2
Commit
e5b656c2
authored
Mar 30, 2011
by
anarcat
Browse files
1102650 by helmo - fail more gracefully in db connexions
parent
c278e0bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
db/db.drush.inc
View file @
e5b656c2
...
...
@@ -21,6 +21,8 @@ function db_drush_exit() {
function
db_drush_help
(
$section
)
{
switch
(
$section
)
{
case
'error:PROVISION_CONNECT_DB_FAILED'
:
return
dt
(
'Unable to connect to database server.'
);
case
'error:PROVISION_CREATE_DB_FAILED'
:
return
dt
(
'Unable to create new databases.'
);
case
'error:PROVISION_DROP_DB_FAILED'
:
...
...
@@ -56,12 +58,15 @@ class provisionService_db extends provisionService {
}
function
verify_server_cmd
()
{
$this
->
connect
();
if
(
$this
->
can_create_database
())
{
drush_log
(
dt
(
'Provision can create new databases.'
),
'message'
);
}
else
{
drush_set_error
(
'PROVISION_CREATE_DB_FAILED'
);
if
(
$this
->
connect
())
{
if
(
$this
->
can_create_database
())
{
drush_log
(
dt
(
'Provision can create new databases.'
),
'message'
);
}
else
{
drush_set_error
(
'PROVISION_CREATE_DB_FAILED'
);
}
}
else
{
drush_set_error
(
'PROVISION_CONNECT_DB_FAILED'
);
}
}
...
...
@@ -281,6 +286,7 @@ class provisionService_db_pdo extends provisionService_db {
function
connect
()
{
try
{
$this
->
conn
=
new
PDO
(
$this
->
dsn
,
$this
->
creds
[
'user'
],
$this
->
creds
[
'pass'
]);
return
$this
->
conn
;
}
catch
(
PDOException
$e
)
{
return
drush_set_error
(
'PROVISION_DB_CONNECT_FAIL'
,
$e
->
getMessage
());
...
...
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