"using exceptins (instead of depricated egw_db::hold_on_error attribute) to deal with not set up eGW"

This commit is contained in:
Ralf Becker 2008-10-25 05:43:59 +00:00
parent 9ba17c163c
commit ff16b360f0

View File

@ -84,25 +84,20 @@ class egw extends egw_minimal
// check if eGW is already setup, if not redirect to setup/ // check if eGW is already setup, if not redirect to setup/
try { try {
$this->db->connect(); $this->db->connect();
if (!($num_config = $this->db->select(config::TABLE,'COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle()))
{
$phpgw_config = $this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle();
}
} }
catch(Exception $e) { catch(Exception $e) {
//echo "<pre>Connection to DB failed (".$e->getMessage().")!\n".$e->getTraceAsString(); //echo "<pre>Connection to DB failed (".$e->getMessage().")!\n".$e->getTraceAsString();
} }
$buff = $this->db->Halt_On_Error; if ($e || !$num_config)
$this->db->Halt_On_Error = "report";
$retval=false;
if (is_object($this->db->select(config::TABLE,'COUNT(config_name)',false,__LINE__,__FILE__))) {
$retval = $this->db->select(config::TABLE,'COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle();
} else {
#echo config::TABLE. " does not exist";
}
if ($e || !$retval)
{ {
$setup_dir = str_replace($_SERVER['PHP_SELF'],'index.php','setup/'); $setup_dir = str_replace(array('home/index.php','index.php'),'setup/',$_SERVER['PHP_SELF']);
// we check for the old table too, to not scare updating users ;-) // we check for the old table too, to not scare updating users ;-)
if (!$e && is_object($this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__)) && if ($phpgw_config)
$this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle())
{ {
throw new Exception('<center><b>Fatal Error:</b> You need to <a href="' . $setup_dir . throw new Exception('<center><b>Fatal Error:</b> You need to <a href="' . $setup_dir .
'">update eGroupWare</a> before you can continue using it.</center>',999); '">update eGroupWare</a> before you can continue using it.</center>',999);
@ -114,7 +109,6 @@ class egw extends egw_minimal
} }
exit; exit;
} }
$this->db->Halt_On_Error = $buff;
// Set the DB's client charset if a system-charset is set // Set the DB's client charset if a system-charset is set
$system_charset = $this->db->select(config::TABLE,'config_value',array( $system_charset = $this->db->select(config::TABLE,'config_value',array(
'config_app' => 'phpgwapi', 'config_app' => 'phpgwapi',