From 7919d00399e199c34a50f87fd10101d0d8f6f021 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 28 Apr 2012 17:50:28 -0700 Subject: bring back the email and logging of update failures, but without the transactions --- boot.php | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index 105180c23..7564615a5 100644 --- a/boot.php +++ b/boot.php @@ -658,32 +658,26 @@ if(! function_exists('check_config')) { // call the specific update -// global $db; -// $db->excep(TRUE); -// 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()); + $func = 'update_' . $x; + $retval = $func($a); + if($retval) { + //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' => sprintf( t('Update %s failed. See error logs.'), $x) + )); + $subject=sprintf(t('Update Error at %s'), $a->get_baseurl()); -// mail($a->config['admin_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); -// } -// $db->excep(FALSE); + mail($a->config['admin_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('CRITICAL: Update Failed: '. $x); + } } } set_config('system','build', DB_UPDATE_VERSION); -- cgit v1.2.3 From 356bd9b04ad5378b19d4aa8b25ccab178491df34 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 28 Apr 2012 17:53:19 -0700 Subject: some constants for the db update failure possibilities --- boot.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'boot.php') diff --git a/boot.php b/boot.php index 7564615a5..cfdadcd19 100644 --- a/boot.php +++ b/boot.php @@ -73,6 +73,14 @@ define ( 'HOOK_HOOK', 0); define ( 'HOOK_FILE', 1); define ( 'HOOK_FUNCTION', 2); +/** + * DB update return values + */ + +define ( 'UPDATE_SUCCESS', 0); +define ( 'UPDATE_FAILED', 1); + + /** * * page/profile types -- cgit v1.2.3 From b3a71e4327bbe618dbdd15428a4614f58b4e848c Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 28 Apr 2012 21:35:14 -0700 Subject: indicate successful updates --- boot.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index cfdadcd19..616e152f9 100644 --- a/boot.php +++ b/boot.php @@ -671,7 +671,7 @@ if(! function_exists('check_config')) { if($retval) { //send the administrator an e-mail $email_tpl = get_intltext_template("update_fail_eml.tpl"); - $email_tpl = replace_macros($email_tpl, array( + $email_msg = replace_macros($email_tpl, array( '$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$update' => $x, @@ -679,13 +679,16 @@ if(! function_exists('check_config')) { )); $subject=sprintf(t('Update Error at %s'), $a->get_baseurl()); - mail($a->config['admin_email'], $subject, $text, + mail($a->config['admin_email'], $subject, $email_msg, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); //try the logger logger('CRITICAL: Update Failed: '. $x); } + else + set_config('database','update_' . $x, 'success'); + } } set_config('system','build', DB_UPDATE_VERSION); @@ -727,9 +730,10 @@ if(! function_exists('check_config')) { foreach($installed as $i) { if(! in_array($i['name'],$plugins_arr)) { uninstall_plugin($i['name']); - } - else + } + else { $installed_arr[] = $i['name']; + } } } -- cgit v1.2.3 From 249a6814cd777e8eb9d4feb788058ec4683e9522 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Apr 2012 01:08:28 -0700 Subject: add db field for removed account, which will also be the first test of update error checking --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index 616e152f9..100662a8f 100644 --- a/boot.php +++ b/boot.php @@ -11,7 +11,7 @@ require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_VERSION', '2.3.1326' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1139 ); +define ( 'DB_UPDATE_VERSION', 1140 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); -- cgit v1.2.3