Skip to content

fix: array thumbnail parameter in getImageThumbnailAction#78

Merged
solverat merged 1 commit into
open-dxp:1.xfrom
marcopixel:fix/thumbnail-config-array
May 19, 2026
Merged

fix: array thumbnail parameter in getImageThumbnailAction#78
solverat merged 1 commit into
open-dxp:1.xfrom
marcopixel:fix/thumbnail-config-array

Conversation

@marcopixel
Copy link
Copy Markdown
Contributor

Changes in this pull request

Fix getImageThumbnailAction crash when thumbnail query param is an array.

PR #39 replaced $request->get() with $request->query->get() across controllers to address the Symfony 7.4 deprecation. That was correct in general, but thumbnail is a special case: it accepts both a string (named config) and an array (inline config). InputBag::get() throws BadRequestException for non-scalar values since Symfony 5.1+, so the array case broke.

This can be easily triggered by declaring a dynamic configuration inside twig:

{{ opendxp_image('test_image', {
        'thumbnail': {
            'width': 500,
            'aspectratio': true,
            'interlace': true,
            'quality': 85,
            'format': 'png'
        }
}) }}
Symfony\Component\HttpFoundation\Exception\BadRequestException:
Input value "thumbnail" contains a non-scalar value.

  at vendor/symfony/http-foundation/InputBag.php:46
  at Symfony\Component\HttpFoundation\InputBag->get('thumbnail')
     (vendor/open-dxp/admin-bundle/src/Controller/Admin/Asset/AssetController.php:1171)
  at OpenDxp\Bundle\AdminBundle\Controller\Admin\Asset\AssetController->getImageThumbnailAction(object(Request))
     (vendor/symfony/http-kernel/HttpKernel.php:183)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:76)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:193)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:32)
  at require_once('/var/www/html/vendor/autoload_runtime.php')
     (public/index.php:17)               

Fix:
Read via ->all()['thumbnail'] ?? null which bypasses the scalar restriction and handles both value shapes without throwing.

Changes:

  • AssetController::getImageThumbnailAction: replace ->get('thumbnail') with ->all()['thumbnail'] ?? null
  • Add GetImageThumbnailQueryParamTest

InputBag::get() throws BadRequestException for non-scalar values since
Symfony 5.1+. The thumbnail param accepts both a string (named config)
and an array (inline config), so ->get() breaks the array case.
->all()['thumbnail'] ?? null bypasses the scalar restriction and handles
both shapes without throwing.
@solverat solverat self-assigned this May 18, 2026
@solverat solverat added the bug Something isn't working label May 18, 2026
@solverat solverat added this to the 1.3.3 milestone May 18, 2026
@solverat solverat self-requested a review May 19, 2026 09:27
@solverat solverat merged commit e02e8fd into open-dxp:1.x May 19, 2026
13 checks passed
@solverat
Copy link
Copy Markdown
Contributor

thanks @marcopixel!

@github-actions github-actions Bot locked and limited conversation to collaborators May 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants