TypeError in ContextualImageStyleDownloadController::process()

Created on 21 March 2025, 17 days ago

Problem/Motivation

We are receiving an Exception 'TypeError' and it is showing up a lot in our logs. It seems to be acting as if `strict_types=1` was set. Locally, if I add `strict_types=1` to that file I get the full WSOD error. My site is hosted on Acquia, so not sure exactly why it is treating as such, but maybe they are doing something to enforce strict types?? Not sure though.

Steps to reproduce

Add `declare(strict_types=1);` to ContextualImageStyleDownloadController file, and you will see the error when you have overrides on a field.

Proposed resolution

I'm curious if the maintainers have a preferred solution, but a quick fix would be to allow string and convert to an int within `process()`. We could also add more to the route itself to verify, but quick testing Symfony's argument resolver does not enforce it as an it, when it finally gets passed to the controller.

Remaining tasks

I'm working on opening up a MR, however I can see a few possible solutions. Maintainers, if you have a preferred solution, I can work towards that...

  • fix it?

Full Error

 in Drupal\media_contextual_crop\Controller\ContextualImageStyleDownloadController::process called at ? (?)
 in call_user_func_array called at /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php (123)
 in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::Drupal\Core\EventSubscriber\{closure} called at /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php (638)
 in Drupal\Core\Render\Renderer::executeInRenderContext called at /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php (121)
 in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext called at /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php (97)
 in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::Drupal\Core\EventSubscriber\{closure} called at /var/www/html/vendor/symfony/http-kernel/HttpKernel.php (181)
 in Symfony\Component\HttpKernel\HttpKernel::handleRaw called at /var/www/html/vendor/symfony/http-kernel/HttpKernel.php (76)
 in Symfony\Component\HttpKernel\HttpKernel::handle called at /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php (53)
 in Drupal\Core\StackMiddleware\Session::handle called at /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php (48)
 in Drupal\Core\StackMiddleware\KernelPreHandle::handle called at /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/ContentLength.php (28)
 in Drupal\Core\StackMiddleware\ContentLength::handle called at /var/www/html/docroot/modules/contrib/shield/src/ShieldMiddleware.php (263)
 in Drupal\shield\ShieldMiddleware::bypass called at /var/www/html/docroot/modules/contrib/shield/src/ShieldMiddleware.php (130)
 in Drupal\shield\ShieldMiddleware::handle called at /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php (48)
 in Drupal\Core\StackMiddleware\ReverseProxyMiddleware::handle called at /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php (51)
 in Drupal\Core\StackMiddleware\NegotiationMiddleware::handle called at /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php (36)
 in Drupal\Core\StackMiddleware\AjaxPageState::handle called at /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php (51)
 in Drupal\Core\StackMiddleware\StackedHttpKernel::handle called at /var/www/html/docroot/core/lib/Drupal/Core/DrupalKernel.php (741)
 in Drupal\Core\DrupalKernel::handle called at /var/www/html/docroot/index.php (19)
πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States pingevt

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

Merge Requests

Comments & Activities

  • Issue created by @pingevt
  • πŸ‡ΊπŸ‡ΈUnited States pingevt

    After diving in a lot further... the error is being triggered by a bad url... `/sites/default/files/contextual/styles/1x1__image_scale_and_crop__sm/public/2024-12`. I don't think the module is responsible for the url, but the route just needs pattern validation on context route parameter.

  • Merge request !13Only allow numeric values for {context} β†’ (Merged) created by pingevt
  • Pipeline finished with Success
    17 days ago
    Total: 140s
    #454340
Production build 0.71.5 2024