Problem/Motivation
When using a variable of type "View result variable" and the arguments field is empty, it shows the following warning when executing the routine:
Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\business_rules\Plugin\BusinessRulesVariable\ViewResultVariable->evaluate() (line 223 of modules/contrib/business_rules/src/Plugin/BusinessRulesVariable/ViewResultVariable.php).
Drupal\business_rules\Plugin\BusinessRulesVariable\ViewResultVariable->evaluate(Object, Object) (Line: 94)
Drupal\business_rules\Entity\Variable->evaluate(Object) (Line: 708)
Drupal\business_rules\Util\BusinessRulesProcessor->evaluateVariable(Object, Object) (Line: 673)
Drupal\business_rules\Util\BusinessRulesProcessor->evaluateVariables(Object, Object) (Line: 501)
Drupal\business_rules\Util\BusinessRulesProcessor->executeAction(Object, Object) (Line: 344)
Drupal\business_rules\Util\BusinessRulesProcessor->processItems(Array, Object, 'alertas_compara_valores') (Line: 384)
Drupal\business_rules\Util\BusinessRulesProcessor->processItems(Array, Object, 'alertas_envio_p1') (Line: 289)
Drupal\business_rules\Util\BusinessRulesProcessor->processTriggeredRules(Array, Object) (Line: 198)
Drupal\business_rules\Util\BusinessRulesProcessor->process(Object) (Line: 207)
Drupal\business_rules\EventSubscriber\BusinessRulesListener->process(Object, 'business_rules.cron_runs', Object)
...
Steps to reproduce
- Create a variable of type "View result variable" and configure it, leaving the arguments field empty.
- Create a routine that uses the variable created earlier.
- Run the routine created earlier.
Proposed resolution
If the result of the arguments is null, apply an empty string. Line to change.
// Get settings.
$defined_view = $variable->getSettings('view');
$view_fields = $variable->getSettings('view_html');
$args = $variable->getSettings('arguments');
$event_variables = $event->getArgument('variables');
to
// Get settings.
$defined_view = $variable->getSettings('view');
$view_fields = $variable->getSettings('view_html');
$args = $variable->getSettings('arguments') ?? "";
$event_variables = $event->getArgument('variables');
Remaining tasks
Validate the proposed fix.
User interface changes
None.
API changes
None.
Data model changes
None.