Problem/Motivation

Using Drupal 9 when creating a context with block reaction, I have the error below:

Drupal\Core\Security\UntrustedCallbackException: Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was Drupal\context\Plugin\ContextReaction\Blocks::preRenderBlock. See https://www.drupal.org/node/2966725 in Drupal\Core\Render\Renderer->doTrustedCallback() (line 96 of core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php).

Proposed resolution

The Blocks must implement the TrustedCallbackInterface.

See record changes: https://www.drupal.org/node/2966725

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

paulocs created an issue. See original summary.

paulocs’s picture

Issue summary: View changes
paulocs’s picture

Status: Needs work » Needs review
FileSize
1.2 KB

Follow a patch.

paulocs’s picture

Assigned: paulocs » Unassigned
MaxMendez’s picture

Thanks for patch, i've installed it on Drupal 9.0.2 and fixed the problem.

paulocs’s picture

New patch because it is needed to update the context.info.yml file as TrustedCallbackInterface was introduced in Drupal 8.8 version

paulocs’s picture

Status: Needs review » Fixed

Fixed in dev branch!

  • paulocs committed a9ed151 on 8.x-4.x
    Issue #3158830 by paulocs, MaxMendez: Render #pre_render callbacks must...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.