Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When try to cache_clear_all with $cid, but no $bin, no effect. The reason is the cache key is generated by $bin . '-' . $cid (e.g cache-foo) and since there is no bin details, the key become something like '-foo'. This details is in the docblock, of cache_clear_all, but code doesn't enforce it.
/**
* Expires data from the cache.
...
...
* @param $bin
* If set, the cache bin to delete from. Mandatory argument if $cid is set.
...
...
*/
function cache_clear_all($cid = NULL, $bin = NULL, $wildcard = FALSE) {
Proposed resolution
Solution 1. Provide default option to bin, if $cid is set.
Solution 2. If solution 1 is too much assumption, throw an exception for the calls with $cid and no $bin.
Remaining tasks
1. Discuss
2. Issue path
User interface changes
N/A
API changes
Depends on solution.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2189537-cache-no-bin-2.patch | 516 bytes | vijaycs85 |
Comments
Comment #1
vijaycs85Comment #2
vijaycs85Comment #3
vijaycs85Comment #4
vijaycs85Comment #5
danblack CreditAttribution: danblack commentedlooks good!
Comment #6
David_Rothstein CreditAttribution: David_Rothstein commentedSeems reasonable, since the current behavior is an unhelpful-looking PDOException anyway.
However, "\Exception" (with the forward-slash namespace thing) won't work on PHP 5.2, right?
And the exception message should really be a complete sentence.