diff --git a/NEWS b/NEWS index 5c255be4..4ab91637 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - treat undefined constants as null (Ferdinand Beyer, Monte) - fix problem with inserts and nested fetches (Rainer Collet, Monte) - added support for passing params to include_php diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index 4ceb2f00..76e172bf 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -1774,10 +1774,7 @@ class Smarty_Compiler extends Smarty { case 'const': array_shift($indexes); - if(!defined(substr($indexes[0],1))) { - $this->_syntax_error('$smarty' . implode('', $indexes) .' is an undefined constant', E_USER_ERROR, __FILE__, __LINE__); - } - $compiled_ref = substr($indexes[0],1); + $compiled_ref = 'defined(' . substr($indexes[0],1) . ') ? ' . substr($indexes[0],1) . ' : null'; break; default: diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 4ceb2f00..76e172bf 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -1774,10 +1774,7 @@ class Smarty_Compiler extends Smarty { case 'const': array_shift($indexes); - if(!defined(substr($indexes[0],1))) { - $this->_syntax_error('$smarty' . implode('', $indexes) .' is an undefined constant', E_USER_ERROR, __FILE__, __LINE__); - } - $compiled_ref = substr($indexes[0],1); + $compiled_ref = 'defined(' . substr($indexes[0],1) . ') ? ' . substr($indexes[0],1) . ' : null'; break; default: