I use purge and expire modules to flush the nginx cache.

The pages cached are well purged in the nginx cache but i get always this warning

Warning : Invalid argument supplied for foreach() dans purge_logging() (ligne 178 ...

Because the param $purge_request_results of the function purge_logging (ligne 173 in purge.inc) is always empty.

It seems that in the function purge_issue_requests_curl($purges), i always match the condition line 147

if ($multi_result != CURLM_OK || $select_result == -1) {
    // @TODO: error handling. Something truly awkward happened.
    return FALSE;
    }

If i comment return FALSE, i get well the logs of purge module in the watchdog, without warning.

Is this normal, because of the @TODO ?

Thanks

Comments

flocondetoile’s picture

Status: Active » Needs review

I made some try. I am not an expert of CURL and found examples about the usage of curl_multi_exec and curl_multi_select.

I change this code line 134 in purge.inc

// Execute the purge requests
  ob_start();
  do {
    // This loop is only necessary for libcurl earlier than 7.20.0, however
    // RHEL 5 has just that. Otherwise a simple call would do.
    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);
    }
    if ($multi_result != CURLM_OK || $select_result == -1) {
    // @TODO: error handling. Something truly awkward happened.
    return FALSE;
    }
  } while ($select_result != -1 && $active && $multi_result == CURLM_OK);
  ob_end_clean();

with this code

// Execute the purge requests
  $active = NULL;
  ob_start();
  do {
      $multi_result = curl_multi_exec($curl_purges, $active);
    } while ($multi_result == CURLM_CALL_MULTI_PERFORM);
    
    // Do the job until there is activity on any of the handlers.
  while ($active && $multi_result == CURLM_OK) {
    if (curl_multi_select($curl_purges) != -1) {
      do {
         $multi_result = curl_multi_exec($curl_purges, $active);
      } while ($multi_result == CURLM_CALL_MULTI_PERFORM);
    }
  }
  ob_end_clean();

The job seems to be done. The pages are well purged from the nginx cache without warning and with the purge's logs in the watchdog.

But i missing perhaps something ? about REHL 5 ?

jaydub’s picture

Possibly related to #1892028: curl fails: change to curl_multi_select() in PHP. What version of PHP are you running?

flocondetoile’s picture

I use PHP 5.3.24

In my case, the pages cached are well purged.

jaydub’s picture

See the other issue then #1892028: curl fails: change to curl_multi_select() in PHP as it looks like a change in PHP starting with 5.3.18 may be the reason you see the problem. There's a patch in that issue that you can try to test.

m.stenta’s picture

Issue summary: View changes
Status: Needs review » Closed (duplicate)

I was getting the same error, and the patch in #1892028: curl fails: change to curl_multi_select() in PHP solved it.

Closing this issue as a duplicate.