diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2013-01-22 14:38:44 -0800 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2013-01-22 14:38:44 -0800 |
commit | 9eecb913380fa2f55a8e24b9a15def241519a0de (patch) | |
tree | 7b6fc516e34c256c43d0733040f283b6601dce1e /lib/db.php | |
parent | ec8609fa2186f03f5dde215bc7ed06f47cbe47ba (diff) | |
parent | 5136f6d818d1cb567cdedc468657fb0d0ed82f85 (diff) | |
download | nextcloud-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.php | 17 |
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 |