dev/core#38 Fix inappropriate limit on participant.getcount
authoreileen <emcnaughton@wikimedia.org>
Thu, 24 May 2018 23:21:37 +0000 (11:21 +1200)
committereileen <emcnaughton@wikimedia.org>
Thu, 24 May 2018 23:21:37 +0000 (11:21 +1200)
api/v3/utils.php
tests/phpunit/api/v3/ParticipantTest.php

index 9948ae9e6bddd7dbadb8177ee28015e8ca9c5f0d..814d11e0b83a9ab9ccfd5a3a066e3a3a31cf5b3b 100644 (file)
@@ -819,7 +819,7 @@ function _civicrm_api3_get_options_from_params(&$params, $queryObject = FALSE, $
 
   $options = array(
     'offset' => CRM_Utils_Rule::integer($offset) ? $offset : NULL,
-    'limit' => CRM_Utils_Rule::integer($limit) ? $limit : NULL,
+    'limit' => (!$is_count && CRM_Utils_Rule::integer($limit)) ? $limit : NULL,
     'is_count' => $is_count,
     'return' => !empty($returnProperties) ? $returnProperties : array(),
   );
index 9de692b0fb266664562f437b304010653120f73c..17321af996a33780e1e64cccff12c1bf4ecb698c 100644 (file)
@@ -98,6 +98,23 @@ class api_v3_ParticipantTest extends CiviUnitTestCase {
     $this->quickCleanup($tablesToTruncate, TRUE);
   }
 
+  /**
+   * Check that getCount can count past 25.
+   */
+  public function testGetCountLimit() {
+    $contactIDs = [];
+
+    for ($count = $this->callAPISuccessGetCount('Participant', []); $count < 27; $count++) {
+      $contactIDs[] = $contactID = $this->individualCreate();
+      $this->participantCreate(['contact_id' => $contactID, 'event_id' => $this->_eventID]);
+    }
+    $this->callAPISuccessGetCount('Participant', [], 27);
+
+    foreach ($contactIDs as $contactID) {
+      $this->callAPISuccess('Contact', 'delete', ['id' => $contactID]);
+    }
+  }
+
   /**
    * Test get participants with role_id.
    */