This extension offers in-line replacements for deprecated and abandoned CiviCRM Core functions
The extension is licensed under AGPL-3.0.
The purpose of this extension is to offer replacements for functions that have been deprecated or even removed from the CiviCRM Core.
Of course, you should resolving this by replacing these function calls with a well-designed piece of code to exactly the same thing that the old function did for you, but in a clean and up-to-date way. Since that might be a lot of work, we designed this extension to offer a quick, temporary solution to your extensions' compatibility issues.
- PHP v7.4+
- CiviCRM 5.45+
- Check out your extension from a repository
- Open a shell and navigate into your extension's folder
- Run a simple scan command. This one should find all calls that are removed from current CiviCRM versions:
grep -r -E "(CRM_Utils_Token::replaceOrgTokens|CRM_Activity_Form_Task_PDFLetterCommon|PDFLetterCommon::postProcess|CRM_Core_OptionGroup::getValue|CRM_Core_OptionGroup::getLabel|CRM_Contact_BAO_Contact::contactTrashRestore|CRM_Contact_BAO_Contact::getPhoneDetails|CRM_Core_DAO::checkFieldExists|CRM_Contact_BAO_Contact::getPhoneDetails|CRM_Core_DAO::createTempTableName|civicrm_api3_field_names|ation::deleteLocationBlocks|ipn_process_transaction|CRM_Core_Form_Date::buildDateRange|CRM_Core_Form_Date::returnDateRangeSelector|CRM_Core_Form_Date::addDateRangeToForm|CRM_Core_DAO::executeSql)" *
You can also run this one, to find all problematic calls, i.e. deprecated and removed:
grep -r -E "(CRM_Utils_Token::replaceOrgTokens|CRM_Activity_Form_Task_PDFLetterCommon|PDFLetterCommon::postProcess|CRM_Core_OptionGroup::getValue|CRM_Core_OptionGroup::getLabel|CRM_Contact_BAO_Contact::contactTrashRestore|CRM_Contact_BAO_Contact::getPhoneDetails|CRM_Core_DAO::checkFieldExists|CRM_Contact_BAO_Contact::getPhoneDetails|CRM_Core_DAO::createTempTableName|civicrm_api3_field_names|ation::deleteLocationBlocks|ipn_process_transaction|CRM_Core_Form_Date::buildDateRange|CRM_Core_Form_Date::returnDateRangeSelector|CRM_Core_Form_Date::addDateRangeToForm|CRM_Core_Error::debug_log_message|CRM_Core_DAO::executeSql|::getContactRelationshipSelector|::getContactRelationships)" *
- Investigate each match and replace all calls in your extension according to the table below.
- Add the
lagacycodeextension as part of it's dependencies, i.e. add the following to your extensions'info.xml:<requires> <ext>legacycode</ext> </requires> - Review your changes and create a commit
- If you made any changes to your extension, make sure the
lagacycodeextension
<requires>
<ext>legacycode</ext>
</requires>
- Create a new release for your extension.
- Advantage: minimally invasive
- Disadvantage: extension dependency
- Investigate each match in the table below and find out which class provides the discontinued function, e.g.
CRM_Legacycode_OptionGroup::getValue - Copy that class into your extension, e.g. into
CRM/EXTENSION/Legacycode/OptionGroup.php, where 'EXTENSION' should be your extension's namespace. - Adjust the class name accordingly, e.g.
CRM_Mything_Legacycode_OptionGroup - Replace all calls in your extension, e.g.
CRM_Mything_Legacycode_OptionGroup::getValue - Create a new release for your extension.
- Advantage: no extension dependency
- Disadvantage: more work
You can find an example here
| Function | Replacement | Deprecated Since | Dropped Since |
|---|---|---|---|
CRM_Core_DAO::executeSql |
todo | ? | no idea, but old |
PDFLetterCommon::postProcess |
todo | ? | 5.57 |
CRM_Activity_Form_Task_PDFLetterCommon |
todo | ? | 5.57 |
CRM_Utils_Token::replaceOrgTokens |
todo | ? | 5.57 |
CRM_Core_OptionGroup::getValue |
CRM_Legacycode_OptionGroup::getValue | ? | 5.60 |
CRM_Core_OptionGroup::getLabel |
CRM_Legacycode_OptionGroup::getLabel | ? | 5.60 |
CRM_Contact_BAO_Contact::contactTrashRestore |
todo | ? | 5.60 |
CRM_Core_DAO::checkFieldExists |
todo | ? | 5.60 |
CRM_Contact_BAO_Contact::getPhoneDetails |
todo | ? | 5.60 |
CRM_Core_DAO::createTempTableName |
CRM_Legacycode_Core_DAO::createTempTableName | ? | 5.60 |
civicrm_api3_field_names |
todo | ? | 5.60 |
CRM_Core_BAO_Location::deleteLocationBlocks |
todo | ? | 5.60 |
ipn_process_transaction |
todo | ? | 5.60 |
CRM_Core_Form_Date::buildDateRange |
CRM_Legacycode_Date::buildDateRange | ? | 5.61 |
CRM_Core_Form_Date::returnDateRangeSelector |
CRM_Legacycode_Date::returnDateRangeSelector | ? | 5.61 |
CRM_Core_Form_Date::addDateRangeToForm |
CRM_Legacycode_Date::addDateRangeToForm | ? | 5.61 |
CRM_Contact_BAO_Relationship::getContactRelationshipSelector |
? | ? | 5.74 |
CRM_Contact_Page_AJAX::getContactRelationships |
? | ? | 5.74 |
CRM_Core_Error::debug_log_message |
Civi::log()->debug | ? | not yet |
| (more to come) | todo |
Since this aims to be a collection of some very volatile information, PRs are very welcome!