Deprecated function: Optional parameter $from declared before required parameter $element
Overview
Deprecated function: Optional parameter $from declared before required parameter $element is implicitly treated as a required parameter in require_once() (line 19 of /sites/all/modules/civicrm/drupal/modules/civicrm_rules/civicrm_rules.rules.inc).
The deprecated error issue is related to two files in the civicrm_rules sub module.
- line 20 of /civicrm/drupal/modules/civicrm_rules/civicrm_rules.mailing-eval.inc
- line 27 of civicrm/drupal/modules/civicrm_rules/civicrm_rules.contact-eval.inc
This issue is referenced at: #3958 (comment 152174)
Reproduction steps
- Provision a new Drupal 7 / CiviCRM site on PHP 8.2 or change an existing site to PHP 8.2
- Got an error "Fatal error: Deprecated function: Optional parameter $from declared before required parameter $element is implicitly treated as a required parameter in require_once() (line 19 of /sites/all/modules/civicrm/drupal/modules/civicrm_rules/civicrm_rules.rules.inc).".
Environment information
- CiviCRM: version 5.66.0 (any version)
- PHP: 8.2.x
- CMS: Drupal 7.98 (any Drupal 7 version)
- Database: MySQL 5.7.7/MariaDB 10.4/...
- Web Server: Apache 2.4/Nginx 1.16/...
Comments
The fix is to set the optional parameter $from = NULL to string $from = NULL.
- The sites where I have found this issue all use the Drupal Rules module so this may not impact sites that don't use Drupal Rules in their workflow.
I will create a PR shortly.