[Pkg-owncloud-commits] [owncloud] 139/394: backport pullrequest #562
David Prévot
taffit at alioth.debian.org
Fri Nov 8 23:11:48 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.
commit e56de168763ec9d0346810c8ca80a400246913e3
Author: Frank Karlitschek <frank at owncloud.org>
Date: Sat Nov 24 18:56:53 2012 +0100
backport pullrequest #562
---
lib/db.php | 17 ++++++-----------
lib/template.php | 14 ++++++++++++++
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/lib/db.php b/lib/db.php
index f1597fb..4c1c18f 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -168,8 +168,7 @@ class OC_DB {
try{
self::$PDO=new PDO($dsn, $user, $pass, $opts);
}catch(PDOException $e) {
- echo( '<b>can not connect to database, using '.$type.'. ('.$e->getMessage().')</center>');
- die();
+ OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.$e->getMessage().')' );
}
// We always, really always want associative arrays
self::$PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
@@ -263,10 +262,7 @@ class OC_DB {
// Die if we could not connect
if( PEAR::isError( self::$MDB2 )) {
- echo( '<b>can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')</center>');
- OC_Log::write('core', self::$MDB2->getUserInfo(), OC_Log::FATAL);
- OC_Log::write('core', self::$MDB2->getMessage(), OC_Log::FATAL);
- die();
+ OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')' );
}
// We always, really always want associative arrays
@@ -326,7 +322,7 @@ class OC_DB {
$entry .= 'Offending command was: '.htmlentities($query).'<br />';
OC_Log::write('core', $entry,OC_Log::FATAL);
error_log('DB error: '.$entry);
- die( $entry );
+ OC_Template::printErrorPage( $entry );
}
}else{
try{
@@ -336,7 +332,7 @@ class OC_DB {
$entry .= 'Offending command was: '.htmlentities($query).'<br />';
OC_Log::write('core', $entry,OC_Log::FATAL);
error_log('DB error: '.$entry);
- die( $entry );
+ OC_Template::printErrorPage( $entry );
}
$result=new PDOStatementWrapper($result);
}
@@ -449,7 +445,7 @@ class OC_DB {
// Die in case something went wrong
if( $definition instanceof MDB2_Schema_Error ) {
- die( $definition->getMessage().': '.$definition->getUserInfo());
+ OC_Template::printErrorPage( $definition->getMessage().': '.$definition->getUserInfo() );
}
if(OC_Config::getValue('dbtype', 'sqlite')==='oci') {
unset($definition['charset']); //or MDB2 tries SHUTDOWN IMMEDIATE
@@ -461,8 +457,7 @@ class OC_DB {
// Die in case something went wrong
if( $ret instanceof MDB2_Error ) {
- echo (self::$MDB2->getDebugOutput());
- die ($ret->getMessage() . ': ' . $ret->getUserInfo());
+ OC_Template::printErrorPage( self::$MDB2->getDebugOutput().' '.$ret->getMessage() . ': ' . $ret->getUserInfo() );
}
return true;
diff --git a/lib/template.php b/lib/template.php
index 1c52993..5d8baca 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -482,4 +482,18 @@ class OC_Template{
}
return $content->printPage();
}
+
+ /**
+ * @brief Print a fatal error page and terminates the script
+ * @param string $error The error message to show
+ * @param string $hint An option hint message
+ */
+ public static function printErrorPage( $error, $hint = '' ) {
+ $error['error']=$error;
+ $error['hint']=$hint;
+ $errors[]=$error;
+ OC_Template::printGuestPage("", "error", array("errors" => $errors));
+ die();
+ }
+
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list