Merge pull request #18554 from civicrm/5.30
[civicrm-core.git] / Civi / Api4 / Generic / Result.php
index 675b752e70a20e93162f50e74440cb9641f8b81a..afc30c217ade1d5b7dde54284881ac457609ae4b 100644 (file)
@@ -40,6 +40,10 @@ class Result extends \ArrayObject implements \JsonSerializable {
    * @var int
    */
   public $version = 4;
+  /**
+   * @var int
+   */
+  public $rowCount;
 
   private $indexedBy;
 
@@ -107,11 +111,7 @@ class Result extends \ArrayObject implements \JsonSerializable {
    * @return int
    */
   public function count() {
-    $count = parent::count();
-    if ($count == 1 && is_array($this->first()) && array_keys($this->first()) == ['row_count']) {
-      return $this->first()['row_count'];
-    }
-    return $count;
+    return $this->rowCount ?? parent::count();
   }
 
   /**