Strange error message in Renderer

Created on 18 January 2024, 11 months ago

I'm having this problem https://www.drupal.org/project/workflow/issues/3415585 ๐Ÿ› Route "entity.workflow_state.canonical" does not exist Active in Drupal 10.2.1, and a very strange error message is generated halfway the stacktrace:

Drupal\Core\Utility\LinkGenerator->generate('Creatie', Object) (Line: 102)
Drupal\Core\Render\Element\Link::preRenderLink(Array)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725 โ†’ ', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 858)

The %s in the message looks strange. Looking at the code in Drupal\Core\Render\Renderer (method below). The %s is a parameter value, which looks strange. This error message could be improved upon.

  protected function doCallback($callback_type, $callback, array $args) {
    $callable = $this->callableResolver->getCallableFromDefinition($callback);
    $message = sprintf('Render %s callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', $callback_type, '%s');
    // Add \Drupal\Core\Render\Element\RenderCallbackInterface as an extra
    // trusted interface so that:
    // - All public methods on Render elements are considered trusted.
    // - Helper classes that contain only callback methods can implement this
    //   instead of TrustedCallbackInterface.
    return $this->doTrustedCallback($callable, $args, $message, TrustedCallbackInterface::THROW_EXCEPTION, RenderCallbackInterface::class);
  }
๐Ÿ› Bug report
Status

Active

Version

10.2 โœจ

Component
Renderย  โ†’

Last updated about 12 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024