Skip to content

Commit

Permalink
Merge pull request #12186 from owncloud/fix-12182
Browse files Browse the repository at this point in the history
eliminate OC_Template::printErrorPage in database classes, fixes #12182
  • Loading branch information
MorrisJobke committed Nov 15, 2014
2 parents c44e3b0 + 74ffda8 commit b9e86b0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
10 changes: 8 additions & 2 deletions lib/private/db/adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function fixupStatement($statement) {
* insert the @input values when they do not exist yet
* @param string $table name
* @param array $input key->value pair, key has to be sanitized properly
* @throws \OC\HintException
* @return int count of inserted rows
*/
public function insertIfNotExist($table, $input) {
Expand Down Expand Up @@ -70,8 +71,13 @@ public function insertIfNotExist($table, $input) {
$entry = 'DB Error: "'.$e->getMessage() . '"<br />';
$entry .= 'Offending command was: ' . $query.'<br />';
\OC_Log::write('core', $entry, \OC_Log::FATAL);
error_log('DB error: ' . $entry);
\OC_Template::printErrorPage( $entry );
$l = \OC::$server->getL10N('lib');
throw new \OC\HintException(
$l->t('Database Error'),
$l->t('Please contact your system administrator.'),
0,
$e
);
}
}
}
18 changes: 14 additions & 4 deletions lib/private/db/adaptersqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ public function insertIfNotExist($table, $input) {
$entry = 'DB Error: "'.$e->getMessage() . '"<br />';
$entry .= 'Offending command was: ' . $query . '<br />';
\OC_Log::write('core', $entry, \OC_Log::FATAL);
error_log('DB error: '.$entry);
\OC_Template::printErrorPage( $entry );
$l = \OC::$server->getL10N('lib');
throw new \OC\HintException(
$l->t('Database Error'),
$l->t('Please contact your system administrator.'),
0,
$e
);
}

if ($stmt->fetchColumn() === '0') {
Expand All @@ -60,8 +65,13 @@ public function insertIfNotExist($table, $input) {
$entry = 'DB Error: "'.$e->getMessage() . '"<br />';
$entry .= 'Offending command was: ' . $query.'<br />';
\OC_Log::write('core', $entry, \OC_Log::FATAL);
error_log('DB error: ' . $entry);
\OC_Template::printErrorPage( $entry );
$l = \OC::$server->getL10N('lib');
throw new \OC\HintException(
$l->t('Database Error'),
$l->t('Please contact your system administrator.'),
0,
$e
);
}

return $result;
Expand Down
16 changes: 9 additions & 7 deletions lib/private/db/statementwrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function execute($input=array()) {
} else {
$result = $this->statement->execute();
}

if ($result === false) {
return false;
}
Expand Down Expand Up @@ -158,14 +158,16 @@ private function tryFixSubstringLastArgumentDataForMSSQL($input) {
OC_Log::write('core', $entry, OC_Log::FATAL);
OC_User::setUserId(null);

// send http status 503
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
OC_Template::printErrorPage('Failed to connect to database');
die ($entry);
$l = \OC::$server->getL10N('lib');
throw new \OC\HintException(
$l->t('Database Error'),
$l->t('Please contact your system administrator.'),
0,
$e
);
}
}

/**
* provide an alias for fetch
*
Expand Down

0 comments on commit b9e86b0

Please sign in to comment.