corrected note typos and changed trigger_errors error LEVEL
back to Warning as before, which still is halted by the smarty error handler
This commit is contained in:
@ -71,7 +71,7 @@ function memSnap($tshow = '') {
|
||||
* Set our own exeption handler to convert all errors into exeptions automatically
|
||||
* function_exists() avoids 'cannot redeclare previously declared' fatal errors in XML feed context.
|
||||
*
|
||||
* See Notes returning false
|
||||
* See Notes about returning false
|
||||
*
|
||||
* @access public
|
||||
* @param standard
|
||||
@ -93,23 +93,24 @@ if(!function_exists('errorToExceptionHandler')) {
|
||||
echo '<p> == FULL DEBUG ERROR MODE == </p>';
|
||||
echo '<pre>';
|
||||
// trying to be as detailled as possible
|
||||
if(function_exists('debug_backtrace'))
|
||||
if(function_exists('debug_backtrace')) {
|
||||
print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)); // whether or not to populate the "object" index >= PHP 5.3.6
|
||||
}
|
||||
throw new ErrorException($errStr); // tracepath = all, if not ini_set('display_errors', 0);
|
||||
echo '</pre>'; // if throw new ... endtag is not set, but browsers don't care
|
||||
echo '</pre>'; // if throw new ... endtag is not set, it still looks better and browsers don't care
|
||||
}
|
||||
if($serendipity['production'] !== true) {
|
||||
$e = new Exception;
|
||||
echo '<p> == TESTING ERROR MODE == </p>';
|
||||
echo '<pre>';
|
||||
throw new ErrorException("Serendipity error: " . $errStr); // tracepath = all;
|
||||
echo '</pre>'; // if throw new ... endtag is not set, , but browsers don't care
|
||||
echo '</pre>'; // if throw new ... endtag is not set, it still looks better and browsers don't care
|
||||
} else {
|
||||
// ToDo: enhance for more special serendipity error needs
|
||||
$diestr = '<p> == SERENDIPITY ERROR == </p>';
|
||||
$diestr .= '<p>Please correct:</p>';
|
||||
$diestr .= '<p>' . $errStr . ' in ' . $errFile . ' on line ' . $errLine . '</p>';
|
||||
serendipity_die($diestr); // needs to halt with die() here, else will path through and gets written underneath blog content.
|
||||
$str = '<p> == SERENDIPITY ERROR == </p>';
|
||||
$str .= '<p>Please correct:</p>';
|
||||
$str .= '<p>' . $errStr . ' in ' . $errFile . ' on line ' . $errLine . '</p>';
|
||||
serendipity_die($str); // needs to halt with die() here, else it will path through and gets written underneath blog content.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ function serendipity_smarty_showCommentForm($params, &$smarty) {
|
||||
global $serendipity;
|
||||
|
||||
if (!isset($params['id']) || !isset($params['entry'])) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'id' or 'entry' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'id' or 'entry' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ function serendipity_smarty_showPlugin($params, &$smarty) {
|
||||
global $serendipity;
|
||||
|
||||
if (!isset($params['class']) && !isset($params['id'])) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'class' or 'id' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'class' or 'id' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -490,7 +490,7 @@ function serendipity_smarty_showPlugin($params, &$smarty) {
|
||||
*/
|
||||
function serendipity_smarty_getTotalCount($params, &$smarty) {
|
||||
if (!isset($params['what'])) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'what' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'what' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -521,12 +521,12 @@ function serendipity_smarty_hookPlugin($params, &$smarty) {
|
||||
'frontend_comment',
|
||||
'frontend_footer');
|
||||
if (!isset($params['hook'])) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'hook' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'hook' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!in_array($params['hook'], $hookable) && $params['hookAll'] != 'true') {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": illegal hook '". $params['hook'] ."' (" . $params['hookAll'] . ")", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": illegal hook '". $params['hook'] ."' (" . $params['hookAll'] . ")", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -571,7 +571,7 @@ function serendipity_smarty_refhookPlugin(&$eventData, $hook, $addData = null) {
|
||||
global $serendipity;
|
||||
|
||||
if (!isset($hook)) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'hook' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'hook' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -602,7 +602,7 @@ function serendipity_smarty_refhookPlugin(&$eventData, $hook, $addData = null) {
|
||||
*/
|
||||
function serendipity_smarty_printSidebar($params, &$smarty) {
|
||||
if ( !isset($params['side']) ) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'side' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'side' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -624,7 +624,7 @@ function serendipity_smarty_printSidebar($params, &$smarty) {
|
||||
*/
|
||||
function serendipity_smarty_getFile($params, &$smarty) {
|
||||
if ( !isset($params['file']) ) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'file' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'file' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
return serendipity_getTemplateFile($params['file']);
|
||||
@ -644,12 +644,12 @@ function serendipity_smarty_getFile($params, &$smarty) {
|
||||
*/
|
||||
function serendipity_smarty_pickKey($params, &$smarty) {
|
||||
if ( !isset($params['array']) ) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'array' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'array' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !isset($params['key']) ) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'key' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'key' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -669,11 +669,11 @@ function serendipity_smarty_pickKey($params, &$smarty) {
|
||||
*/
|
||||
function serendipity_smarty_rss_getguid($params, &$smarty) {
|
||||
if ( !isset($params['entry']) ) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'entry' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'entry' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
if ( !isset($params['is_comments']) ) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'is_comments' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'is_comments' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -717,7 +717,7 @@ function &serendipity_smarty_printComments($params, &$smarty) {
|
||||
global $serendipity;
|
||||
|
||||
if (!isset($params['entry'])) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'entry' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'entry' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -774,7 +774,7 @@ function &serendipity_smarty_printComments($params, &$smarty) {
|
||||
*/
|
||||
function &serendipity_smarty_printTrackbacks($params, &$smarty) {
|
||||
if ( !isset($params['entry']) ) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'entry' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'entry' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -814,11 +814,11 @@ function serendipity_smarty_getImageSize($params, &$smarty) {
|
||||
global $serendipity;
|
||||
|
||||
if (!isset($params['file'])) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'file' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'file' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
if (!isset($params['assign'])) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'assign' parameter", E_USER_ERROR);
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'assign' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -826,16 +826,16 @@ function serendipity_smarty_getImageSize($params, &$smarty) {
|
||||
$file = $params['file'];
|
||||
// Most likely the user specified an HTTP path
|
||||
if (!file_exists($file)) {
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . $file;
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . $file;
|
||||
}
|
||||
// Maybe wants a template file (returns filesystem path)
|
||||
if (!file_exists($file)) {
|
||||
$file = serendipity_getTemplateFile($params['file']);
|
||||
$file = serendipity_getTemplateFile($params['file']);
|
||||
}
|
||||
// If no file, trigger an error
|
||||
if (!file_exists($file)) {
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .': file ' . $params['file'] . NOT_FOUND . ' ', E_USER_ERROR);
|
||||
return;
|
||||
trigger_error("Smarty Error: " . __FUNCTION__ .': file ' . $params['file'] . NOT_FOUND . ' ', E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
$smarty->assign($params['assign'], serendipity_getimagesize($file));
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php // (experimental) serendipity_smarty_class.inc.php 2011-12-05 13:09 Ian
|
||||
<?php // (experimental) serendipity_smarty_class.inc.php 2011-12-25 15:19 Ian
|
||||
|
||||
// define secure_dir and trusted_dirs for Serendipity_Smarty_Security_Policy class.
|
||||
@define('S9Y_TEMPLATE_FALLBACK', $serendipity['serendipityPath'] . $serendipity['templatePath'] . 'default');
|
||||
@ -45,7 +45,7 @@ class Serendipity_Smarty_Security_Policy extends Smarty_Security
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function test()
|
||||
public static function test()
|
||||
{
|
||||
var_dump(get_called_class());
|
||||
}
|
||||
@ -104,18 +104,18 @@ class Serendipity_Smarty extends Smarty
|
||||
global $serendipity;
|
||||
|
||||
// some documentary from the smarty forum
|
||||
/*********************************************************
|
||||
* Adressing a specific $template_dir (see 3.1 release notes)
|
||||
*
|
||||
* Smarty 3.1 introduces the $template_dir index notation.
|
||||
* $smarty->fetch('[foo]bar.tpl') and {include file="[foo]bar.tpl"} require the template bar.tpl to be loaded from $template_dir['foo'];
|
||||
* Smarty::setTemplateDir() and Smarty::addTemplateDir() offer ways to define indexes along with the actual directories.
|
||||
**/
|
||||
/*
|
||||
Adressing a specific $template_dir (see 3.1 release notes)
|
||||
|
||||
Smarty 3.1 introduces the $template_dir index notation.
|
||||
$smarty->fetch('[foo]bar.tpl') and {include file="[foo]bar.tpl"} require the template bar.tpl to be loaded from $template_dir['foo'];
|
||||
Smarty::setTemplateDir() and Smarty::addTemplateDir() offer ways to define indexes along with the actual directories.
|
||||
*/
|
||||
|
||||
/*****************************
|
||||
* Set all directory setters
|
||||
* Smarty will always use the first template found in order of the given array. Move the least significant directory to the end.
|
||||
****************************/
|
||||
/* +++++++++++++++++++++++++++++++++++++++++++
|
||||
Set all directory setters
|
||||
Smarty will always use the first template found in order of the given array. Move the least significant directory to the end.
|
||||
*/
|
||||
|
||||
// initiate templateDir setter
|
||||
$this->setTemplateDir(array(S9Y_TEMPLATE_USERDEFAULT));
|
||||
@ -162,9 +162,9 @@ class Serendipity_Smarty extends Smarty
|
||||
Note: rodneyrehm - From within the Smarty class context you can safely access properties like Smarty::$use_sub_dirs directly.
|
||||
*/
|
||||
|
||||
/************************************
|
||||
* Set Smarty caching
|
||||
***********************************/
|
||||
/* +++++++++++++++++++++++++++++++++++
|
||||
Set Smarty caching
|
||||
*/
|
||||
|
||||
/*
|
||||
Caching is disabled, as long as we haven't figured out on how to use it best here....
|
||||
@ -195,26 +195,27 @@ class Serendipity_Smarty extends Smarty
|
||||
*/
|
||||
|
||||
// some documentary from the smarty forum
|
||||
/*********************************************************
|
||||
* With Smarty::CACHING_LIFETIME_SAVED the expiration date is written into the cached file.
|
||||
* So each cache_id / compile_id combination may have their own cache lifetime.
|
||||
* The point is simply, that once the cache lifetime (expiration date) has been saved to the cache file,
|
||||
* it cannot be altered except for clearing and regenerating said cache file
|
||||
*
|
||||
* Template Inheritance
|
||||
* Using is_cached() on sub-templates has to set up caching before is_cached() calls,
|
||||
* e.g if (!$smarty->isCached('sub_test.tpl')) { $smarty->assign('foo', $foo); }.
|
||||
* The subtemplate will always be cached as specified in the {include} tag.
|
||||
* Otherwise you could never cache a subtemplate with caching disabled for the main template.
|
||||
* If you don't want to have the main template cached, turn caching off again after the is_cached() calls for the subtemplate.
|
||||
* So the example will cache sub_test.tpl, but not test.tpl
|
||||
* Using is_cached() on subtemplates has to set up caching before is_cached() calls.
|
||||
* The subtemplate will always be cached as specified in the {include} tag. Otherwise you could never cache a subtemplate with caching disabled for the main template.
|
||||
* If you don't want to have the main template cached, turn caching off again after the is_cached() calls for the subtemplate.
|
||||
* So the example will cache sub_test.tpl but not test.tpl
|
||||
* Use $smarty->caching = Smarty::CACHING_LIFETIME_SAVED; with {include file="sub_test.tpl" cache_lifetime="120"} in test.tpl;
|
||||
* Use $smarty->caching = Smarty::CACHING_LIFETIME_CURRENT; with {include .... caching}
|
||||
**/
|
||||
/*
|
||||
With Smarty::CACHING_LIFETIME_SAVED the expiration date is written into the cached file.
|
||||
So each cache_id / compile_id combination may have their own cache lifetime.
|
||||
The point is simply, that once the cache lifetime (expiration date) has been saved to the cache file,
|
||||
it cannot be altered except for clearing and regenerating said cache file
|
||||
|
||||
Template Inheritance
|
||||
Using is_cached() on sub-templates has to set up caching before is_cached() calls,
|
||||
e.g if (!$smarty->isCached('sub_test.tpl')) { $smarty->assign('foo', $foo); }.
|
||||
The subtemplate will always be cached as specified in the {include} tag.
|
||||
Otherwise you could never cache a subtemplate with caching disabled for the main template.
|
||||
If you don't want to have the main template cached, turn caching off again after the is_cached() calls for the subtemplate.
|
||||
So the example will cache sub_test.tpl, but not test.tpl
|
||||
Using is_cached() on subtemplates has to set up caching before is_cached() calls.
|
||||
The subtemplate will always be cached as specified in the {include} tag.
|
||||
Otherwise you could never cache a subtemplate with caching disabled for the main template.
|
||||
If you don't want to have the main template cached, turn caching off again after the is_cached() calls for the subtemplate.
|
||||
So the example will cache sub_test.tpl but not test.tpl
|
||||
Use $smarty->caching = Smarty::CACHING_LIFETIME_SAVED; with {include file="sub_test.tpl" cache_lifetime="120"} in test.tpl;
|
||||
Use $smarty->caching = Smarty::CACHING_LIFETIME_CURRENT; with {include .... caching}
|
||||
*/
|
||||
|
||||
#cache# $this->caching = Smarty::CACHING_LIFETIME_CURRENT; // $this->setCaching(2); // 1 will change the end of lifetime immediately.
|
||||
# $this->caching = Smarty::CACHING_LIFETIME_SAVED; // $this->setCaching(Smarty::CACHING_LIFETIME_SAVED);
|
||||
@ -233,15 +234,15 @@ class Serendipity_Smarty extends Smarty
|
||||
// set the cache_lifetime for index.tpl to 5 minutes
|
||||
#cache# $this->cache_lifetime = 300; // $this->setCacheLifetime(300); // 86400; // one day: 60*60*24
|
||||
|
||||
// some documentary from the smarty forum
|
||||
/*********************************************************
|
||||
* Smarty caching is based purely on the fetch() or display() call. So:
|
||||
* $smarty->fetch('application.tpl');
|
||||
* Will generate a cached output and use that on repeated calls. If you have multiple versions of this call, you need to pass a cache_id. Example:
|
||||
* $cache_id = md5($_SERVER['REQUEST_URI']);
|
||||
* $smarty->fetch('application.tpl',$cache_id);
|
||||
* It is entirely up to you what is taken into account for the cache_id (URL, etc.)
|
||||
**/
|
||||
// some documentary from the smarty forum
|
||||
/*
|
||||
Smarty caching is based purely on the fetch() or display() call. So:
|
||||
$smarty->fetch('application.tpl');
|
||||
Will generate a cached output and use that on repeated calls. If you have multiple versions of this call, you need to pass a cache_id. Example:
|
||||
$cache_id = md5($_SERVER['REQUEST_URI']);
|
||||
$smarty->fetch('application.tpl',$cache_id);
|
||||
It is entirely up to you what is taken into account for the cache_id (URL, etc.)
|
||||
*/
|
||||
|
||||
// does this mean $this->setCacheId($id); is useless here and has to be set where the actual templates are called? or does ist work as something default?
|
||||
/*
|
||||
@ -254,12 +255,12 @@ class Serendipity_Smarty extends Smarty
|
||||
*/
|
||||
|
||||
// some documentary from the smarty forum
|
||||
/*********************************************************
|
||||
* Smarty will use the cache_id for distributing the cache files into sub_dirs
|
||||
* A cache id is used if you cache different output generated by the same template as for example on a product page.
|
||||
* In such a case you should use a product id as cache id.
|
||||
* $this->cache_id($id); // $this->setCacheId($id);
|
||||
**/
|
||||
/*
|
||||
Smarty will use the cache_id for distributing the cache files into sub_dirs
|
||||
A cache id is used if you cache different output generated by the same template as for example on a product page.
|
||||
In such a case you should use a product id as cache id.
|
||||
$this->cache_id($id); // $this->setCacheId($id);
|
||||
*/
|
||||
|
||||
#cache# $this->cache_id = md5($_SERVER['REQUEST_URI']); // this isn't a good idea either, better have it disabled or use a special id
|
||||
/*
|
||||
@ -268,9 +269,9 @@ class Serendipity_Smarty extends Smarty
|
||||
- see Rodneys first caching note
|
||||
*/
|
||||
|
||||
/************************************************
|
||||
* Set all other needed Smarty class properties
|
||||
***********************************************/
|
||||
/* ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
Set all other needed Smarty class properties
|
||||
*/
|
||||
|
||||
#???# $this->merge_compiled_includes = true; // $this->setMergeCompiledIncludes(true); // what is this for?
|
||||
|
||||
@ -366,7 +367,7 @@ class Serendipity_Smarty extends Smarty
|
||||
$this->assignByRef($tpl_var, $value);
|
||||
}
|
||||
|
||||
static public function test()
|
||||
public static function test()
|
||||
{
|
||||
var_dump(get_called_class());
|
||||
}
|
||||
|
Reference in New Issue
Block a user