I had a need for Views content caches to be able to be invalidated when nodequeues that views are built on are altered. Nodequeue provides a couple hooks when items are added/removed/reordered in a nodequeue.
I've attached a patch that adds a plugin to add nodequeues as content cache settings.
I'm not totally clear on the 'clause_mode' of 'AND' or 'OR' but I think that in my case I would require 'OR' as 'AND' would mean that both a nodequeue add/remove/reorder AND a nodeapi action would have to happen if I had say node type 'foo' checked in the nodes section of the config along with a nodequeue queue.
Let me know if what I have looks sane. For nodequeue reordering support you need to have Nodequeue release 6.x-2.10 or later or current 6.x-2-dev.
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | views_content_cache-nodequeue_plugin-1185268-29.patch | 3.56 KB | pcambra |
| #27 | interdiff-22-27.txt | 722 bytes | renrhaf |
| #27 | views_content_cache-nodequeue_plugin-1185268-27.patch | 3.88 KB | renrhaf |
| #22 | interdiff-1185268-18-22.txt | 1.44 KB | rpsu |
| #22 | views_content_cache-nodequeue_plugin-1185268-22.patch | 3.99 KB | rpsu |
Comments
Comment #1
jaydub commentedbumping in the hopes that I can get someone to take a look at the patch...
Comment #2
agileadamHello,
I've tried your patch. While all of the syntax checks out just fine, nothing is happening on the frontend when I add items to, remove items from, or re-order a nodequeue. All of my views Content Cache settings are set to "none" for min/max lifetime. I've tested every way I can think of.
views_content_cache_update_set($subqueue, 'nodequeue'); is executing and returning a 1, but my output on the frontend never changes.
Comment #3
agileadamAs a followup, I discovered a problem... the parameters for hook_nodequeue_sort_alter() have been reversed in 6.x-2.11. So, for use with nodequeue 2.11:
views_content_cache_nodequeue_sort_alter($sqid, $nodes)becomes
views_content_cache_nodequeue_sort_alter($nodes, $sqid)See http://drupal.org/node/1212876#comment-4709402
I'm going to continue testing to see what else might be keeping this from working for me.
Comment #4
jaydub commentedOf course the parameter order was reversed :) just my luck. 6.2.11 only came out a few days ago so I haven't had a chance to take a look.
Obviously to support people using new and old versions of nodequeue my patch will have to support either parameter order I would think since it's unrealistic to expect users to be able to upgrade nodequeue and we can't set a module dependency on a specfic module version that I'm aware of.
Did you apply the patch to 6.2.11 only in testing? I haven't had a chance to test my patch against any recent changes to nodequeue so I'll have to make sure your problem isn't solely due to underlying changes in nodequeue.
Comment #5
agileadamHey again,
Unfortunately I never got your code to work 100%. I discovered the parameter swap during my investigation, but didn't devote too much time to figuring out why else it may not be working for me.
If I find some time I'll dig back into it again.
Cheers!
Comment #6
gstout commentedHey all, with the fix,
views_content_cache_nodequeue_sort_alter($sqid, $nodes)
becomes
views_content_cache_nodequeue_sort_alter($nodes, $sqid)
and nodequeue 2.11 this works like a charm. Thank you so much for putting this together and sharing it!
We are now using it on the main top story display at globalpost.com and it's allowing our cache to be significantly more responsive.
Thank You!!
Comment #7
jaydub commentedOk I updated the patch to include logic to try and determine if the Nodequeue sort_alter call is pre 6.2.11 or after. Works locally on both old and new versions of Nodequeue.
Comment #8
agileadamPatch from #7 applied cleanly to Dev branch... sorry, I mis-tagged this comment.
Comment #9
soulfroys+1 for this! It worked here!
Thank you all!
Comment #10
steven jones commentedPatch looks good, but need to get tests passing before I can merge in.
Comment #11
steven jones commentedThanks so much, merged in 6.x-2.x
Comment #13
steven jones commentedComment #14
jaydub commentedGot some time and came back around to update my old patch. Attached patch adds nodequeue support to current Drupal 7 views content cache module.
Comment #15
bessone commentedtried with views_content_cache 7.x-3.0-alpha2, i get any error but the cache is not flushed.
EDIT: Ops, my fault, I had not seen the option in the View Configuration. Great patch!
Comment #16
mstef commentedGetting this warning:
Seems to be working though -- thanks.
Comment #17
colanComment #18
azinck commentedJust needed a slight tweak to fix the error in #16
Comment #19
joachim commentedPatch in #18 works great for me. Thanks!
Comment #20
joachim commentedAh on second thoughts, this has issues with exportability:
That's the diff for my feature. The setting in the view handler should really be using the nodequeue machine name, rather than the local-only nodequeue ID.
Comment #21
zanixThe patch needs a small change to work with Nodequeue 7.x-3.x-dev
To
Comment #22
rpsuThis patch is close to the same as #18, but instead of using internal id it is using nodequeue name as a key to enable exports using nodequeue name instead of internal id.
OR-clause is removed since it broke db-query if nodequeue updates were the only cache invalidation criteria.
Comment #23
jaydub commentedFor the OR clause issue, suggest checking out #2407467: views_content_cache_update_get() builds incorrect query possible patch to help with that. Which if it helps, the OR should be added back to the patch.
Comment #24
damienmckennaSeeing as it was added to the D6 branch, it should be added to the D7 branch too.
Comment #25
renrhaf+1
Comment #26
renrhaf@jaydub, @rpsu:
Thanks for your patches, it seems the OR clause if necessary though.
Using the patch you gave in https://www.drupal.org/node/2407467#comment-11535899 fixes the issue properly.
Comment #27
renrhafComment #28
pcambraBear in mind that patches #26 and #27 include the change from #2407467: views_content_cache_update_get() builds incorrect query, those to want to apply the patches separately need to use the one in #22
Comment #29
pcambraAdding a patch that includes #22 and the clause_mode method to make sure combining diverse criteria to clear cache works but doesn't include #2407467: views_content_cache_update_get() builds incorrect query that needs to be applied independently.
Setting as RTBC
Comment #30
berenddeboer commentedWorks perfectly, please add this patch.
Comment #31
nironan commentedWorks like a charm, thanks!
Comment #32
jonhattan#22 and #2407467: views_content_cache_update_get() builds incorrect query saved my day