From 4828db003f3ee505eb9e6d056cdb142da34b78ff Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 27 Aug 2009 15:47:54 -0700 Subject: Remove 'ENGINE=InnoDB' specification from tables that we create. Use the system's default table specification. Fixes ticket #597. --- modules/notification/helpers/notification_installer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/notification') diff --git a/modules/notification/helpers/notification_installer.php b/modules/notification/helpers/notification_installer.php index 3d450258..aa2e09f7 100644 --- a/modules/notification/helpers/notification_installer.php +++ b/modules/notification/helpers/notification_installer.php @@ -27,14 +27,14 @@ class notification_installer { PRIMARY KEY (`id`), UNIQUE KEY (`item_id`, `user_id`), UNIQUE KEY (`user_id`, `item_id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {pending_notifications} ( `id` int(9) NOT NULL auto_increment, `email` varchar(128) NOT NULL, `subject` varchar(255) NOT NULL, `text` text, PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + DEFAULT CHARSET=utf8;"); module::set_version("notification", 1); } -- cgit v1.2.3 From 430b57578b048366f054743e47de1b66cebb574e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 28 Aug 2009 10:27:02 -0700 Subject: Wrap all the notification helpers call with a try catch that swallows the exceptions, so the exceptions don't interrupt the upstream processes --- .../notification/helpers/notification_event.php | 75 ++++++++++++++-------- 1 file changed, 47 insertions(+), 28 deletions(-) (limited to 'modules/notification') diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index d1b76e93..fd667ae8 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -18,60 +18,79 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class notification_event_Core { + // The assumption is that the exception was logged at a lower level, but we + // don't want to screw up the processing that was generating the notification + // so we don't pass the exception up the call stack static function item_updated($original, $new) { - notification::send_item_updated($new); + try { + notification::send_item_updated($new); + } catch (Exception $e) {} } static function item_created($item) { - notification::send_item_add($item); + try { + notification::send_item_add($item); + } catch (Exception $e) {} } static function item_deleted($item) { - notification::send_item_deleted($item); + try { + notification::send_item_deleted($item); - if (notification::is_watching($item)) { - notification::remove_watch($item); - } + if (notification::is_watching($item)) { + notification::remove_watch($item); + } + } catch (Exception $e) {} } static function comment_created($comment) { - if ($comment->state == "published") { - notification::send_comment_published($comment); - } + try { + if ($comment->state == "published") { + notification::send_comment_published($comment); + } + } catch (Exception $e) {} } static function comment_updated($original, $new) { - if ($new->state == "published" && $original->state != "published") { - notification::send_comment_published($new); - } + try { + if ($new->state == "published" && $original->state != "published") { + notification::send_comment_published($new); + } + } catch (Exception $e) {} } static function user_before_delete($user) { - ORM::factory("subscription") - ->where("user_id", $user->id) - ->delete_all(); + try { + ORM::factory("subscription") + ->where("user_id", $user->id) + ->delete_all(); + } catch (Exception $e) {} } static function batch_complete() { - notification::send_pending_notifications(); + try { + notification::send_pending_notifications(); + } catch (Exception $e) {} } static function site_menu($menu, $theme) { - if (!user::active()->guest) { - $item = $theme->item(); + try { + if (!user::active()->guest) { + $item = $theme->item(); - if ($item && $item->is_album() && access::can("view", $item)) { - $watching = notification::is_watching($item); + if ($item && $item->is_album() && access::can("view", $item)) { + $watching = notification::is_watching($item); - $label = $watching ? t("Remove notifications") : t("Enable notifications"); + $label = $watching ? t("Remove notifications") : t("Enable notifications"); - $menu->get("options_menu") - ->append(Menu::factory("link") - ->id("watch") - ->label($label) - ->css_id("gNotifyLink") - ->url(url::site("notification/watch/$item->id?csrf=" . access::csrf_token()))); + $menu->get("options_menu") + ->append(Menu::factory("link") + ->id("watch") + ->label($label) + ->css_id("gNotifyLink") + ->url(url::site("notification/watch/$item->id?csrf=" . access::csrf_token()))); + } } - } + } catch (Exception $e) {} } } \ No newline at end of file -- cgit v1.2.3 From 5133f93290e3ab0052909c27dcec05983c819ebe Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 28 Aug 2009 11:51:41 -0700 Subject: Don't record mail failures when we throw the exception, record them when we catch the exception instead. --- modules/gallery/libraries/Sendmail.php | 2 - .../notification/helpers/notification_event.php | 54 +++++++++++++--------- 2 files changed, 33 insertions(+), 23 deletions(-) (limited to 'modules/notification') diff --git a/modules/gallery/libraries/Sendmail.php b/modules/gallery/libraries/Sendmail.php index d6229e07..7bc21a67 100644 --- a/modules/gallery/libraries/Sendmail.php +++ b/modules/gallery/libraries/Sendmail.php @@ -86,8 +86,6 @@ class Sendmail_Core { $headers = implode($this->header_separator, $headers); $message = wordwrap($this->message, $this->line_length, "\n"); if (!$this->mail($to, $this->subject, $message, $headers)) { - Kohana::log("error", wordwrap("Sending mail failed:\nTo: $to\n $this->subject\n" . - "Headers: $headers\n $this->message")); throw new Exception("@todo SEND_MAIL_FAILED"); } return $this; diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index fd667ae8..8fbeda92 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -24,13 +24,17 @@ class notification_event_Core { static function item_updated($original, $new) { try { notification::send_item_updated($new); - } catch (Exception $e) {} + } catch (Exception $e) { + Kohana::log("error", "@todo notification_event::item_updated() failed"); + } } static function item_created($item) { try { notification::send_item_add($item); - } catch (Exception $e) {} + } catch (Exception $e) { + Kohana::log("error", "@todo notification_event::item_created() failed"); + } } static function item_deleted($item) { @@ -40,7 +44,9 @@ class notification_event_Core { if (notification::is_watching($item)) { notification::remove_watch($item); } - } catch (Exception $e) {} + } catch (Exception $e) { + Kohana::log("error", "@todo notification_event::item_deleted() failed"); + } } static function comment_created($comment) { @@ -48,7 +54,9 @@ class notification_event_Core { if ($comment->state == "published") { notification::send_comment_published($comment); } - } catch (Exception $e) {} + } catch (Exception $e) { + Kohana::log("error", "@todo notification_event::comment_created() failed"); + } } static function comment_updated($original, $new) { @@ -56,7 +64,9 @@ class notification_event_Core { if ($new->state == "published" && $original->state != "published") { notification::send_comment_published($new); } - } catch (Exception $e) {} + } catch (Exception $e) { + Kohana::log("error", "@todo notification_event::comment_updated() failed"); + } } static function user_before_delete($user) { @@ -64,33 +74,35 @@ class notification_event_Core { ORM::factory("subscription") ->where("user_id", $user->id) ->delete_all(); - } catch (Exception $e) {} + } catch (Exception $e) { + Kohana::log("error", "@todo notification_event::user_before_delete() failed"); + } } static function batch_complete() { try { notification::send_pending_notifications(); - } catch (Exception $e) {} + } catch (Exception $e) { + Kohana::log("error", "@todo notification_event::batch_complete() failed"); + } } static function site_menu($menu, $theme) { - try { - if (!user::active()->guest) { - $item = $theme->item(); + if (!user::active()->guest) { + $item = $theme->item(); - if ($item && $item->is_album() && access::can("view", $item)) { - $watching = notification::is_watching($item); + if ($item && $item->is_album() && access::can("view", $item)) { + $watching = notification::is_watching($item); - $label = $watching ? t("Remove notifications") : t("Enable notifications"); + $label = $watching ? t("Remove notifications") : t("Enable notifications"); - $menu->get("options_menu") - ->append(Menu::factory("link") - ->id("watch") - ->label($label) - ->css_id("gNotifyLink") - ->url(url::site("notification/watch/$item->id?csrf=" . access::csrf_token()))); - } + $menu->get("options_menu") + ->append(Menu::factory("link") + ->id("watch") + ->label($label) + ->css_id("gNotifyLink") + ->url(url::site("notification/watch/$item->id?csrf=" . access::csrf_token()))); } - } catch (Exception $e) {} + } } } \ No newline at end of file -- cgit v1.2.3 From 6dcfdb6432d556f43736d60de8f310f247868bfa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 28 Aug 2009 12:42:37 -0700 Subject: Fix a bug in notification where were using get() instead of current() to get the first item in an ORM result set. --- modules/notification/helpers/notification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/notification') diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php index 92c40d4f..d95b3060 100644 --- a/modules/notification/helpers/notification.php +++ b/modules/notification/helpers/notification.php @@ -153,7 +153,7 @@ class notification { ->where("email", $email) ->find_all(); if ($result->count() == 1) { - $pending = $result->get(); + $pending = $result->current(); Sendmail::factory() ->to($email) ->subject($pending->subject) -- cgit v1.2.3 From acce8cbafd1987c72b8e3c7be54e91473ab2a525 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 29 Aug 2009 08:47:44 -0700 Subject: Log the actual exception details, before swallowing the exception. --- modules/notification/helpers/notification_event.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules/notification') diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index 8fbeda92..c50b04c4 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -26,6 +26,7 @@ class notification_event_Core { notification::send_item_updated($new); } catch (Exception $e) { Kohana::log("error", "@todo notification_event::item_updated() failed"); + Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } @@ -34,6 +35,7 @@ class notification_event_Core { notification::send_item_add($item); } catch (Exception $e) { Kohana::log("error", "@todo notification_event::item_created() failed"); + Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } @@ -46,6 +48,7 @@ class notification_event_Core { } } catch (Exception $e) { Kohana::log("error", "@todo notification_event::item_deleted() failed"); + Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } @@ -56,6 +59,7 @@ class notification_event_Core { } } catch (Exception $e) { Kohana::log("error", "@todo notification_event::comment_created() failed"); + Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } @@ -66,6 +70,7 @@ class notification_event_Core { } } catch (Exception $e) { Kohana::log("error", "@todo notification_event::comment_updated() failed"); + Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } @@ -76,6 +81,7 @@ class notification_event_Core { ->delete_all(); } catch (Exception $e) { Kohana::log("error", "@todo notification_event::user_before_delete() failed"); + Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } @@ -84,6 +90,7 @@ class notification_event_Core { notification::send_pending_notifications(); } catch (Exception $e) { Kohana::log("error", "@todo notification_event::batch_complete() failed"); + Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } -- cgit v1.2.3