Commit b9e86b09 authored by Morris Jobke's avatar Morris Jobke
Browse files

Merge pull request #12186 from owncloud/fix-12182

eliminate OC_Template::printErrorPage in database classes, fixes #12182
parents c44e3b05 74ffda82
...@@ -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
);
} }
} }
} }
...@@ -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;
......
...@@ -158,11 +158,13 @@ class OC_DB_StatementWrapper { ...@@ -158,11 +158,13 @@ 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
);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment