Drupal 9.0.2
PHP 7.4.8

Error:
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\imce\ImceFileField::preRenderWidget. See https://www.drupal.org/node/2966725 in Drupal\Core\Render\Renderer->doTrustedCallback() (line 96 of /usr/local/var/www/local.daisy_d9/daisyfoundation.org/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php).

Steps:
Install module via composer
enable module from extend page
manage form display for an image field to enable users to use imce
Attempt to go to a content item that has imce enabled

Reviewed: https://www.drupal.org/node/2966725

To get around the issue I made the following change to the module. I've never made a patch file before, but wanted to share the edits in case someone wants to make a patch or runs into the issue.

File: ImceFileField.php
class ImceFileField implements TrustedCallbackInterface {
public static function trustedCallbacks() {
return ['preRenderWidget'];
}

Comments

watson.sm created an issue. See original summary.

thalles’s picture

Category: Bug report » Support request
thalles’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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