Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Zend_Cache_Backend_TwoLevels fast backend lifetime always set to infinite on cache save #503

Open
mcnathanator opened this issue Jan 27, 2015 · 1 comment

Comments

@mcnathanator
Copy link

Version: 1.12.10dev
Class: Zend_Cache_Backend_TwoLevels
Method: _getFastLifetime()
Line: 504

In Zend_Cache_Backend_TwoLevels on calling save() _getFastLifetime() is called without the 3th parameter $maxLifetime. $maxLifetime will default to null. Resulting in infinite lifetime no matter what $lifetime or $priority is given.
The reason; at line 504 "$maxLifetime >= 0" will be "null >= 0" and that will return true (in my php version atleast) therefor "return $maxLifetime;" will return the lifetime of null.

Isolated the code looks like this:

 $lifetime = 3600;
 $priority = 8;
 $fastLifetime = $this->_getFastLifetime($lifetime, $priority);
 echo $fastLifetime;

What I would expect is 1200. What I get is null.

MarcoMiltenburg added a commit to MarcoMiltenburg/zf1 that referenced this issue Aug 1, 2016
…will never be used and null will always be returned.

Fixes issue zendframework#503.
@MarcoMiltenburg
Copy link

Confirmed, I just found this bug as well. The fix is easy though by changing >= to > as $maxLifetime only makes sense when it's greater than zero. Just opened a pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants