diff --git a/Civi/Api4/Query/SqlExpression.php b/Civi/Api4/Query/SqlExpression.php index f4192477d398..6fce01092c1d 100644 --- a/Civi/Api4/Query/SqlExpression.php +++ b/Civi/Api4/Query/SqlExpression.php @@ -224,7 +224,7 @@ protected function captureKeyword($keywords, &$arg) { protected function captureExpressions(string &$arg, array $mustBe, int $max) { $captured = []; $arg = ltrim($arg); - while ($arg) { + while (strlen($arg)) { $item = $this->captureExpression($arg); $arg = ltrim(substr($arg, strlen($item))); $expr = self::convert($item, FALSE, $mustBe); diff --git a/tests/phpunit/api/v4/Action/SqlFunctionTest.php b/tests/phpunit/api/v4/Action/SqlFunctionTest.php index 329c4fefc75e..5f868900781d 100644 --- a/tests/phpunit/api/v4/Action/SqlFunctionTest.php +++ b/tests/phpunit/api/v4/Action/SqlFunctionTest.php @@ -167,7 +167,7 @@ public function testComparisonFunctions() { $result = Activity::get(FALSE) ->addWhere('id', 'IN', $aids) - ->addSelect('IF(is_deleted, "Trash", "No Trash") AS trashed') + ->addSelect('IF(is_deleted, 1, 0) AS trashed') ->addSelect('NULLIF(subject, location) AS nullif_subject_is_location') ->addSelect('NULLIF(duration, 456) AS nullif_duration_is_456') ->addSelect('COALESCE(duration, location) AS coalesce_duration_location') @@ -179,9 +179,9 @@ public function testComparisonFunctions() { ->execute()->indexBy('id'); $this->assertCount(3, $result); - $this->assertEquals('No Trash', $result[$aids[0]]['trashed']); - $this->assertEquals('Trash', $result[$aids[1]]['trashed']); - $this->assertEquals('No Trash', $result[$aids[2]]['trashed']); + $this->assertEquals(0, $result[$aids[0]]['trashed']); + $this->assertEquals(1, $result[$aids[1]]['trashed']); + $this->assertEquals(0, $result[$aids[2]]['trashed']); $this->assertEquals(NULL, $result[$aids[0]]['nullif_subject_is_location']); $this->assertEquals('xyz', $result[$aids[1]]['nullif_subject_is_location']);