diff --git a/NEWS b/NEWS index 8110adfe..8caa4752 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - speed up compiled templates, hardcode plugin filepaths + instead of dynamically calculate at runtime. (Monte) - fixed bug in _create_dir_structure() when used with open_basedir- restriction and relative paths (messju) - use DIRECTORY_SEPARATOR exclusively, keep DIR_SEP for BC (Monte) diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 13da43dd..a2716c74 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -339,20 +339,23 @@ class Smarty_Compiler extends Smarty { /* Emit code to load needed plugins. */ if (count($this->_plugin_info)) { - $plugins_code = " array("; + $_plugins_params = "array('plugins' => array("; foreach ($this->_plugin_info as $plugin_type => $plugins) { foreach ($plugins as $plugin_name => $plugin_info) { - $plugins_code .= "\narray('$plugin_type', '$plugin_name', '$plugin_info[0]', $plugin_info[1], "; - $plugins_code .= $plugin_info[2] ? 'true),' : 'false),'; + $_plugins_params .= "array('$plugin_type', '$plugin_name', '$plugin_info[0]', $plugin_info[1], "; + $_plugins_params .= $plugin_info[2] ? 'true),' : 'false),'; } } - $plugins_code .= "));\n\$this->_execute_core_function('load_plugins', \$_params); ?>\n"; + $_plugins_params .= '))'; + $_plugin_filepath = $this->_get_plugin_filepath('core', 'load_plugins'); + $plugins_code = "\n"; $template_header .= $plugins_code; $this->_plugin_info = array(); } if ($this->_init_smarty_vars) { - $template_header .= "_execute_core_function('assign_smarty_interface', \$params=null); ?>\n"; + $_plugin_filepath = $this->_get_plugin_filepath('core', 'assign_smarty_interface'); + $template_header .= "\n"; $this->_init_smarty_vars = false; } @@ -765,7 +768,10 @@ class Smarty_Compiler extends Smarty { $this->_add_plugin('insert', $name, $delayed_loading); - return " array(".implode(', ', (array)$arg_list).")); echo \$this->_execute_core_function('run_insert_handler', \$_params); ?>\n"; + $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))"; + $_plugin_filepath = $this->_get_plugin_filepath('core', 'run_insert_handler'); + + return "\n"; } /** @@ -803,9 +809,13 @@ class Smarty_Compiler extends Smarty { } $output .= - "\$_smarty_tpl_vars = \$this->_tpl_vars;\n" . - "\$_params = array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."));\n" . - "\$this->_execute_core_function('smarty_include', \$_params);\n" . + "\$_smarty_tpl_vars = \$this->_tpl_vars;\n"; + + + $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; + $_plugin_filepath = $this->_get_plugin_filepath('core', 'smarty_include'); + + $output .= "require_once('$_plugin_filepath');\nsmarty_core_smarty_include($_params, \$this);\n" . "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . "unset(\$_smarty_tpl_vars);\n"; @@ -844,10 +854,10 @@ class Smarty_Compiler extends Smarty { } } - $output = - " " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', (array)$arg_list).")); \$this->_execute_core_function('smarty_include_php', \$_params); ?>"; - - return $output; + $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; + $_plugin_filepath = $this->_get_plugin_filepath('core', 'smarty_include_php'); + + return "\n"; }