Re: [SMARTY-DEV] Making Smarty's cache HTTP header aware

From: Date: Thu, 08 Nov 2007 13:42:14 +0000
Subject: Re: [SMARTY-DEV] Making Smarty's cache HTTP header aware
References: 1 2  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-3059@lists.php.net to get a copy of this message
Ah yes, here's the text of the patch. This is just an added bonus feature for people using PHP5. If applied, Smarty will still work as before with earlier PHP versions. Luke Index: internals/core.write_cache_file.php =================================================================== --- internals/core.write_cache_file.php +++ internals/core.write_cache_file.php @@ -60,6 +60,9 @@ $params['results'] = implode('', $results); } $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials; + if (version_compare('5', phpversion(), "<") && function_exists('headers_list')) { + $smarty->_cache_info['headers'] = headers_list(); + } // prepend the cache header info into cache file $_cache_info = serialize($smarty->_cache_info); Index: Smarty.class.php =================================================================== --- Smarty.class.php +++ Smarty.class.php @@ -1212,10 +1212,18 @@ header('HTTP/1.1 304 Not Modified'); } else { + if (isset($this->_cache_info['headers'])) { + foreach ($this->_cache_info['headers'] as $h) + header($h); + } header('Last-Modified: '.$_gmt_mtime); echo $_smarty_results; } } else { + if (isset($this->_cache_info['headers'])) { + foreach ($this->_cache_info['headers'] as $h) + header($h); + } echo $_smarty_results; } error_reporting($_smarty_old_error_level) On Nov 8, 2007 2:52 AM, Hielke Hoeve <hielke.hoeve@gmail.com> wrote: > On 07/11/2007, Luke Baker <lukebaker@gmail.com> wrote: > > Attached is the changes I made against Smarty 2.6.18. I'd appreciate > > consideration for adding these changes to the Smarty core. > > There is no attachment, sorry. > > Hielke > > -- > Smarty Development Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.smarty.dev (#3059) next »