Issues

ZF-11885: Zend_Controller_Action_Helper_Cache does not encode cache key on remove

Issue Type: Bug Created: 2011-11-11T16:20:16.000+0000 Last Updated: 2012-07-04T10:47:28.000+0000 Status: Resolved Fix version(s): - 1.12.0 (27/Aug/12)

Reporter: Ashley White (thinkle) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Cache

  • FixForZF1.12
  • cache
  • state:need-feedback
  • zf-caretaker-adamlundrigan
  • zf-crteam-review

Related issues: Attachments: - ZF-11885.patch

Description

As the start method does, the removePage function should wrap $relativeUrl with _encodeCacheId - it seems bad practice to automatically do it on save but not on remove.

Replace line 142 with:

return $cache->remove($this->_encodeCacheId($relativeUrl));

Comments

Posted by Adam Lundrigan (adamlundrigan) on 2012-05-04T19:11:26.000+0000

Attached a patch which provides a reproducing test case and fix

Posted by Adam Lundrigan (adamlundrigan) on 2012-05-12T12:31:57.000+0000

My initial fix breaks backwards-compatibility for those who have implemented a workaround whereby they pre-encoded the relative URL before passing it on to the remove method. I've updated my fix to tirst try removing by an encoded $relativeUrl, and if that fails it removes by raw $relativeUrl. Example

<pre class="highlight">
$result = $cache->remove($this->_encodeCacheId($relativeUrl));
if (is_null($result) ) {
    $result = $cache->remove($relativeUrl);
}
return $result;

I've added an additional test case to enforce the change, and all unit tests in Controller suite still pass after patch is applied.

I've not had much experience using this cache action helper. Are there any potential side-effects of doing this two-step remove that I am not taking into account?

Posted by Adam Lundrigan (adamlundrigan) on 2012-05-31T23:19:59.000+0000

Fixed in trunk r24853

Posted by Gregory Art (artisson) on 2012-07-04T10:47:27.000+0000

Doesn't this solution introduce another problem ?

With the Page cache, and the Static Backend , the name of the stored file is not encoded and the file is never removed.

If we call $cache->remove($relativeUrl); without encoding , the Zend_Cache_Core method return the "Invalid id or tag '$string' : must use only [a-zA-Z0-9_]" execption.

Calling directly the backend method (Static_Cache) Seems to solve the problem.

But i don't know if it's appropriate.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts