I'm using the v3 API to pull a list of participants for an event record. The call I'm making is:

$result = civicrm_api3( 'participant', 'get', array(
    'event_id' => $event_id,
    'options' => array(
        'limit' => 100,
) );

Usually, this works fine and pulls the participant information that I need. However, sometimes it will pull zero results (which is incorrect) but, on refreshing the theme page that displays the data, it will show the participants. It's like the first time through gets no results but primes the second try to be correct. It does not show zero records after the refresh, at least for a while. I cannot regularly recreate this error. As soon as I start pulling down participant records over and over, I don't see the problem show up.

I know this is not a lot to go on but I'm not sure what else to check or how to reliably reproduce this in a way to show off the issue.

Is there a different way to pull participants? Or is this potentially something amiss with CiviCRM?


  • 2
    Have you checked shouldiblamecaching.com? ;) – Coleman Jul 14 '15 at 2:52
  • 1
    @Coleman ... That brings up a good question. Are API calls via PHP cached? I would assume they're not. On the front-end, logged in users for this site are not served cached pages. Even then, just refreshing the page should not break the cache. – joshcanhelp Jul 14 '15 at 19:07
  • 1
    Well, I guess the answer is "maybe." The CiviCRM api itself does not cache anything (well except getfields), but in other layers there might be caching going on. If it's an ajax api call you might get caching in your browser or reverse-proxy server. Certain BAOs (which serve results to the api) perform some caching. But I can't offhand think of why this particular call would be affected. I've never run into this kind of problem before. – Coleman Jul 15 '15 at 1:43
  • @Coleman - It's all happening on page load, directly in PHP. Also, if it was cached, I would expect to see possibly a lower number of participants, not just "none" every time. Maybe someone should update shouldiblamecaching.com to "sometimes" or "maybe" :) – joshcanhelp Jul 15 '15 at 16:13
  • Can you ensure that $event_id is always a value corresponding to a valid event id ? – samuelsov Jul 29 '15 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.