#81461: Clean up the cache API (stop overloading function arguments, remove procedural wrappers) introduced a lovely new cache API.
this issue will track converting core to use it. as a general rule, simple conversions live here, but anything more complicated should be tracked in another issue.
Once the conversion is done, it should be possible to commit #1272706: Remove backwards compatibility layer for cache API.
Here's a list of places to make patches against. Note that modules may contain multiple files:
includes/form.inc -- Testing
includes/menu.inc -- partial conversion
modules/block/ -- Errors
modules/poll/ -- Errors
modules/update/
modules/locale/
modules/image/
modules/field/
modules/statistics/
modules/system/
modules/menu/
modules/book/
Comment | File | Size | Author |
---|---|---|---|
#64 | cache_conversion-1272686-64.patch | 47.11 KB | Anonymous (not verified) |
#63 | cache_conversion-1272686-63.patch | 47.01 KB | Paul Simard |
#58 | cache_conversion-1272686-57.patch | 46.77 KB | bfroehle |
#56 | cache_conversion-54-remaining.txt | 3.78 KB | bfroehle |
#54 | 172686-New-Cache-API-54.patch | 23.8 KB | Paul Simard |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedadding novice task tag.
Comment #2
catchThose two first patches are good to go. Thanks beejeebus!
Comment #2.0
catchUpdated issue summary.
Comment #2.1
catchUpdated issue summary.
Comment #3
Paul Simard CreditAttribution: Paul Simard commentedaggregator module patch -- 1st contribution.
Comment #3.0
Paul Simard CreditAttribution: Paul Simard commentedUpdated issue summary.
Comment #4
Paul Simard CreditAttribution: Paul Simard commentedpoll module patch
Possible error: duplicate of previous patch included, as well. oops!
Comment #6
Paul Simard CreditAttribution: Paul Simard commentedpoll module patch
Comment #8
catchCall to cache_clear_all() with no arguments need to stay the same for now, this is why poll is failing. That was bad grepping on my part, sorry!
Comment #9
Paul Simard CreditAttribution: Paul Simard commentedPatches to following include files:
menu.inc
form.inc
gettext.inc
module.inc
Comment #9.0
Paul Simard CreditAttribution: Paul Simard commentedUpdated issue summary.
Comment #10
Paul Simard CreditAttribution: Paul Simard commentedAssumed assignment
Comment #12
catchThe conversions are reversed.
This should be:
Comment #13
catchThis is nearly there, could be:
Comment #14
Paul Simard CreditAttribution: Paul Simard commentedFixes in [#12] & [#13] emplaced, I hope.
Comment #16
Paul Simard CreditAttribution: Paul Simard commented#14: menu-form-gettext-module-inc.cache-1272686-9.patch queued for re-testing.
Comment #17
bfroehle CreditAttribution: bfroehle commentedAs catch pointed out in #12, your argument ordering is incorrect.
Here is a rough conversion guide:
cache_get('foo', 'cache');
cache()->get('foo');
cache_get('foo', 'cache_bar');
cache('bar')->get('foo');
cache_set('foo', $data);
cache()->set('foo', $data);
cache_set('foo', $data, 'cache_bar');
cache('bar')->set('foo', $data);
cache_clear_all('foo', 'cache');
cache()->delete('foo');
cache_clear_all('foo', 'cache', TRUE);
cache()->deletePrefix('foo');
cache_clear_all('foo', 'cache_bar');
cache('bar')->delete('foo');
cache_clear_all('foo', 'cache_bar', TRUE);
cache('bar')->deletePrefix('foo');
cache('bar')->deleteMultiple(array('foo', 'baz'));
Comment #18
Paul Simard CreditAttribution: Paul Simard commentedmodule.inc stand-alone patch file.
I'm splitting the combined file submitted in #9 into individual patch files, 1 per file.
Comment #19
Paul Simard CreditAttribution: Paul Simard commentedThanks for the assist. Spent some time this afternoon reviewing the changes in includes/cache.inc and concluded the same.
Comment #20
Paul Simard CreditAttribution: Paul Simard commentedgettext.inc stand-alone cache patch.
Comment #21
Paul Simard CreditAttribution: Paul Simard commentedmenu.inc patch. Partial conversion completed.
Still need to convert cache_clear_all() occurrances where immediately followed by drupal_register_shutdown_function('cache_clear_all'...)
Comment #21.0
Paul Simard CreditAttribution: Paul Simard commentedUpdated issue summary.
Comment #22
Paul Simard CreditAttribution: Paul Simard commentedform.inc stand-alone cache patch.
Comment #23
Anonymous (not verified) CreditAttribution: Anonymous commentedi see instances of this:
they need to be this instead:
Comment #23.0
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdated issue summary.
Comment #24
Paul Simard CreditAttribution: Paul Simard commentedrevised module.inc stand-alone cache patch.
Includes correction from beejeebus in previous comment.
Comment #24.0
Paul Simard CreditAttribution: Paul Simard commentedUpdated issue summary.
Comment #25
Paul Simard CreditAttribution: Paul Simard commentedpath.inc stand-alone cache patch.
Comment #25.0
Paul Simard CreditAttribution: Paul Simard commentedUpdated issue summary.
Comment #26
Paul Simard CreditAttribution: Paul Simard commentedregistry.inc stand-alone cache patch
Comment #26.0
Paul Simard CreditAttribution: Paul Simard commentedUpdated issue summary.
Comment #26.1
Paul Simard CreditAttribution: Paul Simard commentedUpdated issue summary.
Comment #26.2
Paul Simard CreditAttribution: Paul Simard commentedUpdated issue summary.
Comment #27
Paul Simard CreditAttribution: Paul Simard commentedmodule/block cache patch
Comment #28
Paul Simard CreditAttribution: Paul Simard commentedpatches submitted.
Comment #29
Paul Simard CreditAttribution: Paul Simard commentedmodules/comment cache patch.
Comment #30
Anonymous (not verified) CreditAttribution: Anonymous commented#26 has this:
which is not valid php...
Comment #31
Paul Simard CreditAttribution: Paul Simard commentedGag. Must've been that spot on my glasses. Will fix.
Comment #32
Paul Simard CreditAttribution: Paul Simard commentedrevised module-block cache patch.
Comment #32.0
Paul Simard CreditAttribution: Paul Simard commentedUpdated issue summary.
Comment #33
Paul Simard CreditAttribution: Paul Simard commentedcache patches for:
module forum
module node
module simpletest
module path
Comment #34
Paul Simard CreditAttribution: Paul Simard commentedcache patches for:
module poll
module user
module filter
module taxonomy
Comment #35
Paul Simard CreditAttribution: Paul Simard commentedrevised module simpletest cache patch
Comment #35.0
Paul Simard CreditAttribution: Paul Simard commentedUpdated issue summary.
Comment #36
Paul Simard CreditAttribution: Paul Simard commentedEnd of day progress for 9/8-9/9
Summary:
Successful patches: 15 (testing passed)
Failed patches: 2
module poll 3 failures
module block 4 failures
Will be back to finish up remaining modules this weekend.
Note:
Files excluded from conversions generally ended in .css, .info, .js extensions.
Files specifically checked for conversions generally ended in .inc, .php, .install, .module extensions.
Comment #37
bfroehle CreditAttribution: bfroehle commentedAlso a bunch of the patches incorrectly use
cache()->deletePrefix(...)
instead ofcache()->delete(...)
. ThedeletePrefix
method should be used only when the previous call was of the formcache_clear_all(..., ..., TRUE)
(note the TRUE in the 3rd position).Comment #38
Paul Simard CreditAttribution: Paul Simard commentedOk. Will follow-up and re-craft. That brings up a question:
Rough conversion guide for cache_clear_all():
cache_clear_all('foo', 'cache');
cache_clear_all('foo', 'cache', TRUE);
cache_clear_all('foo', 'cache_bar');
cache_clear_all('foo', 'cache_bar', TRUE);
cache_clear_all('foo', 'cache_bar');
cache_clear_all('baz', 'cache_bar');
When in the form
cache_clear_all('*', cache_bar, TRUE); or cache_clear_all('*', cache, TRUE);
is the solution
or
or
If more than one of those is correct, depending on the context of the code, could you clarify which case calls for which solution?
Thanks
Paul
Comment #39
Anonymous (not verified) CreditAttribution: Anonymous commentedre #38, when $cid == '*', and $wildcard == TRUE:
convert to this:
Comment #40
Paul Simard CreditAttribution: Paul Simard commentedGot it. Thanks.
Comment #41
Paul Simard CreditAttribution: Paul Simard commentedpath.inc revised cache patch
Comment #42
Paul Simard CreditAttribution: Paul Simard commentedComment #43
Paul Simard CreditAttribution: Paul Simard commentedComment #44
Paul Simard CreditAttribution: Paul Simard commentedmodule menu cache patch
Comment #45
Paul Simard CreditAttribution: Paul Simard commentedmodule system cache patch
Comment #46
Paul Simard CreditAttribution: Paul Simard commentedmodule field cache patch for testing
Comment #47
Paul Simard CreditAttribution: Paul Simard commentedmodule image cache patch
Comment #49
Paul Simard CreditAttribution: Paul Simard commentedrepaired field module cache patch
Comment #50
Paul Simard CreditAttribution: Paul Simard commentedComment #51
Paul Simard CreditAttribution: Paul Simard commentedrevised image module cache patch
Comment #52
Paul Simard CreditAttribution: Paul Simard commentedpatch roll-up & testing (cache patches)
Comment #53
catchThis is looking good, spotted a few cases where deletePrefix() should be delete() or vice versa, but otherwise very close.
These two can just be straight cache('form')->delete(....). No need for prefix since there was no TRUE argument to cache_clear_all().
This one however does need to be ->deletePrefix()
This can just be ->delete()
18 days to next Drupal core point release.
Comment #54
Paul Simard CreditAttribution: Paul Simard commentedFinal roll-up patch I think.
Comment #55
bfroehle CreditAttribution: bfroehle commentedI manually reviewed the patch in #54 and did not notice any errors in the conversion.
Are we going for one big patch here or multiple little ones? In particular, there appear to still be many unchanged occurrences of cache_get, cache_set, and cache_clear_all.
Comment #56
bfroehle CreditAttribution: bfroehle commentedI have attached a list of occurrences of cache_get, cache_set, and cache_clear_all after applying the patch in #54 to a clean 8.x checkout:
Comment #57
Paul Simard CreditAttribution: Paul Simard commentedI'll have to check with catch on that. Maybe he'll see this and give a holler. Will work on these in a couple of hours.
As far as the patch is concerned. I started with lots of little ones, and was told to roll them all up. So I did.
Thanks for the feedback.
Comment #58
bfroehle CreditAttribution: bfroehle commentedI went ahead and fixed up some (but not all) of the remaining occurrences of the old API. For easier review, the attached patch has two big chunks, the first of which is #54 and the second which is new.
Still to be fixed:
I'm not sure what the conversion process is for $bin as a variable ... i.e. will passing $bin = 'cache_page' always still work or do we need to change the prior code to make sure that $bin is (eventually) just 'page'?
Comment #59
Paul Simard CreditAttribution: Paul Simard commentedComment #60
Paul Simard CreditAttribution: Paul Simard commentedOk, you combined your changes into my patch. Which is fine. The only hitch is I'm still new at this and paranoid about screwing things up. The new patch is double in size from the one I've been working.
As I see it, I should:
Is that right? BTW, I'm on IRC in #drupal-contribute if you need to contact directly. Query is fine.
Paul
Comment #61
Paul Simard CreditAttribution: Paul Simard commentedAlso, from your last comment...
From ./includes/common.inc: cache_clear_all('*', $table, TRUE);
works for now.
The new code should execute like this:
in succession using the new API. As Drupal does not require a cache to exist, this may result in added cache rebuilds, but the function is drupal_flush_all_caches().
It does pose an additional question, which is the module_invoke_all('flush_caches') call. As I read it, this adds to the array $cache_tables the function 'flush_caches' points to where it exists in the list of modules contained in $core.
Overall, I think it's safe here to use the cache($table)->flush().
Comment #62
Paul Simard CreditAttribution: Paul Simard commentedRegarding...
$bin will resolve to either 'cache', or the value contained in $elements['#cache']['bin'] which is passed to the function as shown below:
The question is whether the argument passed to $elements will always be good within the function. If $elements['#cache']['bin'] doesn't have a value, the value resolves to 'cache', which is all good. The issue is that $elements['#cache']['bin'] always needs to contain a valid cache bin if the value is present. Sounds like something to be tested for...
This also applies to:
./includes/common.inc: cache_set($cid, $data, $bin, $expire);
where
These seem to indicate that the same bin resolution applies, and items affected will persist unless $elements['#cache']['expire'] resolves to something else meaningful. Another thing to be tested, perhaps.
and for
at least as far as resolving $bin is concerned.
I don't know simpletest enough to determine whether these are already being tested for or not, nor do I feel confident enough at this moment to write such a test if it can be written, but that's another issue.
Comment #63
Paul Simard CreditAttribution: Paul Simard commentedAnother roll-up.
It's almost done, whomever reviews, search for lines containing: "Proposed replacement:".
They are comments within the code, and there are only a few.
Any added feedback on whether I can make the replacements, please let me know. There are a couple of comments above #61 & #62 that outline my thoughts on the matter.
Comment #64
Anonymous (not verified) CreditAttribution: Anonymous commentedgreat work!
i've uploaded a new patch that resolves your suggestions.
they were all right except for the one in system cron, which should resolve to a cache->expire().
Comment #65
Paul Simard CreditAttribution: Paul Simard commentedThanks. That's a few hours of work that's ready for the grinder of full review I think.
To beejeebus, chx, crell, and bfroehle ...
Thanks loads for your help and support.
Comment #66
catchThis is ready to go. Thanks folks!
Comment #67
Dries CreditAttribution: Dries commentedThis looks good. Thanks for all the work and the mentoring. Great to see. Committed to 8.x.
Comment #68
bfroehle CreditAttribution: bfroehle commentedContinuing the conversation in #1275808: Use new cache bin naming in hook_flush_cache.
Comment #69.0
(not verified) CreditAttribution: commentedUpdated issue summary.