X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi%2FApi4%2FGeneric%2FAbstractAction.php;h=9347394ada9d15cae280015073f09c0db43dc211;hb=a4934764e309b794d091a3a1448a36b6fe1367e8;hp=a531cddc72d4ae640b21fc449a4167519f71152e;hpb=a1e9d187534eab7fa135fd61f5bbe3368370a942;p=civicrm-core.git diff --git a/Civi/Api4/Generic/AbstractAction.php b/Civi/Api4/Generic/AbstractAction.php index a531cddc72..9347394ada 100644 --- a/Civi/Api4/Generic/AbstractAction.php +++ b/Civi/Api4/Generic/AbstractAction.php @@ -327,13 +327,14 @@ abstract class AbstractAction implements \ArrayAccess { /** * @inheritDoc */ - public function offsetExists($offset) { + public function offsetExists($offset): bool { return in_array($offset, ['entity', 'action', 'params', 'version', 'check_permissions', 'id']) || isset($this->_arrayStorage[$offset]); } /** * @inheritDoc */ + #[\ReturnTypeWillChange] public function &offsetGet($offset) { $val = NULL; if (in_array($offset, ['entity', 'action'])) { @@ -359,7 +360,7 @@ abstract class AbstractAction implements \ArrayAccess { /** * @inheritDoc */ - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { if (in_array($offset, ['entity', 'action', 'entityName', 'actionName', 'params', 'version', 'id'])) { throw new \API_Exception('Cannot modify api4 state via array access'); } @@ -374,7 +375,7 @@ abstract class AbstractAction implements \ArrayAccess { /** * @inheritDoc */ - public function offsetUnset($offset) { + public function offsetUnset($offset): void { if (in_array($offset, ['entity', 'action', 'entityName', 'actionName', 'params', 'check_permissions', 'version', 'id'])) { throw new \API_Exception('Cannot modify api4 state via array access'); } @@ -398,7 +399,7 @@ abstract class AbstractAction implements \ArrayAccess { * @return array */ public function getPermissions() { - $permissions = call_user_func([CoreUtil::getApiClass($this->_entityName), 'permissions']); + $permissions = call_user_func([CoreUtil::getApiClass($this->_entityName), 'permissions'], $this->_entityName); $permissions += [ // applies to getFields, getActions, etc. 'meta' => ['access CiviCRM'], @@ -513,6 +514,12 @@ abstract class AbstractAction implements \ArrayAccess { $options = FormattingUtil::getPseudoconstantList($info['field'], $info['expr'], $record, 'create'); $record[$fieldName] = FormattingUtil::replacePseudoconstant($options, $info['val'], TRUE); } + // The DAO works better with ints than booleans. See https://github.com/civicrm/civicrm-core/pull/23970 + foreach ($record as $key => $value) { + if (is_bool($value)) { + $record[$key] = (int) $value; + } + } } /**