Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
b9e86b09
Commit
b9e86b09
authored
Nov 15, 2014
by
Morris Jobke
Browse files
Merge pull request #12186 from owncloud/fix-12182
eliminate OC_Template::printErrorPage in database classes, fixes #12182
parents
c44e3b05
74ffda82
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/private/db/adapter.php
View file @
b9e86b09
...
@@ -43,6 +43,7 @@ class Adapter {
...
@@ -43,6 +43,7 @@ class Adapter {
* insert the @input values when they do not exist yet
* insert the @input values when they do not exist yet
* @param string $table name
* @param string $table name
* @param array $input key->value pair, key has to be sanitized properly
* @param array $input key->value pair, key has to be sanitized properly
* @throws \OC\HintException
* @return int count of inserted rows
* @return int count of inserted rows
*/
*/
public
function
insertIfNotExist
(
$table
,
$input
)
{
public
function
insertIfNotExist
(
$table
,
$input
)
{
...
@@ -70,8 +71,13 @@ class Adapter {
...
@@ -70,8 +71,13 @@ class Adapter {
$entry
=
'DB Error: "'
.
$e
->
getMessage
()
.
'"<br />'
;
$entry
=
'DB Error: "'
.
$e
->
getMessage
()
.
'"<br />'
;
$entry
.
=
'Offending command was: '
.
$query
.
'<br />'
;
$entry
.
=
'Offending command was: '
.
$query
.
'<br />'
;
\
OC_Log
::
write
(
'core'
,
$entry
,
\
OC_Log
::
FATAL
);
\
OC_Log
::
write
(
'core'
,
$entry
,
\
OC_Log
::
FATAL
);
error_log
(
'DB error: '
.
$entry
);
$l
=
\
OC
::
$server
->
getL10N
(
'lib'
);
\
OC_Template
::
printErrorPage
(
$entry
);
throw
new
\
OC\HintException
(
$l
->
t
(
'Database Error'
),
$l
->
t
(
'Please contact your system administrator.'
),
0
,
$e
);
}
}
}
}
}
}
lib/private/db/adaptersqlite.php
View file @
b9e86b09
...
@@ -41,8 +41,13 @@ class AdapterSqlite extends Adapter {
...
@@ -41,8 +41,13 @@ class AdapterSqlite extends Adapter {
$entry
=
'DB Error: "'
.
$e
->
getMessage
()
.
'"<br />'
;
$entry
=
'DB Error: "'
.
$e
->
getMessage
()
.
'"<br />'
;
$entry
.
=
'Offending command was: '
.
$query
.
'<br />'
;
$entry
.
=
'Offending command was: '
.
$query
.
'<br />'
;
\
OC_Log
::
write
(
'core'
,
$entry
,
\
OC_Log
::
FATAL
);
\
OC_Log
::
write
(
'core'
,
$entry
,
\
OC_Log
::
FATAL
);
error_log
(
'DB error: '
.
$entry
);
$l
=
\
OC
::
$server
->
getL10N
(
'lib'
);
\
OC_Template
::
printErrorPage
(
$entry
);
throw
new
\
OC\HintException
(
$l
->
t
(
'Database Error'
),
$l
->
t
(
'Please contact your system administrator.'
),
0
,
$e
);
}
}
if
(
$stmt
->
fetchColumn
()
===
'0'
)
{
if
(
$stmt
->
fetchColumn
()
===
'0'
)
{
...
@@ -60,8 +65,13 @@ class AdapterSqlite extends Adapter {
...
@@ -60,8 +65,13 @@ class AdapterSqlite extends Adapter {
$entry
=
'DB Error: "'
.
$e
->
getMessage
()
.
'"<br />'
;
$entry
=
'DB Error: "'
.
$e
->
getMessage
()
.
'"<br />'
;
$entry
.
=
'Offending command was: '
.
$query
.
'<br />'
;
$entry
.
=
'Offending command was: '
.
$query
.
'<br />'
;
\
OC_Log
::
write
(
'core'
,
$entry
,
\
OC_Log
::
FATAL
);
\
OC_Log
::
write
(
'core'
,
$entry
,
\
OC_Log
::
FATAL
);
error_log
(
'DB error: '
.
$entry
);
$l
=
\
OC
::
$server
->
getL10N
(
'lib'
);
\
OC_Template
::
printErrorPage
(
$entry
);
throw
new
\
OC\HintException
(
$l
->
t
(
'Database Error'
),
$l
->
t
(
'Please contact your system administrator.'
),
0
,
$e
);
}
}
return
$result
;
return
$result
;
...
...
lib/private/db/statementwrapper.php
View file @
b9e86b09
...
@@ -64,7 +64,7 @@ class OC_DB_StatementWrapper {
...
@@ -64,7 +64,7 @@ class OC_DB_StatementWrapper {
}
else
{
}
else
{
$result
=
$this
->
statement
->
execute
();
$result
=
$this
->
statement
->
execute
();
}
}
if
(
$result
===
false
)
{
if
(
$result
===
false
)
{
return
false
;
return
false
;
}
}
...
@@ -158,14 +158,16 @@ class OC_DB_StatementWrapper {
...
@@ -158,14 +158,16 @@ class OC_DB_StatementWrapper {
OC_Log
::
write
(
'core'
,
$entry
,
OC_Log
::
FATAL
);
OC_Log
::
write
(
'core'
,
$entry
,
OC_Log
::
FATAL
);
OC_User
::
setUserId
(
null
);
OC_User
::
setUserId
(
null
);
// send http status 503
$l
=
\
OC
::
$server
->
getL10N
(
'lib'
);
header
(
'HTTP/1.1 503 Service Temporarily Unavailable'
);
throw
new
\
OC\HintException
(
header
(
'Status: 503 Service Temporarily Unavailable'
);
$l
->
t
(
'Database Error'
),
OC_Template
::
printErrorPage
(
'Failed to connect to database'
);
$l
->
t
(
'Please contact your system administrator.'
),
die
(
$entry
);
0
,
$e
);
}
}
}
}
/**
/**
* provide an alias for fetch
* provide an alias for fetch
*
*
...
...
Write
Preview
Markdown
is supported
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