Fatal errors in code that calls methods in `CRM_Dedupe_BAO_RuleGroup` in 5.62+
Overview
There are a number of plugins out in the wild that call CRM_Dedupe_BAO_RuleGroup::getByType()
to retrieve a keyed array of Dedupe Rules. These include, but may not be limited to:
- Caldera Forms CiviCRM (or whichever adapted version people are still using)
- CiviCRM Profile Sync
- CiviCRM Admin Utilities (thankfully not used internally)
- Integrate CiviCRM with WooCommerce
- CiviCRM Event Organiser
I have updated each of these to use API4 instead - but I don't know how many other plugins, modules and extensions there are out there that use similar code for similar purposes. Moreover, if people update to CiviCRM 5.62.x without updating their plugins first, their sites will throw a fatal error and (in some cases) become non-functional - though the severity of this depends on when the code is called.
Reproduction steps
- Install CiviCRM 5.62.x
- Install one of the unpatched plugins listed above.
- Go to a screen that renders a list of Dedupe Rules (with CiviCRM Profile Sync using ACF Extended forms, any screen will do)
- PHP Fatal error: Uncaught Error: Class "CRM_Dedupe_BAO_RuleGroup" not found".
Current behaviour
Calling CRM_Dedupe_BAO_RuleGroup::getByType()
throws a fatal error.
Expected behaviour
I don't object to files being removed from CiviCRM as such, however there should be mitigations in place to warn developers that this is likely to happen in a future version of CiviCRM.
When aliasing classes, it would be really helpful if methods are overloaded and implemented something like _deprecated_function
to write something to the logs so that developers are aware of the impending removal of classes and methods, e.g.:
/**
* @inheritDoc
*/
public static function getByType($contactType = NULL) {
civicrm_deprecated_function( __METHOD__, '5.39', 'CRM_Dedupe_BAO_DedupeRuleGroup::getByType()' );
return parent::getByType($contactType);
}
I'd have acted sooner if I'd seen something like the following in my logs:
Function CRM_Dedupe_BAO_RuleGroup::getByType() is deprecated since CiviCRM version 5.39. Use CRM_Dedupe_BAO_DedupeRuleGroup::getByType() or civicrm_api4() instead.
As it stands, people have 2 weeks or so to update their plugins/modules/etc before updating CiviCRM to 5.62 causes issues.