diff --git a/Config_File.class.php b/Config_File.class.php index af7d4bdf..e752c3a8 100644 --- a/Config_File.class.php +++ b/Config_File.class.php @@ -78,7 +78,7 @@ class Config_File extends PEAR { { $this->PEAR(); - if (substr(PHP_OS, 1, 3) == "WIN") + if (substr(PHP_OS, 1, 3) == "WIN" || substr(PHP_OS, 1, 4) == "OS/2") $this->_separator = "\\"; else $this->_separator = "/"; diff --git a/NEWS b/NEWS index c33aaf28..e4a9c3d5 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,13 @@ blocks. (Andrei, Alexander Belonosov) - added 'field_array' attribute to html_select_time function. (Andrei, Michael Caplan) + - added {section} "max" attribute to docs (Monte) + - fixed notice message in Smarty_Compiler.class.php (Monte) + - fixed bug with clear_cache introduced in 1.4.6, third parameter should be + null (Monte) + - updated Config_File.class.php for "\" support in OS/2 (Monte, Francesco + Ciprianii) + - removed secure_ext setting (not used) (Monte) - made cache reading process more efficient. (Monte) - fixed bug, is_cached() now supports new 1.4.6 caching behavior. (Monte) - update FAQ with mailing list Reply-To header FAQ. (Monte) diff --git a/Smarty.class.php b/Smarty.class.php index 29b136d3..4899e6bd 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -101,8 +101,10 @@ class Smarty // this will tell Smarty not to look for // insert tags and speed up cached page // fetches. + var $cache_handler_func = ''; // function used for cached content. this is + // an alternative to using the file based $cache_dir. - var $tpl_file_ext = '.tpl'; // template file extention + var $tpl_file_ext = '.tpl'; // template file extention (deprecated) var $php_handling = SMARTY_PHP_PASSTHRU; // how smarty handles php tags in the templates @@ -116,7 +118,6 @@ class Smarty var $security = false; // enable template security (default false) var $secure_dir = array('./templates'); // array of directories considered secure - var $secure_ext = array('.tpl'); // array of file extentions considered secure var $security_settings = array( 'PHP_HANDLING' => false, 'IF_FUNCS' => array('array', 'list', @@ -413,9 +414,13 @@ class Smarty Function: clear_cache() Purpose: clear cached content for the given template and cache id \*======================================================================*/ - function clear_cache($tpl_file = null, $cache_id = null, $compile_id) + function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null) { - return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id); + if(!empty($this->cache_handler_func) { + return $$this->cache_handler_func('clear', $tpl_file, $cache_id, $compile_id); + } else { + return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id); + } } @@ -425,7 +430,11 @@ class Smarty \*======================================================================*/ function clear_all_cache() { - return $this->_rm_auto($this->cache_dir); + if(!empty($this->cache_handler_func) { + return $$this->cache_handler_func('clear'); + } else { + return $this->_rm_auto($this->cache_dir); + } } @@ -438,20 +447,7 @@ class Smarty if (!$this->caching) return false; - $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id); - - if (file_exists($cache_file) && - ($this->cache_lifetime == 0 || - (time() - filemtime($cache_file) <= $this->cache_lifetime))) { - if($this->compile_check) { - return $this->_read_cache_file($cache_file,$results); - } else { - return true; - } - } - else - return false; - + return $this->_read_cache_file($tpl_file,$cache_id,$compile_id,$results); } @@ -524,29 +520,22 @@ class Smarty $this->_cache_info[] = array('template', $tpl_file); - $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id); + if($this->_read_cache_file($tpl_file,$cache_id,$compile_id,$results)) { + if ($this->insert_tag_check) { + $results = $this->_process_cached_inserts($results); + } + if ($display) { + echo $results; + if ($this->debugging) + { + // capture time for debugging info + $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time; - if (file_exists($cache_file) && - ($this->cache_lifetime == 0 || - (time() - filemtime($cache_file) <= $this->cache_lifetime))) { - - if($this->_read_cache_file($cache_file,$results)) { - if ($this->insert_tag_check) { - $results = $this->_process_cached_inserts($results); - } - if ($display) { - echo $results; - if ($this->debugging) - { - // capture time for debugging info - $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time; - - echo $this->_generate_debug_output(); - } - return; - } else { - return $results; + echo $this->_generate_debug_output(); } + return; + } else { + return $results; } } } @@ -607,7 +596,7 @@ class Smarty } if ($this->caching) { - $this->_write_cache_file($cache_file, $results); + $this->_write_cache_file($tpl_file,$cache_id,$compile_id,$results); $results = $this->_process_cached_inserts($results); } @@ -869,7 +858,6 @@ function _generate_debug_output() { $smarty_compiler->compiler_funcs = $this->compiler_funcs; $smarty_compiler->security = $this->security; $smarty_compiler->secure_dir = $this->secure_dir; - $smarty_compiler->secure_ext = $this->secure_ext; $smarty_compiler->security_settings = $this->security_settings; if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled)) @@ -1233,62 +1221,91 @@ function _run_insert_handler($args) /*======================================================================*\ Function: _write_cache_file Purpose: Prepend the cache information to the cache file - and write it to disk + and write it \*======================================================================*/ - function _write_cache_file($cache_file,$results) + function _write_cache_file($tpl_file, $cache_id, $compile_id, $results) { - // put the templates involved with this cache in the first line - $cache_info = 'SMARTY_CACHE_INFO_HEADER'.serialize($this->_cache_info)."\n"; - $this->_write_file($cache_file, $cache_info.$results, true); + // put timestamp in cache header + $this->_cache_info['timestamp'] = time(); - return true; + // prepend the cache header info into cache file + $results = 'SMARTY_CACHE_INFO_HEADER'.serialize($this->_cache_info)."\n".$results; + + if(!empty($this->cache_handler_func)) { + // use cache_write_handler function + return $$this->cache_handler_func('write', $tpl_file, $cache_id, $compile_id, $results, $this); + } else { + // use local cache file + $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id); + $this->_write_file($cache_file, $results, true); + return true; + } } /*======================================================================*\ Function: _read_cache_file - Purpose: See if any of the templates for this cache file - have changed or not since the cache was created. - Remove the cache info from the cache results. + Purpose: read a cache file, determine if it needs to be + regenerated or not \*======================================================================*/ - function _read_cache_file($cache_file,&$results) + function _read_cache_file($tpl_file, $cache_id, $compile_id, &$results) { - if( !($cache_header = $this->_read_file($cache_file,1,1) )) { + if ($this->force_compile || $this->cache_lifetime == 0) { + // force compile enabled or cache lifetime is zero, always regenerate return false; } + if(!empty($this->cache_handler_func)) { + + // use cache_read_handler function + return($$this->cache_handler_func('read',$tpl_file, $cache_id, $compile_id, $results, $this)); + + } else { + // use local file cache + + $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id); + return ($results = $this->_read_file($cache_file)); + + } + + $cache_split = explode("\n",$results,2); + $cache_header = $cache_split[0]; + if (substr($cache_header, 0, 24) == 'SMARTY_CACHE_INFO_HEADER') { + $cache_info = unserialize(substr($cache_header, 24)); + $cache_timestamp = $cache_info['timestamp']; + if (time() - $cache_timestamp > $this->cache_lifetime) { + // cache expired, regenerate + return false; + } + if ($this->compile_check) { - $cache_filemtime = filemtime($cache_file); - foreach ($cache_info as $curr_cache_info) { switch ($curr_cache_info[0]) { case 'template': $this->_fetch_template_info($curr_cache_info[1], $template_source, $template_timestamp, false); - if($cache_filemtime < $template_timestamp) { + if($cache_timestamp < $template_timestamp) { // template file has changed, regenerate cache return false; } break; case 'config': - if ($cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) { + if ($cache_timestamp < filemtime($this->config_dir.'/'.$curr_cache_info[1])) { // config file file has changed, regenerate cache return false; } break; } } - } - $results = $this->_read_file($cache_file,2); + $results = $cache_split[1]; + return true; } else { - // no cache info header, pre Smarty 1.4.6 format - $results = $this->_read_file($cache_file); + // no cache info header, pre Smarty 1.4.6 format. regenerate + return false; } - - return true; } diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index c6cc0c6a..00dc05d2 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -374,7 +374,7 @@ class Smarty_Compiler extends Smarty { $attrs['section'] = 'null'; } - @$scope = $this->_dequote($attrs['scope']); + $scope = @$this->_dequote($attrs['scope']); if (!empty($scope)) { if ($scope != 'local' && $scope != 'parent' && diff --git a/docs.sgml b/docs.sgml index 25426e20..8126a67b 100644 --- a/docs.sgml +++ b/docs.sgml @@ -40,9 +40,9 @@ between programming/HTML a couple of times. Thus, it's important to have good template support because programmers don't want anything to do with HTML and don't want HTML designers mucking around with PHP - code. Designers need support for config files, dynamic blocks and other - stuff, but they don't want to have to deal with intricacies of the PHP - programming language. + code. Designers need support for config files, dynamic blocks and + other interface issues, but they don't want to have to deal with + intricacies of the PHP programming language. Looking at many templating solutions available for PHP today, most of @@ -89,10 +89,12 @@ What is Smarty? Smarty is a template engine for PHP. One of the unique aspects about - Smarty that sets it apart from other templating solutions is that it - compiles the templates into native PHP scripts upon the first - invocation. After that, it merely executes the compiled PHP scripts. - Therefore, there is no costly template file parsing for each request. + Smarty is that it compiles the template files into native PHP scripts + upon the first invocation. After that, it just executes the compiled + PHP scripts. Therefore, there is no costly template file parsing for + each request, and each template can take full advantage of PHP compiler + cache solutions such as Zend Cache (http://www.zend.com) or APC + (http://apc.communityconnect.com). Some of Smarty's features: @@ -108,9 +110,9 @@ functions and custom variable modifiers, so the template language is extremely extensible. Configurable template delimiter tag syntax, so you can use - {}, {{}}, <!--{}-->, or whatever you like. + {}, {{}}, <!--{}-->, etc. The if/elseif/else/endif constructs are passed to the - PHP parser, so the if expression syntax can be as simple or as complex + PHP parser, so the {if ...} expression syntax can be as simple or as complex as you like. Unlimited nesting of sections, ifs, etc. allowed. It is possible to embed PHP code right in your template files, @@ -118,6 +120,7 @@ since the engine is so customizable. Built-in caching support (new in 1.3.0) Arbitrary template sources (new in 1.4.0) + Custom cache handling functions (new in 1.4.7) @@ -148,12 +151,13 @@ TECHNICAL NOTE: Any time you change a template, change values in config files or change the content that gets displayed in a - template, you must turn on compile_check (new behavior in 1.4.6), - clear the caches that are affected, or wait for the cache to expire - to see the results of the changes. You can either do this manually - by deleting files from the cache directory, or programatically with - clear_cache or clear_all_cache. + template, you can turn on compile_check to regenerate the caches + that are affected, or wait for the cache to expire to see the + results of the changes. You clear caches manually by deleting files + from the cache directory, programatically with clear_cache or clear_all_cache, or turn on + $compile_check (or $force_compile). TECHNICAL NOTE: As of Smarty 1.4.6, if you have caching enabled AND @@ -163,7 +167,8 @@ since it has to check the templates and config files for modification times. Therefore if you are not actively changing templates or config files, it is advisable to leave compile_check - off. + off. As of Smarty 1.4.7, enabling $force_compile will cause cache + files to always be regenerated. @@ -180,16 +185,16 @@ Installing Smarty - Installing Smarty is fairly straightforward, there is just one thing - you must be aware of. Smarty creates PHP scripts from the templates. - This usually means allowing user "nobody" (or whomever the web server - runs as) to have permission to write the files. Each installation of a - Smarty application minimally needs a templates directory and a compiled - templates directory. If you use configuration files you will also need - a directory for those. By default these are named "templates", and - "templates_c" and "configs" respectively. If you plan on using caching, - you will need to create a "cache" directory, also with permission to - write files. + Installing Smarty is fairly straightforward, there are a few things to + be aware of. Smarty creates PHP scripts from the templates. This + usually means allowing user "nobody" (or whomever the web server runs + as) to have permission to write the files. Each installation of a + Smarty application minimally needs a templates directory and a compiled + templates directory. If you use configuration files you will also need + a directory for those. By default these are named "templates", + "templates_c" and "configs" respectively. If you plan on using caching, + you will need to create a "cache" directory, also with permission to + write files. TECHNICAL NOTE: You can get around the need to allow the web server @@ -220,6 +225,11 @@ directory yourself before hand, and change the file ownership accordingly. See below. + + TECHNICAL NOTE: If you don't want to use include_path to find the + Smarty files, you can set the SMARTY_DIR constant to the full path to + your Smarty library files. Be sure the path ends with a slash! + Example of installing Smarty @@ -392,7 +402,9 @@ require_once(SMARTY_DIR."Smarty.class.php"); $compile_check to "false" to improve performance! Note that if you change this to "false" and a template file is changed, you will *not* see the change since the template will not get - recompiled. See $force_compile or clear_compiled_tpl. @@ -403,19 +415,27 @@ require_once(SMARTY_DIR."Smarty.class.php"); This forces Smarty to (re)compile templates on every invocation. This setting overrides $compile_check. By default this is disabled. This is handy for development and debugging. - It should never be used in a production environment. + It should never be used in a production environment. If caching + is enabled, the cache file(s) will be regenerated every time. $caching - This tells Smarty whether or not to cache the output of the - templates. By default this is set to false. If your templates - generate the same content over and over, it is advisable to - turn on caching. This will result significant performance - gains. You can also have multiple caches for the same template. - See is_cached for details. - This was added to Smarty 1.3.0. + This tells Smarty whether or not to cache the output of the + templates. By default this is set to false. If your templates + generate redundant redundant content over and over again and + again repeatedly, it is advisable to turn on caching. This will + result in significant performance gains. You can also have + multiple caches for the same template. See is_cached for details. This was + added to Smarty 1.3.0. + + + If $compile_check is enabled, the cached content will be + regenerated if any of the involved templates are changed. (new + to 1.4.6). If $force_compile is enabled, the cached content + will always be regenerated (new to 1.4.7). @@ -425,6 +445,8 @@ require_once(SMARTY_DIR."Smarty.class.php"); stored. By default this is "./cache", meaning that it will look for the cache directory in the same directory as the executing php script. This was added to Smarty version 1.3.0. + You can also use your own custom cache handler function to + control cache files, which will ignore this setting. TECHNICAL NOTE: This setting must be either a relative or @@ -455,6 +477,14 @@ require_once(SMARTY_DIR."Smarty.class.php"); search, speeding up cached page fetches. + + $cache_handler_func + + You can supply a custom function to handle cache files instead + of using the built-in method using the $cache_dir. See the + custom cache handler function section for details. + + $tpl_file_ext @@ -470,12 +500,12 @@ require_once(SMARTY_DIR."Smarty.class.php"); $allow_php - Whether or not to allow PHP code in the templates. If set to - false, PHP code is escaped and not interpreted. Embedding PHP - code into templates is highly discouraged. Use custom functions or modifiers instead. Default - is "false". + Whether or not to allow PHP code in the templates. If set to + false, PHP code is escaped and not interpreted. Embedding PHP + code into templates is not recommended. Use custom functions or modifiers instead. Default + is "false". NOTE: $allow_php was removed in 1.3.0, and replaced with @@ -1221,7 +1251,7 @@ var_dump($tpl_vars); This displays the template. Supply a valid template resource + linkend="section.template.resources">template resource type and path. As an optional second parameter, you can pass a cache id. See the caching section for more information. @@ -1508,7 +1538,7 @@ function add_header_comment($tpl_source) { } // register the postfilter -$smarty->register_postfilter("add_header_comments"); +$smarty->register_postfilter("add_header_comment"); $smarty->display("index.tpl"); {* from within Smarty template *} @@ -2441,6 +2471,14 @@ OUTPUT: 0,2,4, etc. If step is negative, it will step through the array backwards. (Added to Smarty 1.4.4.) + + max + integer + No + 1 + Sets the maximum number of times the section + will loop. (Added to Smarty 1.4.4.) + show boolean diff --git a/libs/Config_File.class.php b/libs/Config_File.class.php index af7d4bdf..e752c3a8 100644 --- a/libs/Config_File.class.php +++ b/libs/Config_File.class.php @@ -78,7 +78,7 @@ class Config_File extends PEAR { { $this->PEAR(); - if (substr(PHP_OS, 1, 3) == "WIN") + if (substr(PHP_OS, 1, 3) == "WIN" || substr(PHP_OS, 1, 4) == "OS/2") $this->_separator = "\\"; else $this->_separator = "/"; diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 29b136d3..4899e6bd 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -101,8 +101,10 @@ class Smarty // this will tell Smarty not to look for // insert tags and speed up cached page // fetches. + var $cache_handler_func = ''; // function used for cached content. this is + // an alternative to using the file based $cache_dir. - var $tpl_file_ext = '.tpl'; // template file extention + var $tpl_file_ext = '.tpl'; // template file extention (deprecated) var $php_handling = SMARTY_PHP_PASSTHRU; // how smarty handles php tags in the templates @@ -116,7 +118,6 @@ class Smarty var $security = false; // enable template security (default false) var $secure_dir = array('./templates'); // array of directories considered secure - var $secure_ext = array('.tpl'); // array of file extentions considered secure var $security_settings = array( 'PHP_HANDLING' => false, 'IF_FUNCS' => array('array', 'list', @@ -413,9 +414,13 @@ class Smarty Function: clear_cache() Purpose: clear cached content for the given template and cache id \*======================================================================*/ - function clear_cache($tpl_file = null, $cache_id = null, $compile_id) + function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null) { - return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id); + if(!empty($this->cache_handler_func) { + return $$this->cache_handler_func('clear', $tpl_file, $cache_id, $compile_id); + } else { + return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id); + } } @@ -425,7 +430,11 @@ class Smarty \*======================================================================*/ function clear_all_cache() { - return $this->_rm_auto($this->cache_dir); + if(!empty($this->cache_handler_func) { + return $$this->cache_handler_func('clear'); + } else { + return $this->_rm_auto($this->cache_dir); + } } @@ -438,20 +447,7 @@ class Smarty if (!$this->caching) return false; - $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id); - - if (file_exists($cache_file) && - ($this->cache_lifetime == 0 || - (time() - filemtime($cache_file) <= $this->cache_lifetime))) { - if($this->compile_check) { - return $this->_read_cache_file($cache_file,$results); - } else { - return true; - } - } - else - return false; - + return $this->_read_cache_file($tpl_file,$cache_id,$compile_id,$results); } @@ -524,29 +520,22 @@ class Smarty $this->_cache_info[] = array('template', $tpl_file); - $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id); + if($this->_read_cache_file($tpl_file,$cache_id,$compile_id,$results)) { + if ($this->insert_tag_check) { + $results = $this->_process_cached_inserts($results); + } + if ($display) { + echo $results; + if ($this->debugging) + { + // capture time for debugging info + $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time; - if (file_exists($cache_file) && - ($this->cache_lifetime == 0 || - (time() - filemtime($cache_file) <= $this->cache_lifetime))) { - - if($this->_read_cache_file($cache_file,$results)) { - if ($this->insert_tag_check) { - $results = $this->_process_cached_inserts($results); - } - if ($display) { - echo $results; - if ($this->debugging) - { - // capture time for debugging info - $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time; - - echo $this->_generate_debug_output(); - } - return; - } else { - return $results; + echo $this->_generate_debug_output(); } + return; + } else { + return $results; } } } @@ -607,7 +596,7 @@ class Smarty } if ($this->caching) { - $this->_write_cache_file($cache_file, $results); + $this->_write_cache_file($tpl_file,$cache_id,$compile_id,$results); $results = $this->_process_cached_inserts($results); } @@ -869,7 +858,6 @@ function _generate_debug_output() { $smarty_compiler->compiler_funcs = $this->compiler_funcs; $smarty_compiler->security = $this->security; $smarty_compiler->secure_dir = $this->secure_dir; - $smarty_compiler->secure_ext = $this->secure_ext; $smarty_compiler->security_settings = $this->security_settings; if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled)) @@ -1233,62 +1221,91 @@ function _run_insert_handler($args) /*======================================================================*\ Function: _write_cache_file Purpose: Prepend the cache information to the cache file - and write it to disk + and write it \*======================================================================*/ - function _write_cache_file($cache_file,$results) + function _write_cache_file($tpl_file, $cache_id, $compile_id, $results) { - // put the templates involved with this cache in the first line - $cache_info = 'SMARTY_CACHE_INFO_HEADER'.serialize($this->_cache_info)."\n"; - $this->_write_file($cache_file, $cache_info.$results, true); + // put timestamp in cache header + $this->_cache_info['timestamp'] = time(); - return true; + // prepend the cache header info into cache file + $results = 'SMARTY_CACHE_INFO_HEADER'.serialize($this->_cache_info)."\n".$results; + + if(!empty($this->cache_handler_func)) { + // use cache_write_handler function + return $$this->cache_handler_func('write', $tpl_file, $cache_id, $compile_id, $results, $this); + } else { + // use local cache file + $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id); + $this->_write_file($cache_file, $results, true); + return true; + } } /*======================================================================*\ Function: _read_cache_file - Purpose: See if any of the templates for this cache file - have changed or not since the cache was created. - Remove the cache info from the cache results. + Purpose: read a cache file, determine if it needs to be + regenerated or not \*======================================================================*/ - function _read_cache_file($cache_file,&$results) + function _read_cache_file($tpl_file, $cache_id, $compile_id, &$results) { - if( !($cache_header = $this->_read_file($cache_file,1,1) )) { + if ($this->force_compile || $this->cache_lifetime == 0) { + // force compile enabled or cache lifetime is zero, always regenerate return false; } + if(!empty($this->cache_handler_func)) { + + // use cache_read_handler function + return($$this->cache_handler_func('read',$tpl_file, $cache_id, $compile_id, $results, $this)); + + } else { + // use local file cache + + $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id); + return ($results = $this->_read_file($cache_file)); + + } + + $cache_split = explode("\n",$results,2); + $cache_header = $cache_split[0]; + if (substr($cache_header, 0, 24) == 'SMARTY_CACHE_INFO_HEADER') { + $cache_info = unserialize(substr($cache_header, 24)); + $cache_timestamp = $cache_info['timestamp']; + if (time() - $cache_timestamp > $this->cache_lifetime) { + // cache expired, regenerate + return false; + } + if ($this->compile_check) { - $cache_filemtime = filemtime($cache_file); - foreach ($cache_info as $curr_cache_info) { switch ($curr_cache_info[0]) { case 'template': $this->_fetch_template_info($curr_cache_info[1], $template_source, $template_timestamp, false); - if($cache_filemtime < $template_timestamp) { + if($cache_timestamp < $template_timestamp) { // template file has changed, regenerate cache return false; } break; case 'config': - if ($cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) { + if ($cache_timestamp < filemtime($this->config_dir.'/'.$curr_cache_info[1])) { // config file file has changed, regenerate cache return false; } break; } } - } - $results = $this->_read_file($cache_file,2); + $results = $cache_split[1]; + return true; } else { - // no cache info header, pre Smarty 1.4.6 format - $results = $this->_read_file($cache_file); + // no cache info header, pre Smarty 1.4.6 format. regenerate + return false; } - - return true; } diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index c6cc0c6a..00dc05d2 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -374,7 +374,7 @@ class Smarty_Compiler extends Smarty { $attrs['section'] = 'null'; } - @$scope = $this->_dequote($attrs['scope']); + $scope = @$this->_dequote($attrs['scope']); if (!empty($scope)) { if ($scope != 'local' && $scope != 'parent' &&