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. <strong>The callback was Drupal\imce\ImceFileField::preRenderWidget</strong>. See https://www.drupal.org/node/2966725 in Drupal\Core\Render\Renderer->doTrustedCallback() (line 96 of /srv/www/htdocs/kacb9/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php).

This is on Drupal 9.0 on a Linux platform. Help please.
Sorry, I submitted two of these by accident. See no way to remove a duplicate!

Comments

tjtj created an issue. See original summary.

tjtj’s picture

Issue summary: View changes
hodowany’s picture

StatusFileSize
new753 bytes

I followed the advice from the error message and copied the procedure outlined in https://www.drupal.org/node/2966725 to change the preRenderWidget callback to implement the TrustedCallbackInterface interface. The modification is on the class ImceFileField in the file

/modules/imce/src/ImceFileField.php

class declaration is changed to:

class ImceFileField implements TrustedCallbackInterface {

then add the trusted callback method inside the class

public static function trustedCallbacks() {
return ['preRenderWidget'];
}

That's it. Security error gone. I will attach a diff/patch file below.

thalles’s picture

Issue summary: View changes
chekka.de’s picture

Thanks, works fine!

tjtj’s picture

Yes,, thank you!

thalles’s picture

How can I reproduce this message?

thalles’s picture

Status: Active » Needs review
thalles’s picture

StatusFileSize
new677 bytes

Follow a new patch, the #3 was not applyed to me

  • thalles committed d67c743 on 8.x-2.x
    Issue #3149697 by thalles, hodowany, tjtj, chekka.de: php security error...
thalles’s picture

Thanks @all for your help!

thalles’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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