fix bug with compiling config files with caching on

This commit is contained in:
mohrt
2002-12-14 16:50:40 +00:00
parent 2307e780bf
commit 9d5c7f4f55
4 changed files with 32 additions and 24 deletions

View File

@@ -1226,15 +1226,21 @@ function _generate_debug_output() {
$_file_path = str_replace('//', '/' ,$_config_dir . '/' . $file); $_file_path = str_replace('//', '/' ,$_config_dir . '/' . $file);
// get path to compiled object file // get path to compiled object file
$_compile_file = $this->_get_auto_filename($this->compile_dir, $file . $section, 'SMARTY_CONFIG'); if(isset($section)) {
$_compile_file = $this->_get_auto_filename($this->compile_dir, $section . ' ' . $file);
} else {
$_compile_file = $this->_get_auto_filename($this->compile_dir, $file);
}
// need to generate cache? // need to generate cache?
if($this->force_compile || if($this->force_compile || !file_exists($_compile_file) ||
($this->compile_check && ( @filemtime($_compile_file) != @filemtime($_file_path) ))) { ($this->compile_check &&
file_exists($_file_path) &&
( filemtime($_compile_file) != filemtime($_file_path) ))) {
$_generate_cache = true; $_generate_cache = true;
} else { } else {
include($_compile_file); include($_compile_file);
if(empty($_config_vars)) { if(!empty($_config_vars)) {
$_generate_cache = true; $_generate_cache = true;
} else { } else {
$_generate_cache = false; $_generate_cache = false;
@@ -1254,9 +1260,9 @@ function _generate_debug_output() {
if($_config_vars = $this->_conf_obj->get($file, $section)) { if($_config_vars = $this->_conf_obj->get($file, $section)) {
if(function_exists('var_export')) { if(function_exists('var_export')) {
$_compile_data = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>'; $_compile_data = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; return true; ?>';
} else { } else {
$_compile_data = '<?php $_config_vars = unserialize(\'' . str_replace('\'','\\\'', serialize($_config_vars)) . '\'); ?>'; $_compile_data = '<?php $_config_vars = unserialize(\'' . str_replace('\'','\\\'', serialize($_config_vars)) . '\'); return true; ?>';
} }
$this->_write_file($_compile_file, $_compile_data, true); $this->_write_file($_compile_file, $_compile_data, true);
touch($_compile_file,filemtime($_file_path)); touch($_compile_file,filemtime($_file_path));

View File

@@ -542,23 +542,21 @@ class Smarty_Compiler extends Smarty {
$attrs['section'] = 'null'; $attrs['section'] = 'null';
} }
$scope = @$this->_dequote($attrs['scope']); if (isset($attrs['scope'])) {
if (!empty($scope)) { $scope = @$this->_dequote($attrs['scope']);
if ($scope != 'local' && if ($scope != 'local' &&
$scope != 'parent' && $scope != 'parent' &&
$scope != 'global') { $scope != 'global') {
$this->_syntax_error("invalid 'scope' attribute value"); $this->_syntax_error("invalid 'scope' attribute value");
} }
} else { } else {
if (!empty($attrs['global']) && $attrs['global']) if (isset($attrs['global']) && $attrs['global'])
$scope = 'parent'; $scope = 'parent';
else else
$scope = 'local'; $scope = 'local';
} }
$output = '<?php $this->config_load(' . $attrs['file'] . ', ' . $attrs['section'] . ", '$scope'); ?>"; return '<?php $this->config_load(' . $attrs['file'] . ', ' . $attrs['section'] . ", '$scope'); ?>";
return $output;
} }

View File

@@ -1226,15 +1226,21 @@ function _generate_debug_output() {
$_file_path = str_replace('//', '/' ,$_config_dir . '/' . $file); $_file_path = str_replace('//', '/' ,$_config_dir . '/' . $file);
// get path to compiled object file // get path to compiled object file
$_compile_file = $this->_get_auto_filename($this->compile_dir, $file . $section, 'SMARTY_CONFIG'); if(isset($section)) {
$_compile_file = $this->_get_auto_filename($this->compile_dir, $section . ' ' . $file);
} else {
$_compile_file = $this->_get_auto_filename($this->compile_dir, $file);
}
// need to generate cache? // need to generate cache?
if($this->force_compile || if($this->force_compile || !file_exists($_compile_file) ||
($this->compile_check && ( @filemtime($_compile_file) != @filemtime($_file_path) ))) { ($this->compile_check &&
file_exists($_file_path) &&
( filemtime($_compile_file) != filemtime($_file_path) ))) {
$_generate_cache = true; $_generate_cache = true;
} else { } else {
include($_compile_file); include($_compile_file);
if(empty($_config_vars)) { if(!empty($_config_vars)) {
$_generate_cache = true; $_generate_cache = true;
} else { } else {
$_generate_cache = false; $_generate_cache = false;
@@ -1254,9 +1260,9 @@ function _generate_debug_output() {
if($_config_vars = $this->_conf_obj->get($file, $section)) { if($_config_vars = $this->_conf_obj->get($file, $section)) {
if(function_exists('var_export')) { if(function_exists('var_export')) {
$_compile_data = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>'; $_compile_data = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; return true; ?>';
} else { } else {
$_compile_data = '<?php $_config_vars = unserialize(\'' . str_replace('\'','\\\'', serialize($_config_vars)) . '\'); ?>'; $_compile_data = '<?php $_config_vars = unserialize(\'' . str_replace('\'','\\\'', serialize($_config_vars)) . '\'); return true; ?>';
} }
$this->_write_file($_compile_file, $_compile_data, true); $this->_write_file($_compile_file, $_compile_data, true);
touch($_compile_file,filemtime($_file_path)); touch($_compile_file,filemtime($_file_path));

View File

@@ -542,23 +542,21 @@ class Smarty_Compiler extends Smarty {
$attrs['section'] = 'null'; $attrs['section'] = 'null';
} }
$scope = @$this->_dequote($attrs['scope']); if (isset($attrs['scope'])) {
if (!empty($scope)) { $scope = @$this->_dequote($attrs['scope']);
if ($scope != 'local' && if ($scope != 'local' &&
$scope != 'parent' && $scope != 'parent' &&
$scope != 'global') { $scope != 'global') {
$this->_syntax_error("invalid 'scope' attribute value"); $this->_syntax_error("invalid 'scope' attribute value");
} }
} else { } else {
if (!empty($attrs['global']) && $attrs['global']) if (isset($attrs['global']) && $attrs['global'])
$scope = 'parent'; $scope = 'parent';
else else
$scope = 'local'; $scope = 'local';
} }
$output = '<?php $this->config_load(' . $attrs['file'] . ', ' . $attrs['section'] . ", '$scope'); ?>"; return '<?php $this->config_load(' . $attrs['file'] . ', ' . $attrs['section'] . ", '$scope'); ?>";
return $output;
} }