I've been trying to get purge working for a site at work, but while I had no problems getting purge+expire to work on a VM, I was unable to replicate this success on production. What I've come to discover is that purge requests are never sent on production, and here is the reason why:
https://bugs.php.net/bug.php?id=63411
According to this bug, the functionality of curl_multi_select() and curl_multi_exec() has changed for PHP versions 5.3.18 and above. It was also confirmed as an issue in 5.4.8, which was released at the same time.
The code here immediate returns, which is not what is expected previous to PHP 5.3.18: (@ purge.inc)
do {
$multi_result = curl_multi_exec($curl_purges, $active);
} while ($multi_result == CURLM_CALL_MULTI_PERFORM);
// Block until there is activity on any of the handlers. Avoids
// busywaiting.
if ($multi_result == CURLM_OK) {
$select_result = curl_multi_select($curl_purges);
}
Because of this, the purge_urls() function is returned an empty array, and no purge requests are actually sent out.
I've been working on trying to develop a patch, but so far, my challenge has been making a safe place to do so.
Comment | File | Size | Author |
---|---|---|---|
#26 | 1892028-26-fix-curl-multi-select-bug.patch | 1.05 KB | PieterDC |
#20 | 1892028-20-fix-curl-multi-select-bug.patch | 969 bytes | hanoii |
#19 | purge-curl-multi-select-1892028-19.patch | 3.32 KB | jmarkel |
#16 | purge-curl-multi-select-1892028-16.patch | 3.34 KB | djbobbydrake |
#14 | purge-curl-multi-select-1892028-12.patch | 3.22 KB | hefox |
Comments
Comment #1
SqyD CreditAttribution: SqyD commentedThank you for this report. For the 2.x release I plan to have a more modular approach that would allow for curl replacements so implementing multiple curl versions should be an option too. I wonder if Guzzle will magicaly take care of these different behaviors in curl...
Comment #2
jaydub CreditAttribution: jaydub commentedI just ran into this myself on PHP 5.3.24. I looked up the PHP bug report noted above and there was someone's workaround that did seem to work for me. I've rolled a patch that does a PHP version check for supposedly affected versions of PHP curl_multi_select() which would be 5.3.18+ and 5.4.8+. With the patch my purge _did_ work so it would seem to be at least a temporary fix for those that are running into this.
Comment #3
jaydub CreditAttribution: jaydub commentedRerolled as I only tested for > than 5.3.18 and > 5.4.8 rather than including those releases.
Comment #4
jaydub CreditAttribution: jaydub commentedOne more time! I just submitted an unchanged patch :)
Comment #5
rahulbile CreditAttribution: rahulbile commentedHere is the patch against 7-x.1.6.
Comment #6
mrfelton CreditAttribution: mrfelton commentedPatch updated against latest 7.x-1.x dev code.
Comment #7
Firemyst CreditAttribution: Firemyst commentedWe just pulled this patch into our QA env. It wasn't working, but I'm not sure why. When I tested on local VMs, I was able to make purge work with, or without this patch.
Any suggestions?
Comment #8
jaydub CreditAttribution: jaydub commented@Firemyst Since the patch is based on specific versions of PHP, would help to know what your environment is running...
Comment #9
Firemyst CreditAttribution: Firemyst commentedOf course. Here's what we have for apache and PHP:
Server:Apache/2.2.3 (Red Hat)
Via:1.1 varnish
X-Powered-By:PHP/5.4.15
It's where the usleep() should have went into effect, but I don't see how the patch works, since the state doesn't seem to leave state -1. There's no re-test before the exit condition of the do().
I have a task this week to actually convert my patch to a patch file. I'll post it here for review.
Comment #10
Firemyst CreditAttribution: Firemyst commentedHere is the patch against v1.6
Comment #11
xavier_g CreditAttribution: xavier_g commentedHello,
Regarding the patch attached to #10: I am pretty sure you meant:
$multi_result = curl_multi_exec($curl_purges, $active);
instead of:
$multi_result = curl_multi_exec($curl_pages, $active);
Indeed, applying the initial patch generates the following warning at purge time:
curl_multi_exec() expects parameter 1 to be resource, null given purge.inc:148
Comment #12
Firemyst CreditAttribution: Firemyst commentedYes, that's correct. Also solves a warning message I was getting, but only on QA servers.
Thanks.
Comment #13
hefox CreditAttribution: hefox commentedHaven't tested it, but there's some minor spacing code stye issues with last patch
Comment #14
hefox CreditAttribution: hefox commentedquickie attempt to update 12 to 1.x-dev
Comment #15
geerlingguy CreditAttribution: geerlingguy commentedThis bug basically broke my local development environment when I was running PHP 5.4.x. I downgraded to 5.3.3 (CentOS default) and now things are working again.
The patch in #14 looks correct, but I can't test it right now :(
Comment #16
djbobbydrake CreditAttribution: djbobbydrake commentedI've modified the patches from 12 and 14. This patch is rolled against 7.x-1.x-dev. I've tested this patch on 7.x-1.6 in my live environment and it's working successfully. I'm on php 5.3.28 and Varnish 3.0.5. I've wrapped the curl_multi_exec into a separate function.
Comment #17
djbobbydrake CreditAttribution: djbobbydrake commentedI'm going to have to amend the patch in #16, since it only supports 5.3.18+ and 5.4.8+. And will need to test in D6 and D7 in the different php versions.
Comment #18
Pinky Brain CreditAttribution: Pinky Brain commentedSame bug with PHP 5.5.8 and Purge module 7x-1.6. Patch #16 (tested with 7x-1.6+2-dev) works as bug fix.
Comment #19
jmarkel CreditAttribution: jmarkel commentedI have rerolled the patch at #16 so that it will apply directly to 7.x-1.6. The one at #16 applies to HEAD on the 7.x-1.x branch but not to the released version.
Comment #20
hanoiiI just faced the same issue and also follow it up a fix before looking into the issue queue (as most times!!), anyway, attached is my version of the patch, I think we did a very similar thing only I changed less lines of code so maybe simpler to review?
Comment #21
brianV CreditAttribution: brianV commentedI installed the patch from #19 above, and it did the trick on PHP 5.5.9. This approach is good, however, I haven't tested #16 (which applies against the main dev branch) as we are running the current stable release.
Comment #22
djbobbydrake CreditAttribution: djbobbydrake commentedWould someone be able to confirm that the patch in purge-curl-multi-select-1892028-19.patch works against php version lower than 5.3.18? If so, will close out this issue.
Comment #23
eugene.ilyin CreditAttribution: eugene.ilyin commented#19 helps me. Thanks @jmarkel
Comment #24
johan.gant CreditAttribution: johan.gant commented#19 worked for me on 7.x-1.6 with PHP 5.4
Comment #25
PieterDC#20 works for me. I haven't tried #19. Decided to go with the smaller patch right away.
Module version 7.x-1.6
PHP version 5.4.10
Comment #26
PieterDCRerolled patch from #20 against 7.x-1.6, made it comply coding standards and got rid of a temporary variable.
Comment #27
Vacilando CreditAttribution: Vacilando commentedOn
drush cc all
I was gettingsimilar to what was reported in #1874448: Warning: Invalid argument supplied for foreach() in purge_logging() (line 167 of /www/www/htdocs/sites/all/modules/purge/purge.i.
Applied #20 and the problem went away. Could this (or #19 if more acceptable) be released to dev?
Comment #29
SqyD CreditAttribution: SqyD commentedCommitted to 7.x-1.x branch. Thanks all!.
Comment #30
SqyD CreditAttribution: SqyD commented