|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
tiger42 Smarty n00b
Joined: 14 Dec 2015 Posts: 4
|
Posted: Mon Dec 14, 2015 4:51 pm Post subject: isCached function gives wrong result |
|
|
Hello,
after updating Smarty to version 3.1.28 I have noticed that some of the unit tests of my application were failing. After some investigation I found out that the Smarty function "isCached" gives the wrong return value (or at least a different result than in the previous Smarty version...).
Here is a simplified section of code that demonstrates the issue:
Code: |
require_once 'smarty/libs/Smarty.class.php';
$smarty = new \Smarty();
$smarty->setTemplateDir('.');
$smarty->setCompileDir('test/');
$smarty->setCacheDir('test/');
$smarty->setCaching(\Smarty::CACHING_LIFETIME_CURRENT);
$tpl = $smarty->fetch('test.tpl');
var_dump($smarty->isCached('test.tpl')); // true
$smarty->clearAllCache();
var_dump($smarty->isCached('test.tpl')); // true -> should be false!
|
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Dec 14, 2015 5:02 pm Post subject: |
|
|
The Smarty::isCached() result is likely cached.
That said, your test do not show wrong results per se.
Rendering a template, clearing cache, and rendering template again is and unexpected turn of events.
Also, take a look at CACHING_LIFETIME_SAVED. It gives a better caching control. |
|
Back to top |
|
tiger42 Smarty n00b
Joined: 14 Dec 2015 Posts: 4
|
Posted: Mon Dec 14, 2015 7:35 pm Post subject: |
|
|
Maybe my code example is not really relevant in real world applications (although I am sure one could find a more relevant example...), but that is not the point. The point is: The isCached() function returns an unexpected result in some cases, which is not documented anywhere and breaks compatibility with older versions of Smarty. So I still think that this is a bug that should be fixed. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Dec 15, 2015 2:35 am Post subject: |
|
|
This is fixed now on github in the master branch |
|
Back to top |
|
tiger42 Smarty n00b
Joined: 14 Dec 2015 Posts: 4
|
Posted: Tue Dec 15, 2015 7:50 am Post subject: |
|
|
Thank you very much! |
|
Back to top |
|
|
|
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
|