- performance Smarty::configLoad() did load unneeded template source object

This commit is contained in:
uwetews
2016-09-11 05:41:16 +02:00
parent 0a8e47ecb2
commit 44189a7531
4 changed files with 17 additions and 15 deletions

View File

@@ -2,6 +2,7 @@
11.09.2016 11.09.2016
- improvement {math} misleading E_USER_WARNING messages when parameter value = null https://github.com/smarty-php/smarty/issues/288 - improvement {math} misleading E_USER_WARNING messages when parameter value = null https://github.com/smarty-php/smarty/issues/288
- improvement move often used code snippets into methods - improvement move often used code snippets into methods
- performance Smarty::configLoad() did load unneeded template source object
09.09.2016 09.09.2016
- bugfix/optimization {foreach} did not execute the {foreachelse} when iterating empty objects https://github.com/smarty-php/smarty/pull/287 - bugfix/optimization {foreach} did not execute the {foreachelse} when iterating empty objects https://github.com/smarty-php/smarty/pull/287

View File

@@ -114,7 +114,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.31-dev/17'; const SMARTY_VERSION = '3.1.31-dev/18';
/** /**
* define variable scopes * define variable scopes

View File

@@ -57,11 +57,10 @@ class Smarty_Internal_Method_ConfigLoad
public function _loadConfigFile(Smarty_Internal_Data $data, $config_file, $sections = null, $scope = 0) public function _loadConfigFile(Smarty_Internal_Data $data, $config_file, $sections = null, $scope = 0)
{ {
/* @var \Smarty $smarty */ /* @var \Smarty $smarty */
$smarty = isset($data->smarty) ? $data->smarty : $data; $smarty = $data->_getSmartyObj();
/* @var \Smarty_Internal_Template $confObj */ /* @var \Smarty_Internal_Template $confObj */
$confObj = new Smarty_Internal_Template($config_file, $smarty, $data); $confObj = new Smarty_Internal_Template($config_file, $smarty, $data, null, null, null, null, true);
$confObj->caching = Smarty::CACHING_OFF; $confObj->caching = Smarty::CACHING_OFF;
$confObj->source = Smarty_Template_Config::load($confObj);
$confObj->source->config_sections = $sections; $confObj->source->config_sections = $sections;
$confObj->source->scope = $scope; $confObj->source->scope = $scope;
$confObj->compiled = Smarty_Template_Compiled::load($confObj); $confObj->compiled = Smarty_Template_Compiled::load($confObj);

View File

@@ -107,19 +107,21 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
* Some of the global Smarty settings copied to template scope * Some of the global Smarty settings copied to template scope
* It load the required template resources and caching plugins * It load the required template resources and caching plugins
* *
* @param string $template_resource template resource string * @param string $template_resource template resource string
* @param Smarty $smarty Smarty instance * @param Smarty $smarty Smarty instance
* @param \Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $_parent back pointer to parent object * @param null|\Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $_parent back pointer to parent object
* with variables or null * with variables or null
* @param mixed $_cache_id cache id or null * @param mixed $_cache_id cache id or null
* @param mixed $_compile_id compile id or null * @param mixed $_compile_id compile id or null
* @param bool $_caching use caching? * @param bool|int|null $_caching use caching?
* @param int $_cache_lifetime cache life-time in seconds * @param int|null $_cache_lifetime cache life-time in seconds
* @param bool $_isConfig
* *
* @throws \SmartyException * @throws \SmartyException
*/ */
public function __construct($template_resource, Smarty $smarty, Smarty_Internal_Data $_parent = null, public function __construct($template_resource, Smarty $smarty, Smarty_Internal_Data $_parent = null,
$_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null) $_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null,
$_isConfig = false)
{ {
$this->smarty = $smarty; $this->smarty = $smarty;
// Smarty parameter // Smarty parameter
@@ -133,7 +135,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
$this->parent = $_parent; $this->parent = $_parent;
// Template resource // Template resource
$this->template_resource = $template_resource; $this->template_resource = $template_resource;
$this->source = Smarty_Template_Source::load($this); $this->source = $_isConfig ? Smarty_Template_Config::load($this) : Smarty_Template_Source::load($this);
parent::__construct(); parent::__construct();
if ($smarty->security_policy && method_exists($smarty->security_policy, 'registerCallBacks')) { if ($smarty->security_policy && method_exists($smarty->security_policy, 'registerCallBacks')) {
$smarty->security_policy->registerCallBacks($this); $smarty->security_policy->registerCallBacks($this);