TypeError: Civi\Api4\Generic\AbstractAction::setCheckPermissions(): Argument #1

Created on 25 June 2025, 3 months ago

1.0 Problem/Motivation

This error happens on webform submit:

TypeError: Civi\Api4\Generic\AbstractAction::setCheckPermissions(): Argument #1 ($checkPermissions) must be of type bool, null given, called in /var/www/html/vendor/civicrm/civicrm-core/Civi/API/Request.php on line 58 in Civi\Api4\Generic\AbstractAction->setCheckPermissions() (line 198 of /var/www/html/vendor/civicrm/civicrm-core/Civi/Api4/Generic/AbstractAction.php).

2.0 Detailed steps to reproduce (embed screenshots)

1. **Setup:** Start with a Drupal site with `Webform` and `webform_civicrm` installed and connected to a CiviCRM instance.
2. **Create Webform:** Create a new webform.
3. **Configure CiviCRM Handler:**
* In the webform's CiviCRM settings, enable CiviCRM processing.
* Set "Number of Contacts" to 2 (or more).
* Configure "Contact 1" as an Individual.
* Configure "Contact 2" as any contact type (e.g., Organization).
4. **Build Form Element:**
* Go to the "Build" tab of the webform.
* Add an **Entity select** element.
* Set its **Machine name** to `civicrm_2_contact_1_contact_existing`.
* Configure the element to select existing CiviCRM contacts.
* Crucially, enable the **"Multiple"** option to allow selecting more than one contact.
5. **Map the Relationship:**
* Go back to the CiviCRM handler settings.
* On the "Relationship" tab, add a relationship between Contact 1 and Contact 2 to ensure the data from Contact 2 is used.
6. **Test Submission:**
* Go to the "View" or "Test" tab of the webform.
* Fill in the details for Contact 1.
* In the "Existing Contact" field, select one or more contacts from the list.
* Submit the form.

**Expected Result:**
The form should submit successfully, creating the specified relationship(s).

**Actual Result:**
A fatal error occurs: `TypeError: Civi\Api4\Generic\AbstractAction::setCheckPermissions(): Argument #1 ($checkPermissions) must be of type bool, null given...`

Stack strace:

Civi\Api4\Generic\AbstractAction->setCheckPermissions() (line 198 of /var/www/html/vendor/civicrm/civicrm-core/Civi/Api4/Generic/AbstractAction.php).
Civi\Api4\Generic\AbstractAction->setCheckPermissions(NULL) (Line: 58)
Civi\API\Request::create('Contact', 'get', Array) (Line: 77)
civicrm_api4('Contact', 'get', Array, NULL) (Line: 626)
Drupal\webform_civicrm\Utils->wf_civicrm_api4('Contact', 'get', Array) (Line: 234)
Drupal\webform_civicrm\ContactComponent->wf_crm_contact_access(Array, Array, '221357') (Line: 631)
Drupal\webform_civicrm\WebformCivicrmPostProcess->verifyExistingContact('221357', 'civicrm_6_contact_1_contact_existing') (Line: 611)
Drupal\webform_civicrm\WebformCivicrmPostProcess->getExistingContactIds() (Line: 187)
Drupal\webform_civicrm\WebformCivicrmPostProcess->preSave(Object) (Line: 144)
Drupal\webform_civicrm\Plugin\WebformHandler\CivicrmWebformHandler->preSave(Object, NULL, NULL) (Line: 2765)
Drupal\webform\Entity\Webform->invokeHandlers('preSave', Object, NULL, NULL) (Line: 1212)
Drupal\webform\WebformSubmissionStorage->invokeWebformHandlers('preSave', Object) (Line: 968)
Drupal\webform\WebformSubmissionStorage->doPreSave(Object) (Line: 517)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 804)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 983)

3.0 Proposed resolution

src/ContactComponent.php

      'checkPermissions' => $contact_element->getElementProperty($component, 'check_permissions') ?? TRUE

4.0 Submit PR on https://github.com/colemanw/webform_civicrm

🐛 Bug report
Status

Active

Version

6.2

Component

CiviCRM Data Handling

Created by

🇬🇧United Kingdom kenorb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024