Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

SmartyB5 clear_cache not working (on Windows)

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
ndorphin
Smarty Rookie


Joined: 24 Dec 2009
Posts: 15
Location: Berlin, Germany

PostPosted: Thu Dec 24, 2009 8:30 pm    Post subject: SmartyB5 clear_cache not working (on Windows) Reply with quote

Hello,

I've found a bug(?) using smarty clear_cache function on my windows installation (could not test linux behavoir at the moment):

Version is Smarty Beta 5
Code:
* SVN:         $Id: Smarty.class.php 3351 2009-11-18 17:25:18Z Uwe.Tews $


Whats not working for me is line 130 in "smarty_internal_cacheresource_file.php":

Code:
(isset($resource_name) && (string)$_file == $_dir . $_resource_part)) {


What's happen?

I use cache groups and my group name in that case is 'tl_1916'. I want to delete the cache using clear_cache('index.tpl', 'tl_1916').

So the cache file in files system is correctly called:
{myPath}/tl_1916^1172603085.index.tpl.php

(string)$_file in line 130 returns:
{myPath}\\tl_1916^1172603085.index.tpl.php
whats wrong: \\ should not appear in the string, only one / is right

$_dir . $_resource_part from the compare in line 130 returns:
{myPath}/1172603085.index.tpl.php
whats wrong: Were is my cache group id? It's definitly set as paramter?

So you see that {myPath}\\tl_1916^1172603085.index.tpl.php != {myPath}/1172603085.index.tpl.php => cache will not be deleted

My workaround:

1. (String)$file replaces by $_file->getPath() . '/' . $_file->getFilename()
so that it return the correct file path without double \\: {myPath}/tl_1916^1172603085.index.tpl.php

2. $_dir . $_resource_part replaces by $_dir . $_cache_id . '^' . $_resource_part

This workaround return true in compare and the cache file will be deleted.

Any ideas what's wrong?

Happy Christmas!
Greets ndorphin!
Code:
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Dec 24, 2009 9:41 pm    Post subject: Reply with quote

The clear_cache has been already rewritten. It will be part of a major update in a few days.
Back to top
View user's profile Send private message
ndorphin
Smarty Rookie


Joined: 24 Dec 2009
Posts: 15
Location: Berlin, Germany

PostPosted: Fri Dec 25, 2009 12:38 am    Post subject: Reply with quote

Ok, thanks. Hope that in the new version there will be no iteration through the filesystem (could be slow on virtual servers) for comparing all files with the cache filename to to delete. Maybe the file can be deleted directly on the base on the calculated cache file name... Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP