- remove not really needed properties

This commit is contained in:
uwetews
2015-08-19 02:19:25 +02:00
parent df541858de
commit 329cd6ec4d
4 changed files with 22 additions and 40 deletions

View File

@@ -6,6 +6,7 @@
- convert debug console processing to object - convert debug console processing to object
- use output buffers for better performance and less memory usage - use output buffers for better performance and less memory usage
- optimize nocache hash processing - optimize nocache hash processing
- remove not really needed properties
06.08.2015 06.08.2015
- avoid possible circular object references caused by parser/lexer objects - avoid possible circular object references caused by parser/lexer objects

View File

@@ -443,16 +443,6 @@ class Smarty extends Smarty_Internal_TemplateBase
*/ */
public $allow_php_templates = false; public $allow_php_templates = false;
/**
* Should compiled-templates be prevented from being called directly?
* {@internal
* Currently used by Smarty_Internal_Template only.
* }}
*
* @var boolean
*/
public $direct_access_security = true;
/**#@-*/ /**#@-*/
/** /**
* debug mode * debug mode
@@ -615,13 +605,6 @@ class Smarty extends Smarty_Internal_TemplateBase
*/ */
public $registered_plugins = array(); public $registered_plugins = array();
/**
* plugin search order
*
* @var array
*/
public $plugin_search_order = array('function', 'block', 'compiler', 'class');
/** /**
* registered objects * registered objects
* *
@@ -699,20 +682,6 @@ class Smarty extends Smarty_Internal_TemplateBase
*/ */
public $start_time = 0; public $start_time = 0;
/**
* default file permissions
*
* @var int
*/
public $_file_perms = 0644;
/**
* default dir permissions
*
* @var int
*/
public $_dir_perms = 0771;
/** /**
* block tag hierarchy * block tag hierarchy
* *
@@ -753,7 +722,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* *
* @var array * @var array
*/ */
public $obsoleteProperties = array('resource_caching', 'template_resource_caching'); public $obsoleteProperties = array('resource_caching', 'template_resource_caching', 'direct_access_security' , '_dir_perms', '_file_perms', 'plugin_search_order');
/** /**
* Extension object cache * Extension object cache
@@ -804,7 +773,6 @@ class Smarty extends Smarty_Internal_TemplateBase
*/ */
public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false) public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
{ {
$this->_cache['core'] = array();
if ($cache_id !== null && is_object($cache_id)) { if ($cache_id !== null && is_object($cache_id)) {
$parent = $cache_id; $parent = $cache_id;
$cache_id = null; $cache_id = null;

View File

@@ -333,6 +333,14 @@ abstract class Smarty_Internal_TemplateCompilerBase
*/ */
public $stripRegEx = '![\t ]*[\r\n]+[\t ]*!'; public $stripRegEx = '![\t ]*[\r\n]+[\t ]*!';
/**
* plugin search order
*
* @var array
*/
public $plugin_search_order = array('function', 'block', 'compiler', 'class');
/** /**
* method to compile a Smarty template * method to compile a Smarty template
* *
@@ -363,6 +371,9 @@ abstract class Smarty_Internal_TemplateCompilerBase
*/ */
public function compileTemplate(Smarty_Internal_Template $template, $nocache = null, $parent_compiler = null) public function compileTemplate(Smarty_Internal_Template $template, $nocache = null, $parent_compiler = null)
{ {
if (property_exists($template->smarty, 'plugin_search_order')) {
$this->plugin_search_order = $template->smarty->plugin_search_order;
}
// save template object in compiler class // save template object in compiler class
$this->template = $template; $this->template = $template;
$this->savedSource = $this->template->source; $this->savedSource = $this->template->source;
@@ -626,7 +637,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
} }
} }
// check plugins from plugins folder // check plugins from plugins folder
foreach ($this->smarty->plugin_search_order as $plugin_type) { foreach ($this->plugin_search_order as $plugin_type) {
if ($plugin_type == Smarty::PLUGIN_COMPILER && if ($plugin_type == Smarty::PLUGIN_COMPILER &&
$this->smarty->loadPlugin('smarty_compiler_' . $tag) && $this->smarty->loadPlugin('smarty_compiler_' . $tag) &&
(!isset($this->smarty->security_policy) || (!isset($this->smarty->security_policy) ||
@@ -667,7 +678,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (is_callable($this->smarty->default_plugin_handler_func)) { if (is_callable($this->smarty->default_plugin_handler_func)) {
$found = false; $found = false;
// look for already resolved tags // look for already resolved tags
foreach ($this->smarty->plugin_search_order as $plugin_type) { foreach ($this->plugin_search_order as $plugin_type) {
if (isset($this->default_handler_plugins[$plugin_type][$tag])) { if (isset($this->default_handler_plugins[$plugin_type][$tag])) {
$found = true; $found = true;
break; break;
@@ -675,7 +686,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
} }
if (!$found) { if (!$found) {
// call default handler // call default handler
foreach ($this->smarty->plugin_search_order as $plugin_type) { foreach ($this->plugin_search_order as $plugin_type) {
if ($this->getPluginFromDefaultHandler($tag, $plugin_type)) { if ($this->getPluginFromDefaultHandler($tag, $plugin_type)) {
$found = true; $found = true;
break; break;

View File

@@ -29,14 +29,16 @@ class Smarty_Internal_Write_File
{ {
$_error_reporting = error_reporting(); $_error_reporting = error_reporting();
error_reporting($_error_reporting & ~E_NOTICE & ~E_WARNING); error_reporting($_error_reporting & ~E_NOTICE & ~E_WARNING);
if ($smarty->_file_perms !== null) { $_file_perms = property_exists($smarty, '_file_perms') ? $smarty->_file_perms : 0644;
$_dir_perms = property_exists($smarty, '_dir_perms') ? (isset($smarty->_dir_perms) ? $smarty->_dir_perms : 0777) : 0644;
if ($_file_perms !== null) {
$old_umask = umask(0); $old_umask = umask(0);
} }
$_dirpath = dirname($_filepath); $_dirpath = dirname($_filepath);
// if subdirs, create dir structure // if subdirs, create dir structure
if ($_dirpath !== '.' && !file_exists($_dirpath)) { if ($_dirpath !== '.' && !file_exists($_dirpath)) {
mkdir($_dirpath, $smarty->_dir_perms === null ? 0777 : $smarty->_dir_perms, true); mkdir($_dirpath, $_dir_perms, true);
} }
// write to tmp file, then move to overt file lock race condition // write to tmp file, then move to overt file lock race condition
@@ -76,9 +78,9 @@ class Smarty_Internal_Write_File
error_reporting($_error_reporting); error_reporting($_error_reporting);
throw new SmartyException("unable to write file {$_filepath}"); throw new SmartyException("unable to write file {$_filepath}");
} }
if ($smarty->_file_perms !== null) { if ($_file_perms !== null) {
// set file permissions // set file permissions
chmod($_filepath, $smarty->_file_perms); chmod($_filepath, $_file_perms);
umask($old_umask); umask($old_umask);
} }
error_reporting($_error_reporting); error_reporting($_error_reporting);