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
The documentation of the parameter $cid
in DrupalCacheInterface::clear()
is not sufficient enough. This leads to issues like this one: #1871006: Flaw in the implementation of DrupalCacheInterface ::clear() - missing cid array handling
Proposed resolution
Enhance documentation about what data types are accepted.
Remaining tasks
reviews needed - enhancements welcome :)
User interface changes
none
API changes
none
Comments
Comment #1
jhodgdonThanks for reporting and patching!
I would like to offer a couple of suggestions:
a) I think the documentation could be reworded a bit better. It starts out implying it has to be a string, and then in the new sentence says "Oh, it can actually also be an array".
b) I think the documentation should mention in $cid that it must be a string if $wildcard is true (arrays will not work in that case).
c) Maybe it should also mention in $wildcard that if $cid is empty, $wildcard is ignored.
And as a note, I guess this is D7 only... not sure what/where the corresponding classes are in D8?
Comment #2
freblasty CreditAttribution: freblasty commentedCreated new patch based upon the suggestions made by jhodgdon. This patch only applies to D7 because of the new cache API in D8 (#81461: Clean up the cache API (stop overloading function arguments, remove procedural wrappers)).
Comment #3
jhodgdonBetter, thanks!
However... Since cache_clear_all() is calling the clear() method, passing in $cid and $wildcard, the documentation for $cid and $wildcard should, I think, be the same for both functions. Right? It looks like $cid matches, but not $wildcard. Let's pick one... I think the one in cache_clear_all() is clearer.
Also, the behavior of cache_clear_all() when both $bin and $cid are NULL should be documented, which it isn't at all at the moment.
Comment #4
freblasty CreditAttribution: freblasty commented@jhodgdon: It seems that the behavior with the arguments
$cid
and$bin
is already documented but a little vague:What about the following text:
Comment #5
freblasty CreditAttribution: freblasty commentedComment #6
jhodgdon#4 sounds fine; may need a comma or two. :)
And restoring correct status.
Comment #7
freblasty CreditAttribution: freblasty commentedPatch which contains changes from #2 and #4.
Comment #8
jhodgdonLooks good to me, thanks!
Comment #9
jhodgdonThanks again! Committed to 7.x.
Comment #10
das-peter CreditAttribution: das-peter commented@freblasty, @jhodgdon Awesome, thank you very much!