1

After upgrading to civicrm version 5.21 we detected a problem in one of the fields of the form linked to a custom profile.

For some reason, every time you try to insert that data from the form in the frontend it returns the error message:

0 Argument 1 passed to civicrm_api3() must be of the type string, null given, called in /public_html/administrator/components/com_civicrm/civicrm/CRM/Dedupe/BAO/Rule.php on line 62

It is an alphanumeric text field, the same as others that populate the form. Has anyone else come across this problem? What can it be caused by?

EDIT - the field in question is used for DEDUPE RULE (for control of duplicate entries), looks like there is something broke with that

1
  • This does look like a bug of some kind, but hard to guess exactly based on the limited information available. It might be a bug in CiviCRM (perhaps search at lab.civicrm.org/dev/core/issues to see if you can find an existing bug report), or it might lie within an extension. You could use process of elimination to find out if it's an extension, by selectively disabling extensions on the site. Failing that, your best course of action may be to get hands-on help (probably for a fee) from a CiviCRM developer (see civicrm.org/partners-contributors as a starting point).
    – TwoMice
    Jan 23, 2020 at 16:11

3 Answers 3

0

We are experiencing a similar type error on staging site running 5.21

-we have created a custom field in the civicrm profile used for site registration, e.g. that matches on a unique identifier (card Number)

-The error we are getting looks likes this :

TypeError: Argument 1 passed to civicrm_api3() must be of the type string, null given, called in /home/ibew90v2/master/sites/all/modules/civicrm/CRM/Dedupe/BAO/Rule.php on line 62 in civicrm_api3() (line 84 of /home/ibew90v2/master/sites/all/modules/civicrm/api/api.php). ERROR The website encountered an unexpected error. Please try again later.  

The error appears to state that it is looking for null value (?) and cannot handle any input (alphanumeric or otherwise in the field) Placing nothing in the custom field it allows the profile submission and creates the account.

The latest release notes here reference a change to the api https://github.com/civicrm/civicrm-core/blob/master/release-notes/5.21.0.md https://github.com/civicrm/civicrm-core/pull/15817

"Fixes a formatting issue in the api explorer output where IS NULL and IS NOT NULL clauses would output invalid code due to the missing value piece of the clause." it appears that the api did not update, somehow when doing the upgrade, that it is still referencing the apiv3 folder .

Notes :

first part of the error references line 66 in the rule.php file, e.g. /home/ibew90v2/master/sites/all/modules/civicrm/api/v3/Rule.php "This api exposes CiviCRM (dedupe) rules."

The second part of the error references the api.php file at /home/ibew90v2/master/sites/all/modules/civicrm/api/api.php it is breaking down here, line 84 :   function civicrm_api3(string $entity, string $action, array $params = []) {  $params['version'] = 3;

However 5.21 per release notes is using api v4 -- are these old files ? need to be replaced or updated?

Possible fix here : https://github.com/civicrm/civicrm-core/pull/15817/files  

0

On further debugging, I see that this function isn't returning anything CRM_Core_DAO_AllCoreTables::getClassForTable($this->rule_table). (Line 61 Dedupe/BAO/Rule.php)

So, in getClassForTable, the list of tables doesn't include 'civicrm_view_members_1' and therefore

$entity = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($this->rule_table));

$entity is set to null. which then gives the error Argument 1 passed to civicrm_api3() must be of the type string, null given.

I will have to check if its related to the api version problem.

Edit: Added this check here after line 62 in civicrm/CRM/Dedupe/BAO/Rule.php

// if $entity is not set, setting it to empty string because of type declarations 
$entity = $entity ? $entity : '';

It seems to have fixed the issue and dedupe on the custom field also looks ok.

1
  • Hi mmk, welcome to Stackexchange, it is worth editing any current information with any new information rather than submitting a new answer that doesn't really answer the question as this is likely to get downvoted because of that :)
    – Jade
    Jan 23, 2020 at 9:49
0

Thanks mmk. I also encountered this issue on CIVICRM5.21.2/Wordpress 5.4.2. This phenomena appeared to me when I tried to find duplicates using a dedupe rule based on a custom field. it would crash at WP end. I followed you instruction above and it works, only slight modification to your instruction that it the check should be inserted after line 61 where "$entity = CRM_Core_DAO_AllCoreTables..." is called. thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.