Report a better error message when db is offline.
This commit is contained in:
parent
db220d25c2
commit
019cbc501d
@ -121,6 +121,25 @@ if (! defined('NOREQUIREDB'))
|
|||||||
|
|
||||||
if ($db->error)
|
if ($db->error)
|
||||||
{
|
{
|
||||||
|
// If we were into a website context
|
||||||
|
if (! defined('USEDOLIBARREDITOR') && ! defined('USEDOLIBARRSERVER') && ! empty($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], DOL_DATA_ROOT.'/website') === 0))
|
||||||
|
{
|
||||||
|
$sapi_type = php_sapi_name();
|
||||||
|
if (substr($sapi_type, 0, 3) != 'cgi') http_response_code(503); // To tel search engine this is a temporary error
|
||||||
|
print '<div class="center" style="text-align: center; margin: 100px;">';
|
||||||
|
if (is_object($langs))
|
||||||
|
{
|
||||||
|
$langs->setDefaultLang('auto');
|
||||||
|
$langs->load("website");
|
||||||
|
print $langs->trans("SorryWebsiteIsCurrentlyOffLine");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "SorryWebsiteIsCurrentlyOffLine";
|
||||||
|
}
|
||||||
|
print '</div>';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
dol_print_error($db, "host=".$conf->db->host.", port=".$conf->db->port.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error);
|
dol_print_error($db, "host=".$conf->db->host.", port=".$conf->db->port.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user