summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-09-22 14:25:52 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-09-22 14:25:52 -0700
commit28060d9dce3128cb0254d61a66d865fe8f4e1583 (patch)
tree74b03472053740e3a0dec9a529a44cc52a7258e2 /modules
parent1dc3f375bf2f0d035d2c6b90449f248e348d7290 (diff)
Create a gallery error handler that traps php errors and rethrows them as Exceptions. This fixes ticket #763
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/helpers/gallery_error.php32
-rw-r--r--modules/gallery/hooks/init_gallery.php3
2 files changed, 35 insertions, 0 deletions
diff --git a/modules/gallery/helpers/gallery_error.php b/modules/gallery/helpers/gallery_error.php
new file mode 100644
index 00000000..91e05407
--- /dev/null
+++ b/modules/gallery/helpers/gallery_error.php
@@ -0,0 +1,32 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class gallery_error_Core {
+ function error_handler($severity, $message, $filename, $lineno) {
+ if (error_reporting() == 0) {
+ return;
+ }
+
+ if (error_reporting() & $severity) {
+ $e = new ErrorException($message, 0, $severity, $filename, $lineno);
+ log::error("error", $e->getMessage());
+ Kohana::log("error", $e->__toString());
+ }
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/hooks/init_gallery.php b/modules/gallery/hooks/init_gallery.php
index 5735e7dc..da7eeb0f 100644
--- a/modules/gallery/hooks/init_gallery.php
+++ b/modules/gallery/hooks/init_gallery.php
@@ -32,6 +32,9 @@ Event::add("system.post_routing", array("url", "parse_url"));
Event::add("system.post_routing", array("gallery", "maintenance_mode"));
Event::add("system.shutdown", array("gallery", "shutdown"));
+// @todo once we convert to Kohana 2.4 this doesn't have to be here
+set_error_handler(array("gallery_error", "error_handler"));
+
// Override the cookie if we have a session id in the URL.
// @todo This should probably be an event callback
$input = Input::instance();