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

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

Attached a patch which provides a reproducing test case and fix

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


$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?

Fixed in trunk r24853

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.