[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7693] API: error handling / fix create new database
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7693] API: error handling / fix create new database |
Date: |
Wed, 21 Sep 2011 13:34:16 +0000 |
Revision: 7693
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7693
Author: sigurdne
Date: 2011-09-21 13:34:15 +0000 (Wed, 21 Sep 2011)
Log Message:
-----------
API: error handling / fix create new database
Modified Paths:
--------------
trunk/phpgwapi/inc/class.db_adodb.inc.php
trunk/phpgwapi/inc/class.db_pdo.inc.php
trunk/phpgwapi/inc/class.setup.inc.php
trunk/phpgwapi/inc/class.setup_detection.inc.php
trunk/setup/index.php
Modified: trunk/phpgwapi/inc/class.db_adodb.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.db_adodb.inc.php 2011-09-20 13:27:43 UTC (rev
7692)
+++ trunk/phpgwapi/inc/class.db_adodb.inc.php 2011-09-21 13:34:15 UTC (rev
7693)
@@ -725,6 +725,7 @@
$this->adodb->Execute("GRANT ALL ON
{$this->Database}.*"
. " TO
{$this->address@hidden'SERVER_NAME']}"
. " IDENTIFIED BY
'{$this->Password}'");
+ break;
default:
//do nothing
}
Modified: trunk/phpgwapi/inc/class.db_pdo.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.db_pdo.inc.php 2011-09-20 13:27:43 UTC (rev
7692)
+++ trunk/phpgwapi/inc/class.db_pdo.inc.php 2011-09-21 13:34:15 UTC (rev
7693)
@@ -961,12 +961,34 @@
$this->db = null; //close the dead connection
to be safe
}
- $this->connect();
-
+ switch ($GLOBALS['phpgw_info']['server']['db_type'])
+ {
+ case 'postgres':
+ $_database = 'postgres';
+ break;
+ default:
+ $_database = null;
+ }
+
+ $database = $this->Database;
+ try
+ {
+ $this->connect($_database);
+ }
+ catch(Exception $e)
+ {
+ if($e)
+ {
+ throw $e;
+ return false;
+ }
+ }
+
+ $this->Database = $database;
+
if ( !$this->db )
{
- echo 'Connection FAILED<br />';
- return False;
+ throw new Exception('ERROR: Connection FAILED');
}
if( !preg_match('/^[a-z0-9_]+$/i', $this->Database) )
@@ -975,8 +997,20 @@
}
//create the db
- $this->db->exec("CREATE DATABASE {$this->Database}");
-
+ $ok = false;
+ try
+ {
+ $ok = $this->db->exec("CREATE DATABASE
{$this->Database}");
+ }
+
+ catch(PDOException $e)
+ {
+ if ( $e )
+ {
+ throw $e;
+ }
+ }
+
//Grant rights on the db
switch ($GLOBALS['phpgw_info']['server']['db_type'])
{
@@ -984,11 +1018,12 @@
$this->db->exec("GRANT ALL ON
{$this->Database}.*"
. " TO
{$this->address@hidden'SERVER_NAME']}"
. " IDENTIFIED BY
'{$this->Password}'");
+ break;
default:
//do nothing
}
$this->db = null;
- return True;
+ return true;
}
/**
Modified: trunk/phpgwapi/inc/class.setup.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.setup.inc.php 2011-09-20 13:27:43 UTC (rev
7692)
+++ trunk/phpgwapi/inc/class.setup.inc.php 2011-09-21 13:34:15 UTC (rev
7693)
@@ -67,7 +67,7 @@
$GLOBALS['phpgw_info']['server']['db_pass'] =
$GLOBALS['phpgw_domain'][$ConfigDomain]['db_pass'];
$GLOBALS['phpgw_info']['server']['db_abstraction'] =
$GLOBALS['phpgw_domain'][$ConfigDomain]['db_abstraction'];
- $this->db = createObject('phpgwapi.db');
+ $this->db = createObject('phpgwapi.db', null,
null, true);
$this->db->fetchmode= 'BOTH';
$GLOBALS['phpgw']->db =& $this->db;
Modified: trunk/phpgwapi/inc/class.setup_detection.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.setup_detection.inc.php 2011-09-20 13:27:43 UTC
(rev 7692)
+++ trunk/phpgwapi/inc/class.setup_detection.inc.php 2011-09-21 13:34:15 UTC
(rev 7693)
@@ -296,7 +296,14 @@
if(!isset($setup_info['phpgwapi']['currentver']))
{
- $setup_info =
$this->get_db_versions($setup_info);
+ try
+ {
+ $setup_info =
$this->get_db_versions($setup_info);
+ }
+ catch(Exception $e)
+ {
+ return 1;
+ }
}
// _debug_array($setup_info);
Modified: trunk/setup/index.php
===================================================================
--- trunk/setup/index.php 2011-09-20 13:27:43 UTC (rev 7692)
+++ trunk/setup/index.php 2011-09-21 13:34:15 UTC (rev 7693)
@@ -244,7 +244,7 @@
flush();
//ob_start();
- $GLOBALS['phpgw_setup']->db->Halt_On_Error = 'report';
+ $GLOBALS['phpgw_setup']->db->Halt_On_Error = 'yes';
switch
($GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'])
{
@@ -255,7 +255,10 @@
}
catch (Exception $e)
{
-
$setup_tpl->set_var('status',$e->getMessage());
+ if($e)
+ {
+
$setup_tpl->set_var('status','Error: ' . $e->getMessage());
+ }
}
break;
case 'drop':
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7693] API: error handling / fix create new database,
Sigurd Nes <=