From 4cf74b0d1733605f9cd91e0c89babd57b760b4c6 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 8 Apr 2023 15:40:19 -0400 Subject: [PATCH] Fix APIv3 test to better handle serialized fields --- Civi/API/Subscriber/ChainSubscriber.php | 4 +++- tests/phpunit/api/v3/SyntaxConformanceTest.php | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Civi/API/Subscriber/ChainSubscriber.php b/Civi/API/Subscriber/ChainSubscriber.php index 7be1bfb913..84b011eed4 100644 --- a/Civi/API/Subscriber/ChainSubscriber.php +++ b/Civi/API/Subscriber/ChainSubscriber.php @@ -90,9 +90,11 @@ class ChainSubscriber implements EventSubscriberInterface { $result = ['values' => [0 => $oldResult]]; } + // Keys which should not be assumed to be chain calls + $blacklist = ['api.has_parent', 'api_params']; // Scan the params for chain calls. foreach ($params as $field => $newparams) { - if ((is_array($newparams) || $newparams === 1) && $field <> 'api.has_parent' && substr($field, 0, 3) == 'api') { + if ((is_array($newparams) || $newparams === 1) && !in_array($field, $blacklist, TRUE) && substr($field, 0, 3) == 'api') { // This param is a chain call, e.g. api.. // 'api.participant.delete' => 1 is a valid options - handle 1 diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index a67b8c9d5c..e580a495ec 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -1461,6 +1461,9 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { // FIXME: Why doesn't creating a campaign clear caches? civicrm_api3($entityName, 'getfields', ['cache_clear' => 1]); } + if (!empty($specs['serialize'])) { + $entity[$field] = (array) $entity[$field]; + } $updateParams = [ 'id' => $entity['id'], $field => $entity[$field] ?? NULL, -- 2.25.1