fixed fatal error "Exception thrown without a stack frame in Unknown on line 0", if DB does not exist when calling the regular eGW url

This commit is contained in:
Ralf Becker 2008-04-01 10:33:54 +00:00
parent 205e8dbce5
commit 3d909d4776
2 changed files with 29 additions and 18 deletions

View File

@ -81,7 +81,8 @@ class egw extends egw_minimal
}
$this->db->set_app('phpgwapi');
$this->db->Halt_On_Error = 'no';
// check if eGW is already setup, if not redirect to setup/
try {
$this->db->connect(
$GLOBALS['egw_info']['server']['db_name'],
$GLOBALS['egw_info']['server']['db_host'],
@ -90,15 +91,19 @@ class egw extends egw_minimal
$GLOBALS['egw_info']['server']['db_pass'],
$GLOBALS['egw_info']['server']['db_type']
);
// check if eGW is already setup, if not redirect to setup/
if (!$this->db->select(config::TABLE,'COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle())
}
catch(Exception $e) {
//echo "<pre>Connection to DB failed (".$e->getMessage().")!\n".$e->getTraceAsString();
}
if ($e || !$this->db->select(config::TABLE,'COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle())
{
$setup_dir = str_replace($_SERVER['PHP_SELF'],'index.php','setup/');
// we check for the old table too, to not scare updating users ;-)
if ($this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle())
if (!$e && $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 . '">update eGroupWare</a> before you can continue using it.</center>',999);
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);
}
else
{
@ -107,8 +112,6 @@ class egw extends egw_minimal
}
exit;
}
$this->db->Halt_On_Error = 'yes';
// Set the DB's client charset if a system-charset is set
$system_charset = $this->db->select(config::TABLE,'config_value',array(
'config_app' => 'phpgwapi',

View File

@ -1279,12 +1279,16 @@
*/
function lang($key,$vars=null)
{
static $varnames = array('%1','%2','%3','%4');
if(!is_array($vars))
{
$vars = func_get_args();
array_shift($vars); // remove $key
}
return $GLOBALS['egw']->translation->translate($key,$vars);
return is_object($GLOBALS['egw']) && isset($GLOBALS['egw']->translations) ?
$GLOBALS['egw']->translation->translate($key,$vars) :
str_replace($varnames,$vars,$key);
}
}
@ -1359,11 +1363,11 @@ function egw_exception_handler(Exception $e)
'<pre><b>'.$e->getMessage()."</b>\n\n".
$e->getTraceAsString()."</pre>\n";
if (is_object($GLOBALS['egw']) && is_object($GLOBALS['egw']->session))
if (is_object($GLOBALS['egw']) && isset($GLOBALS['egw']->session))
{
'<p><a href="'.$GLOBALS['egw']->link('/index.php').'">'.lang('Click here to resume your eGroupWare Session.').'</a></p>';
}
if (is_object($GLOBALS['egw']) && is_object($GLOBALS['egw']->framework))
if (is_object($GLOBALS['egw']) && isset($GLOBALS['egw']->framework))
{
$GLOBALS['egw']->framework->render($message,$headline);
}
@ -1371,7 +1375,11 @@ function egw_exception_handler(Exception $e)
{
echo "<html>\n<head>\n<title>$headline</title>\n</head>\n<body>\n$message\n</body>\n</html>\n";
}
if (is_object($GLOBALS['egw']) && isset($GLOBALS['egw']->common))
{
$GLOBALS['egw']->common->egw_exit();
}
exit;
}
set_exception_handler('egw_exception_handler');