From 0d60dbef31ea645b8495d8e28fca6c248d20048b Mon Sep 17 00:00:00 2001 From: Alexander Kampmann Date: Mon, 9 Apr 2012 00:45:10 +0200 Subject: added exceptions to dba class added exception handling to index.php, please mind that there is no recovery at the moment added transactions to db update. Please mind that they might not be supported by db table engines. added admin email on failed updates added german translation for admin email --- boot.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'boot.php') diff --git a/boot.php b/boot.php index b1c378d34..c21cefa18 100644 --- a/boot.php +++ b/boot.php @@ -653,8 +653,31 @@ function check_config(&$a) { // call the specific update + global $db; + try { + $db->beginTransaction(); $func = 'update_' . $x; $func($a); + $db->commit(); + } catch(Exception $ex) { + $db->rollback(); + //send the administrator an e-mail + $email_tpl = get_intltext_template("update_fail_eml.tpl"); + $email_tpl = replace_macros($email_tpl, array( + '$sitename' => $a->config['sitename'], + '$siteurl' => $a->get_baseurl(), + '$update' => $x, + '$error' => $ex->getMessage()); + $subject=sprintf(t('Update Error at %s'), $a->get_baseurl()); + + mail($email, $subject, $text, + 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" + . 'Content-type: text/plain; charset=UTF-8' . "\n" + . 'Content-transfer-encoding: 8bit' ); + //try the logger + logger('update failed: '.$ex->getMessage().EOL); + } + } } set_config('system','build', DB_UPDATE_VERSION); -- cgit v1.2.3