- throw exception on illegal Smarty() constructor calls

This commit is contained in:
Uwe.Tews
2009-11-02 23:04:10 +00:00
parent 7409a9061d
commit 67af69cbb1
2 changed files with 5 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
11/02/2009
- added neq,lte,gte,mod as aliases to if conditions
- throw exception on illegal Smarty() constructor calls
10/31/2009
- change of filenames in sysplugins folder for internal spl_autoload function

View File

@@ -524,15 +524,15 @@ class Smarty extends Smarty_Internal_TemplateBase {
*/
public function __call($name, $args)
{
if ($name == 'Smarty') {
throw new Exception('Please use parent::__construct() to call parent constuctor');
}
if (!is_callable($name)) {
$_plugin_filename = strtolower('smarty_method_' . $name . $this->php_ext);
if (!file_exists(SMARTY_SYSPLUGINS_DIR . $_plugin_filename)) {
throw new Exception("Sysplugin file " . $_plugin_filename . " does not exist");
throw new Exception('Undefined Smarty method "'. $name .'"');
}
require_once(SMARTY_SYSPLUGINS_DIR . $_plugin_filename);
if (!is_callable($name)) {
throw new Exception ("Sysplugin file " . $_plugin_filename . " does not define function " . $name);
}
}
return call_user_func_array($name, array_merge(array($this), $args));
}