Loading
bug: #3629878: Debug mode calls non-existent LoggerChannel::dump() and causes a fatal error
Problem
With Devel enabled and Debug Mode checked, evaluateExpression() calls \Drupal::logger('field_token_expression_debug')->dump($debug). LoggerChannel has no dump() method, so saving the entity, or rendering it with Always Evaluate Expression? enabled, ends in a fatal error. The call replaced dpm() in the Drupal 11 upgrade, so 2.0.3 and 2.1.0 are affected.
Changes
ExpressionItemandExpressionItemTrait: the call is replaced with\Drupal::service('devel.dumper')->message($debug, 'Field Token Expression Debug Output'), the service thatdpm()wraps. It stays behind the existingmoduleExists('devel')check, and the misleading// Use logger()->dump() for debugging.comment is removed.ExpressionItem: the Token Replaced Expression entry now shows the expression before blank spaces are removed, asExpressionItemTraitalready does. Spaces are still stripped from the string passed to EvalMath, so results do not change. Before this, the legacy type showed3*3while the 2.x types showed2 + 2(this difference predates 2.0.3).
Testing
Drupal 11.4.8, PHP 8.4, Devel 5.5.0, tested with a Drush script that saves a node as user 1:
- Before the change: the save fails with
Error: Call to undefined method Drupal\Core\Logger\LoggerChannel::dump(). - After the change: the node saves, and the original expression, the token replaced expression and the result are shown as a status message for both
expression_integer(2 + 2, result 4) and the legacyfield_expressiontype (1 000 + 2, result 1002). phpcs --standard=Drupal,DrupalPracticereports no errors.
Closes #3629878
Edited by Orkut Murat Yılmaz