Uncaught PHP Exception TypeError: "Drupal\\Core\\Render\\Renderer::doTrustedCallback()

Created on 8 September 2023, over 1 year ago
Updated 11 September 2023, over 1 year ago

Problem/Motivation

When updated from drupal 9.5.10 to 10.1.2 local site is working perfectly fine but when the configurations moved to AWS ECS (serverless with Docker file) I got the below issue only in AWS

[php:Error] [pid 39] [client 10.80.35.171:34724] Uncaught PHP Exception TypeError: "Drupal\\Core\\Render\\Renderer::doTrustedCallback(): Argument #1 ($callback) must be of type callable, array given, called in /opt/drupal/web/web/core/lib/Drupal/Core/Render/Renderer.php on line 788" at /opt/drupal/web/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php line 57

Steps to reproduce

I have the drupal project with version 9.5.1 and with php version - 8.1.23 and I am using ddev to work locally
I have upgraded the required modules to drupal 10 compatible and updated the drupal core to 10.1.2 using composer and did the drush updb and exported all those configuartions as yml files

Pushed the code to Repo
Updated the Docker file as well with the Docker image mentioned below as I am using AWS ECS (FARGATE) which takes Docker images and with the Azure pipeline it will create a docker Image and push to aws ECR and the pipeline will create a stack (means container) and as my code is already part of docker image and now its creating the health checks by AWS before doing drush cim as its getting the mentioned error and health check giving 400 error which build got aborted and the container reverts to previous version

This is not happening in my local ddev and also with docker created an image and tested but no issues with that

[php:Error] [pid 39] [client 10.80.35.171:34724] Uncaught PHP Exception TypeError: "Drupal\\Core\\Render\\Renderer::doTrustedCallback(): Argument #1 ($callback) must be of type callable, array given, called in /opt/drupal/web/web/core/lib/Drupal/Core/Render/Renderer.php on line 788" at /opt/drupal/web/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php line 57

Tried the below patch but still a different error
https://www.drupal.org/project/drupal/issues/3224723 ๐Ÿ’ฌ Issue with doTrustedCallback() must be array Postponed: needs info

FROM drupal:10

RUN apt-get update && \
    apt-get install -y git curl && \
    rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install mysqli

# Updating the max filesize in php.ini
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini && \
    sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 130M/g' /usr/local/etc/php/php.ini && \
    sed -i 's/post_max_size = 8M/post_max_size = 140M/g' /usr/local/etc/php/php.ini && \
    sed -i 's/max_execution_time = 30/max_execution_time = 600/g' /usr/local/etc/php/php.ini

# Create the logs directory and drupal.log file
RUN chown -R www-data:www-data /var/log/; chmod -R 777 /var/log/

RUN touch /var/log/drupal.log; chmod 777 /var/log/drupal.log

# Copy Application code
COPY . /var/www/html/

# Run Composer (Install Drupal Dependencies)
RUN cd /var/www/html; composer install

RUN apt-get update && apt-get install -y \
    software-properties-common \
    npm
RUN npm install npm@9.2.0 -g && \
    npm install n -g && \
    n latest
# Running npm build
RUN cd /var/www/html; npm install; npm run production

# Apache conf
# allow .htaccess with RewriteEngine
RUN a2enmod rewrite
# without the following line we get "AH00558: apache2: Could not reliably determine the server's fully qualified domain name"
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
# autorise .htaccess files
RUN sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
# for production :
RUN echo "ServerTokens Prod\n" >> /etc/apache2/apache2.conf
RUN echo "ServerSignature Off\n" >> /etc/apache2/apache2.conf

#Setting Error page
RUN echo "ErrorDocument 403 /access-denied" >> /var/www/html/web/.htaccess

#Setting Rewrite rules
RUN echo "RewriteEngine On\nRewriteRule ^themes/README\.txt$ / [R=301,L]" >> /var/www/html/web/.htaccess

RUN echo "RewriteEngine On\nRewriteRule ^sites/README\.txt$ / [R=301,L]" >> /var/www/html/web/.htaccess

RUN echo "RewriteEngine On\nRewriteRule ^modules/README\.txt$ / [R=301,L]" >> /var/www/html/web/.htaccess

WORKDIR /var/www/html/web
CMD ["/bin/sh", "-c", "/usr/sbin/apachectl -D FOREGROUND & tail -f /var/log/drupal.log"]
ENV APACHE_DOCUMENT_ROOT=/var/www/html/web
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
EXPOSE 80 443

This issue is happening in AWS but not in my local not sure why this is happening
My drupal version - 10.1.2
PHP - 8.2

Proposed resolution

Should fix that callback

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ’ฌ Support request
Status

Closed: duplicate

Version

10.1 โœจ

Component
Renderย  โ†’

Last updated about 2 hours ago

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia santhosh@21

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

Comments & Activities

Production build 0.71.5 2024