]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #4036. Hiding exceptions except for admin users.
authorBrett Profitt <brett.profitt@gmail.com>
Sun, 15 Jan 2012 21:40:57 +0000 (13:40 -0800)
committerBrett Profitt <brett.profitt@gmail.com>
Sun, 15 Jan 2012 21:40:57 +0000 (13:40 -0800)
engine/lib/elgglib.php
languages/en.php
views/failsafe/messages/exceptions/exception.php

index 9035d95f2a0c6375badf6d44fd9ea6c57cfda5ec..38ae73d82b6762d473ef75b9bc9b7ddf5e6bb806 100644 (file)
@@ -995,7 +995,8 @@ function elgg_trigger_plugin_hook($hook, $type, $params = null, $returnvalue = n
  * @access private
  */
 function _elgg_php_exception_handler($exception) {
-       error_log("*** FATAL EXCEPTION *** : " . $exception);
+       $timestamp = time();
+       error_log("Exception #$timestamp: $exception");
 
        // Wipe any existing output buffer
        ob_end_clean();
@@ -1011,7 +1012,17 @@ function _elgg_php_exception_handler($exception) {
                $CONFIG->pagesetupdone = true;
 
                elgg_set_viewtype('failsafe');
-               $body = elgg_view("messages/exceptions/exception", array('object' => $exception));
+               if (elgg_is_admin_logged_in()) {
+                       $body = elgg_view("messages/exceptions/admin_exception", array(
+                               'object' => $exception,
+                               'ts' => $timestamp
+                       ));
+               } else {
+                       $body = elgg_view("messages/exceptions/exception", array(
+                               'object' => $exception,
+                               'ts' => $timestamp
+                       ));
+               }
                echo elgg_view_page(elgg_echo('exception:title'), $body);
        } catch (Exception $e) {
                $timestamp = time();
index d9149a689260d71a75cc71471e1dab00cdf1f2ae..97867f922ad11d296444b0bed4df3b354385dab0 100644 (file)
@@ -37,6 +37,7 @@ $english = array(
  * Errors
  */
        'exception:title' => "Fatal Error.",
+       'exception:contact_admin' => 'An unrecoverable error has occurred and has been logged. Contact the site administrator with the following information:',
 
        'actionundefined' => "The requested action (%s) was not defined in the system.",
        'actionnotfound' => "The action file for %s was not found.",
index c35d80c8793b400a5ae76e272e92f3f7ccff749a..1873ca0d905bf8de102bed2ccdc3e77180002080 100644 (file)
 ?>
 
 <p class="elgg-messages-exception">
-       <span title="<?php echo get_class($vars['object']); ?>">
-       <?php
-
-               echo nl2br($vars['object']->getMessage());
-
-       ?>
+       <span title="Unrecoverable Error">
+               <?php echo elgg_echo('exception:contact_admin'); ?>
+               <br /><br />
+               Exception #<?php echo $vars['ts']; ?>.
        </span>
 </p>
-
-<?php
-
-if (elgg_get_config('debug')) {
-?>
-
-<p class="elgg-messages-exception">
-       <?php
-
-               echo nl2br(htmlentities(print_r($vars['object'], true), ENT_QUOTES, 'UTF-8'));
-
-       ?>
-</p>
-<?php
-
-}