-
Notifications
You must be signed in to change notification settings - Fork 13
If display_errors is FALSE exception messages are still printed to the screen #168
Changes from 5 commits
8d7602e
a584b49
c1e3b27
04615a4
82e252d
696024e
94e8a28
e2fc8d4
d2c24ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,35 +79,46 @@ public function setError($error) | |
public function render($cache = false, $params = array()) | ||
{ | ||
// If no error object is set return null | ||
if (!isset($this->_error)) | ||
if (isset($this->_error)) | ||
{ | ||
return; | ||
$code = $$this->_error->getCode(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo. double $ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ercanozkaya Fixed. |
||
if(!isset(JHttpResponse::$status_messages[$code])) { | ||
$code = '500'; | ||
} | ||
|
||
if(ini_get('display_errors')) { | ||
$message = $this->_error->getMessage(); | ||
} else { | ||
$message = JHttpResponse::$status_messages[$code]; | ||
} | ||
|
||
// Set the status header | ||
JFactory::getApplication()->setHeader('status', $code . ' ' . str_replace("\n", ' ', $message)); | ||
$file = 'error.php'; | ||
|
||
// Check template | ||
$directory = isset($params['directory']) ? $params['directory'] : 'templates'; | ||
$template = isset($params['template']) ? JFilterInput::getInstance()->clean($params['template'], 'cmd') : 'system'; | ||
|
||
if (!file_exists($directory . '/' . $template . '/' . $file)) | ||
{ | ||
$template = 'system'; | ||
} | ||
|
||
// Set variables | ||
$this->baseurl = JUri::base(true); | ||
$this->template = $template; | ||
$this->error = $this->_error; | ||
$this->debug = isset($params['debug']) ? $params['debug'] : false; | ||
$this->code = isset($params['code']) ? $params['code'] : $code; | ||
$this->message = isset($params['message']) ? $params['message'] : $message; | ||
|
||
// Load | ||
$data = $this->_loadTemplate($directory . '/' . $template, $file); | ||
|
||
parent::render(); | ||
return $data; | ||
} | ||
|
||
// Set the status header | ||
JFactory::getApplication()->setHeader('status', $this->_error->getCode() . ' ' . str_replace("\n", ' ', $this->_error->getMessage())); | ||
$file = 'error.php'; | ||
|
||
// Check template | ||
$directory = isset($params['directory']) ? $params['directory'] : 'templates'; | ||
$template = isset($params['template']) ? JFilterInput::getInstance()->clean($params['template'], 'cmd') : 'system'; | ||
|
||
if (!file_exists($directory . '/' . $template . '/' . $file)) | ||
{ | ||
$template = 'system'; | ||
} | ||
|
||
// Set variables | ||
$this->baseurl = JUri::base(true); | ||
$this->template = $template; | ||
$this->debug = isset($params['debug']) ? $params['debug'] : false; | ||
$this->error = $this->_error; | ||
|
||
// Load | ||
$data = $this->_loadTemplate($directory . '/' . $template, $file); | ||
|
||
parent::render(); | ||
return $data; | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,24 +13,24 @@ | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" > | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||
<title><?php echo $this->error->getCode(); ?> - <?php echo htmlspecialchars($this->error->getMessage(), ENT_QUOTES, 'UTF-8'); ?></title> | ||
<title><?php echo $this->error->getCode(); ?> - <?php echo htmlspecialchars($this->message, ENT_QUOTES, 'UTF-8'); ?></title> | ||
<link rel="stylesheet" href="templates/system/css/error.css" type="text/css" /> | ||
</head> | ||
<body> | ||
<table width="550" align="center" class="outline"> | ||
<tr> | ||
<tr> | ||
<td align="center"> | ||
<h1> | ||
<?php echo $this->error->getCode() ?> - <?php echo JText::_('JERROR_AN_ERROR_HAS_OCCURRED') ?> | ||
<?php echo $this->code ?> - <?php echo JText::_('JERROR_AN_ERROR_HAS_OCCURRED') ?> | ||
</h1> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td width="39%" align="center"> | ||
<p><?php echo htmlspecialchars($this->error->getMessage(), ENT_QUOTES, 'UTF-8'); ?></p> | ||
<p><?php echo htmlspecialchars($this->message, ENT_QUOTES, 'UTF-8'); ?></p> | ||
<p><a href="index.php"><?php echo JText::_('JGLOBAL_TPL_CPANEL_LINK_TEXT') ?></a></p> | ||
<p> | ||
<?php if ($this->debug) : | ||
<?php if ($this->debug && ini_get('display_errors')) : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd keep it to $this->debug as before since you might want all the information you can get when debug is on. This is also what we do on Koowa no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ercanozkaya No. We only show render the trace if display_errors is on explicitly. Otherwise we don't. This change make the behavior of platform and framework consistent. I would keep it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @johanjanssens Okay agreed |
||
echo $this->renderBacktrace(); | ||
endif; ?> | ||
</p> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before the condition was !$document, I'd keep it in addition to PHP_SAPI check. Otherwise this might break in json, xml etc where JDocument returns null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ercanozkaya Agreed.