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.
I got a PHP error calling varnish_expire_cache() from my hook_nodeapi function because varnish_expire_cache() ends with a break, instead of a return. I have attached a patch with the fix.
Here is the function from which I was calling it. I think I am doing this correctly. At least, my testing so far has indicated that URL's are being cleared out of the cache:
function um_common_nodeapi(&$node, $op, $a3, $a4) {
switch ($op) {
case 'alter':
// snip irrelevant code
break;
case 'insert':
case 'update':
if (module_exists('varnish')) {
$urls = varnish_get_active_urls($node);
varnish_expire_cache($urls);
}
break;
}
}
Comment | File | Size | Author |
---|---|---|---|
#1 | fix-varnish-expire-cache.patch | 519 bytes | EvanDonovan |
Comments
Comment #1
EvanDonovan CreditAttribution: EvanDonovan commentedSorry, forgot to attach the patch.
Comment #2
EvanDonovan CreditAttribution: EvanDonovan commentedI noticed that the varnish_get_active_urls() function has been removed in preparation for people to use the experimental Expire.module. So I've created my own, minimalist version of it in my custom module.
I will probably be testing the Expire.module at some point soon, but will have to see how it fits in with the other priorities at my organization. Anyway, at least this seems to meet my basic needs, now that I've fixed the error in the varnish_expire_cache() function.
Comment #3
carlos8f CreditAttribution: carlos8f commentedI came across the same bug. I don't think hook_expire_caches() needs to return anything though, so the break; just needs to be removed.
Comment #4
EvanDonovan CreditAttribution: EvanDonovan commentedYou're right, I think :)
Comment #5
joshk CreditAttribution: joshk commentedFixed in cvs.