diff options
| -rw-r--r-- | includes/session.php | 10 | ||||
| -rw-r--r-- | modules_v3/gedcom_favorites/module.php | 4 | ||||
| -rw-r--r-- | modules_v3/gedcom_news/module.php | 4 | ||||
| -rw-r--r-- | modules_v3/googlemap/module.php | 4 | ||||
| -rw-r--r-- | modules_v3/user_blog/module.php | 4 | ||||
| -rw-r--r-- | site-unavailable.php | 86 |
6 files changed, 68 insertions, 44 deletions
diff --git a/includes/session.php b/includes/session.php index 7ca4df308d..1b0e4ca512 100644 --- a/includes/session.php +++ b/includes/session.php @@ -356,15 +356,11 @@ try { unset($dbconfig); // Some of the FAMILY JOIN HUSBAND JOIN WIFE queries can excede the MAX_JOIN_SIZE setting WT_DB::exec("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci', SQL_BIG_SELECTS=1"); - try { - WT_DB::updateSchema(WT_ROOT . 'includes/db_schema/', 'WT_SCHEMA_VERSION', WT_SCHEMA_VERSION); - } catch (PDOException $ex) { - // The schema update scripts should never fail. If they do, there is no clean recovery. - die($ex); - } + WT_DB::updateSchema(WT_ROOT . 'includes/db_schema/', 'WT_SCHEMA_VERSION', WT_SCHEMA_VERSION); } catch (PDOException $ex) { + WT_FlashMessages::addMessage($ex->getMessage(), 'danger'); header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-unavailable.php'); - exit; + throw $ex; } // The config.ini.php file must always be in a fixed location. diff --git a/modules_v3/gedcom_favorites/module.php b/modules_v3/gedcom_favorites/module.php index a38cbf8be6..45a0b43410 100644 --- a/modules_v3/gedcom_favorites/module.php +++ b/modules_v3/gedcom_favorites/module.php @@ -332,7 +332,9 @@ class gedcom_favorites_WT_Module extends WT_Module implements WT_Module_Block { WT_DB::updateSchema(WT_ROOT . WT_MODULES_DIR . 'gedcom_favorites/db_schema/', 'FV_SCHEMA_VERSION', 4); } catch (PDOException $ex) { // The schema update scripts should never fail. If they do, there is no clean recovery. - die($ex); + WT_FlashMessages::addMessage($ex->getMessage(), 'danger'); + header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-unavailable.php'); + throw $ex; } } } diff --git a/modules_v3/gedcom_news/module.php b/modules_v3/gedcom_news/module.php index a5ec4485d8..b8e34859cb 100644 --- a/modules_v3/gedcom_news/module.php +++ b/modules_v3/gedcom_news/module.php @@ -27,7 +27,9 @@ try { WT_DB::updateSchema(WT_ROOT . WT_MODULES_DIR . 'gedcom_news/db_schema/', 'NB_SCHEMA_VERSION', 3); } catch (PDOException $ex) { // The schema update scripts should never fail. If they do, there is no clean recovery. - die($ex); + WT_FlashMessages::addMessage($ex->getMessage(), 'danger'); + header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-unavailable.php'); + throw $ex; } /** diff --git a/modules_v3/googlemap/module.php b/modules_v3/googlemap/module.php index 2c189bf34e..47dc2bca93 100644 --- a/modules_v3/googlemap/module.php +++ b/modules_v3/googlemap/module.php @@ -50,7 +50,9 @@ class googlemap_WT_Module extends WT_Module implements WT_Module_Config, WT_Modu WT_DB::updateSchema(WT_ROOT . WT_MODULES_DIR . '/googlemap/db_schema/', 'GM_SCHEMA_VERSION', 5); } catch (PDOException $ex) { // The schema update scripts should never fail. If they do, there is no clean recovery. - die($ex); + WT_FlashMessages::addMessage($ex->getMessage(), 'danger'); + header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-unavailable.php'); + throw $ex; } // Set default values diff --git a/modules_v3/user_blog/module.php b/modules_v3/user_blog/module.php index 6e8676ef37..9eaba9ff9c 100644 --- a/modules_v3/user_blog/module.php +++ b/modules_v3/user_blog/module.php @@ -27,7 +27,9 @@ try { WT_DB::updateSchema(WT_MODULES_DIR . 'user_blog/db_schema/', 'NB_SCHEMA_VERSION', 3); } catch (PDOException $ex) { // The schema update scripts should never fail. If they do, there is no clean recovery. - die($ex); + WT_FlashMessages::addMessage($ex->getMessage(), 'danger'); + header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-unavailable.php'); + throw $ex; } /** diff --git a/site-unavailable.php b/site-unavailable.php index 096b45df6b..7ea8d01771 100644 --- a/site-unavailable.php +++ b/site-unavailable.php @@ -42,45 +42,65 @@ define('WT_LOCALE', WT_I18N::init()); header('Content-Type: text/html; charset=UTF-8'); header($_SERVER["SERVER_PROTOCOL"] . ' 503 Service Temporarily Unavailable'); -echo - '<!DOCTYPE html>', - '<html ', WT_I18N::html_markup(), '>', - '<head>', - '<meta charset="UTF-8">', - '<title>', WT_WEBTREES, '</title>', - '<meta name="robots" content="noindex,follow">', - '<style type="text/css"> - body {color: gray; background-color: white; font: 14px tahoma, arial, helvetica, sans-serif; padding:10px; } - a {color: #81A9CB; font-weight: bold; text-decoration: none;} - a:hover {text-decoration: underline;} - h1 {color: #81A9CB; font-weight:normal; text-align:center;} - li {line-height:2;} - blockquote {color:red;} - .content { /*margin:auto; width:800px;*/ border:1px solid gray; padding:15px; border-radius:15px;} - .good {color: green;} - </style>', - '</head><body>', - '<h1>', WT_I18N::translate('This website is temporarily unavailable'), '</h1>', - '<div class="content">', - '<p>', WT_I18N::translate('Oops! The webserver is unable to connect to the database server. It could be busy, undergoing maintenance, or simply broken. You should <a href="index.php">try again</a> in a few minutes or contact the website administrator.'), '</p>'; +// The page which redirected here may have provided an error message. +$messages = ''; +foreach (WT_FlashMessages::getMessages() as $message) { + $messages .= + '<blockquote>' . WT_Filter::escapeHtml($message->text) . '</blockquote>'; +} +// If we can't connect to the database at all, give the reason why $config_ini_php = parse_ini_file('data/config.ini.php'); if (is_array($config_ini_php) && array_key_exists('dbhost', $config_ini_php) && array_key_exists('dbport', $config_ini_php) && array_key_exists('dbuser', $config_ini_php) && array_key_exists('dbpass', $config_ini_php) && array_key_exists('dbname', $config_ini_php)) { try { $dbh = new PDO('mysql:host=' . $config_ini_php['dbhost'] . ';port=' . $config_ini_php['dbport'] . ';dbname=' . $config_ini_php['dbname'], $config_ini_php['dbuser'], $config_ini_php['dbpass'], array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE=>PDO::FETCH_OBJ, PDO::ATTR_CASE=>PDO::CASE_LOWER, PDO::ATTR_AUTOCOMMIT=>true)); } catch (PDOException $ex) { - echo '<p>', WT_I18N::translate('The database reported the following error message:'), '</p>'; - echo '<blockquote>', $ex->getMessage(), '</blockquote>'; + $messages .= '<p>' . WT_I18N::translate('The database reported the following error message:') . '</p>'; + $messages .= '<blockquote>' . $ex->getMessage() . '</blockquote>'; } } -echo WT_I18N::translate('If you are the website administrator, you should check that:'); -echo '<ol>'; -echo '<li>', /* I18N: [you should check that:] ... */ WT_I18N::translate('the database connection settings in the file <b>/data/config.ini.php</b> are still correct'), '</li>'; -echo '<li>', /* I18N: [you should check that:] ... */ WT_I18N::translate('the directory <b>/data</b> and the file <b>/data/config.ini.php</b> have access permissions that allow the webserver to read them'), '</li>'; -echo '<li>', /* I18N: [you should check that:] ... */ WT_I18N::translate('you can connect to the database using other applications, such as phpmyadmin'), '</li>'; -echo '</ol>'; -echo '<p class="good">', WT_I18N::translate('If you cannot resolve the problem yourself, you can ask for help on the forums at <a href="http://webtrees.net">webtrees.net</a>'), '</p>'; -echo '</div>'; -echo '</body>'; -echo '</html>'; +?> +<!DOCTYPE html> +<html <?php echo WT_I18N::html_markup(); ?>> + <head> + <meta charset="UTF-8"> + <title><?php echo WT_WEBTREES; ?></title> + <meta name="robots" content="noindex,follow"> + <style type="text/css"> + body {color: gray; background-color: white; font: 14px tahoma, arial, helvetica, sans-serif; padding:10px; } + a {color: #81A9CB; font-weight: bold; text-decoration: none;} + a:hover {text-decoration: underline;} + h1 {color: #81A9CB; font-weight:normal; text-align:center;} + li {line-height:2;} + blockquote {color:red;} + .content { /*margin:auto; width:800px;*/ border:1px solid gray; padding:15px; margin: 15px; border-radius:15px;} + .good {color: green;} + .bad { color: red; } + </style> + </head> + <body> + <h1><?php echo WT_I18N::translate('This website is temporarily unavailable'); ?></h1> + <div class="content"> + <p> + <?php echo WT_I18N::translate('Oops! The webserver is unable to connect to the database server. It could be busy, undergoing maintenance, or simply broken. You should <a href="index.php">try again</a> in a few minutes or contact the website administrator.'); ?> + </p> + <?php echo $messages; ?> + <?php echo WT_I18N::translate('If you are the website administrator, you should check that:'); ?> + <ol> + <li> + <?php echo /* I18N: [you should check that:] ... */ WT_I18N::translate('the database connection settings in the file <b>/data/config.ini.php</b> are still correct'); ?> + </li> + <li> + <?php echo /* I18N: [you should check that:] ... */ WT_I18N::translate('the directory <b>/data</b> and the file <b>/data/config.ini.php</b> have access permissions that allow the webserver to read them'); ?> + </li> + <li> + <?php echo /* I18N: [you should check that:] ... */ WT_I18N::translate('you can connect to the database using other applications, such as phpmyadmin'); ?> + </li> + </ol> + <p class="good"> + <?php echo WT_I18N::translate('If you cannot resolve the problem yourself, you can ask for help on the forums at <a href="http://webtrees.net">webtrees.net</a>'); ?> + </p> + </div> + </body> +</html> |
