summaryrefslogtreecommitdiffstats
path: root/lib/db.php
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-01-22 14:38:44 -0800
committerMichael Gapczynski <mtgap@owncloud.com>2013-01-22 14:38:44 -0800
commit9eecb913380fa2f55a8e24b9a15def241519a0de (patch)
tree7b6fc516e34c256c43d0733040f283b6601dce1e /lib/db.php
parentec8609fa2186f03f5dde215bc7ed06f47cbe47ba (diff)
parent5136f6d818d1cb567cdedc468657fb0d0ed82f85 (diff)
downloadnextcloud-server-9eecb913380fa2f55a8e24b9a15def241519a0de.tar.gz
nextcloud-server-9eecb913380fa2f55a8e24b9a15def241519a0de.zip
Merge pull request #1113 from owncloud/fix-issue-1085
Fix rendering of database connection error page
Diffstat (limited to 'lib/db.php')
-rw-r--r--lib/db.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/db.php b/lib/db.php
index 7cc65673d10..51f7c7679d4 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -184,7 +184,14 @@ class OC_DB {
try{
self::$PDO=new PDO($dsn, $user, $pass, $opts);
}catch(PDOException $e) {
- OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.$e->getMessage().')' );
+ OC_Log::write('core', $e->getMessage(), 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();
}
// We always, really always want associative arrays
self::$PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
@@ -281,7 +288,13 @@ class OC_DB {
if( PEAR::isError( self::$MDB2 )) {
OC_Log::write('core', self::$MDB2->getUserInfo(), OC_Log::FATAL);
OC_Log::write('core', self::$MDB2->getMessage(), OC_Log::FATAL);
- OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')' );
+ 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();
}
// We always, really always want associative arrays