sonata-project / SonataMediaBundle

Symfony SonataMediaBundle
https://docs.sonata-project.org/projects/SonataMediaBundle
MIT License
449 stars 496 forks source link

Error 500 when uploading svg files as image #1580

Closed vkhramtsov closed 4 years ago

vkhramtsov commented 5 years ago

Hello

Environment

Sonata packages

sonata-project/admin-bundle              3.48.0 3.48.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.15.0 3.15.0 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  2.0.1  Cache library
sonata-project/core-bundle               3.16.2 3.16.2 Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.5.0  3.0.0  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.2.0  1.2.0  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.8.3  3.8.3  Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle       2.5.0  2.5.0  Symfony SonataEasyExtendsBundle
sonata-project/exporter                  2.0.1  2.0.1  Lightweight Exporter library
sonata-project/media-bundle              3.19.1 3.19.1 Symfony SonataMediaBundle
sonata-project/media-orm-pack            1.0.0  1.0.0  A pack for SonataMediaBundle with ORM support
sonata-project/translation-bundle        2.4.1  2.4.1  SonataTranslationBundle

Symfony packages

Restricting packages listed in "symfony/symfony" to "4.2.*"
symfony/asset                 v4.2.4  v4.2.4  Symfony Asset Component
symfony/browser-kit           v4.2.4  v4.2.4  Symfony BrowserKit Component
symfony/cache                 v4.2.4  v4.2.4  Symfony Cache component with PSR-6, PSR-16, and tags
symfony/config                v4.2.4  v4.2.4  Symfony Config Component
symfony/console               v4.2.4  v4.2.4  Symfony Console Component
symfony/contracts             v1.0.2  v1.0.2  A set of abstractions extracted out of the Symfony components
symfony/css-selector          v4.2.4  v4.2.4  Symfony CssSelector Component
symfony/debug                 v4.2.4  v4.2.4  Symfony Debug Component
symfony/debug-bundle          v4.2.4  v4.2.4  Symfony DebugBundle
symfony/debug-pack            v1.0.7  v1.0.7  A debug pack for Symfony projects
symfony/dependency-injection  v4.2.4  v4.2.4  Symfony DependencyInjection Component
symfony/doctrine-bridge       v4.2.4  v4.2.4  Symfony Doctrine Bridge
symfony/dom-crawler           v4.2.4  v4.2.4  Symfony DomCrawler Component
symfony/dotenv                v4.2.4  v4.2.4  Registers environment variables from a .env file
symfony/event-dispatcher      v4.2.4  v4.2.4  Symfony EventDispatcher Component
symfony/expression-language   v4.2.4  v4.2.4  Symfony ExpressionLanguage Component
symfony/filesystem            v4.2.4  v4.2.4  Symfony Filesystem Component
symfony/finder                v4.2.4  v4.2.4  Symfony Finder Component
symfony/flex                  v1.2.0  v1.2.0  Composer plugin for Symfony
symfony/form                  v4.2.4  v4.2.4  Symfony Form Component
symfony/framework-bundle      v4.2.4  v4.2.4  Symfony FrameworkBundle
symfony/http-foundation       v4.2.4  v4.2.4  Symfony HttpFoundation Component
symfony/http-kernel           v4.2.4  v4.2.4  Symfony HttpKernel Component
symfony/inflector             v4.2.4  v4.2.4  Symfony Inflector Component
symfony/intl                  v4.2.4  v4.2.4  A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/maker-bundle          v1.11.5 v1.11.5 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.
symfony/monolog-bridge        v4.2.4  v4.2.4  Symfony Monolog Bridge
symfony/monolog-bundle        v3.3.1  v3.3.1  Symfony MonologBundle
symfony/options-resolver      v4.2.4  v4.2.4  Symfony OptionsResolver Component
symfony/orm-pack              v1.0.6  v1.0.6  A pack for the Doctrine ORM
symfony/panther               v0.3.0  v0.3.0  A browser testing and web scraping library for PHP and Symfony.
symfony/phpunit-bridge        v4.2.4  v4.2.4  Symfony PHPUnit Bridge
symfony/polyfill-intl-icu     v1.11.0 v1.11.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn     v1.11.0 v1.11.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring     v1.11.0 v1.11.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72        v1.11.0 v1.11.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/process               v4.2.4  v4.2.4  Symfony Process Component
symfony/profiler-pack         v1.0.4  v1.0.4  A pack for the Symfony web profiler
symfony/property-access       v4.2.4  v4.2.4  Symfony PropertyAccess Component
symfony/property-info         v4.2.4  v4.2.4  Symfony Property Info Component
symfony/requirements-checker  v1.1.4  v1.1.4  Check Symfony requirements and give recommendations
symfony/routing               v4.2.4  v4.2.4  Symfony Routing Component
symfony/security-acl          v3.0.1  v3.0.1  Symfony Security Component - ACL (Access Control List)
symfony/security-bundle       v4.2.4  v4.2.4  Symfony SecurityBundle
symfony/security-core         v4.2.4  v4.2.4  Symfony Security Component - Core Library
symfony/security-csrf         v4.2.4  v4.2.4  Symfony Security Component - CSRF Library
symfony/security-guard        v4.2.4  v4.2.4  Symfony Security Component - Guard
symfony/security-http         v4.2.4  v4.2.4  Symfony Security Component - HTTP Integration
symfony/serializer            v4.2.4  v4.2.4  Symfony Serializer Component
symfony/serializer-pack       v1.0.2  v1.0.2  A pack for the Symfony serializer
symfony/stopwatch             v4.2.4  v4.2.4  Symfony Stopwatch Component
symfony/swiftmailer-bundle    v3.2.5  v3.2.5  Symfony SwiftmailerBundle
symfony/templating            v4.2.4  v4.2.4  Symfony Templating Component
symfony/test-pack             v1.0.5  v1.0.5  A pack for functional and end-to-end testing within a Symfony app
symfony/translation           v4.2.4  v4.2.4  Symfony Translation Component
symfony/twig-bridge           v4.2.4  v4.2.4  Symfony Twig Bridge
symfony/twig-bundle           v4.2.4  v4.2.4  Symfony TwigBundle
symfony/validator             v4.2.4  v4.2.4  Symfony Validator Component
symfony/var-dumper            v4.2.4  v4.2.4  Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter          v4.2.4  v4.2.4  A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-link              v4.2.4  v4.2.4  Symfony WebLink Component
symfony/web-profiler-bundle   v4.2.4  v4.2.4  Symfony WebProfilerBundle
symfony/web-server-bundle     v4.2.4  v4.2.4  Symfony WebServerBundle
symfony/webpack-encore-bundle v1.3.0  v1.3.0  Integration with your Symfony app & Webpack Encore!
symfony/yaml                  v4.2.4  v4.2.4  Symfony Yaml Component

PHP version

PHP 7.2.16-1+0~20190307202415.17+stretch~1.gbpa7be82 (cli) (built: Mar  7 2019 20:24:15) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.16-1+0~20190307202415.17+stretch~1.gbpa7be82, Copyright (c) 1999-2018, by Zend Technologies

Subject

I have error 500 when trying to upload svg using image provider in prod mod. In dev mod I see \RuntimeException with message An image could not be created from the given input.

Steps to reproduce

Install and configure sonata admin with media bundle and try to upload svg image (actually it is text, not image)

Expected results

Validation error

Actual results

Error 500

Trace

in vendor/imagine/imagine/lib/Imagine/Gd/Imagine.php (line 190)
in vendor/imagine/imagine/lib/Imagine/Gd/Imagine.php->doLoad (line 107)
in vendor/sonata-project/media-bundle/src/Resizer/SimpleResizer.php->load (line 62)
in vendor/sonata-project/media-bundle/src/Thumbnail/FormatThumbnail.php->resize (line 124)
in vendor/sonata-project/media-bundle/src/Provider/BaseProvider.php->generate (line 146)
in vendor/sonata-project/media-bundle/src/Provider/FileProvider.php->generateThumbnails (line 167)
in vendor/sonata-project/media-bundle/src/Listener/BaseMediaEventSubscriber.php->postPersist (line 79)
in vendor/symfony/doctrine-bridge/ContainerAwareEventManager.php->postPersist (line 61)
in vendor/doctrine/orm/lib/Doctrine/ORM/Event/ListenersInvoker.php->dispatchEvent (line 117)
in vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php->invoke (line 1103)
in vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php->executeInserts (line 386)
in vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php->commit (line 359)
in vendor/sonata-project/doctrine-orm-admin-bundle/src/Model/ModelManager.php->flush (line 176)
in vendor/sonata-project/admin-bundle/src/Admin/AbstractAdmin.php->update (line 670)
in vendor/sonata-project/admin-bundle/src/Controller/CRUDController.php->update (line 355)
in vendor/symfony/http-kernel/HttpKernel.php->editAction (line 150)
in vendor/symfony/http-kernel/HttpKernel.php->handleRaw (line 67)
in vendor/symfony/http-kernel/Kernel.php->handle (line 198) 

Additions:

[Zend Modules] Zend OPcache



In case you need any additional data, don't hesitate to ask.
kunicmarko20 commented 5 years ago

It never worked with .svg https://gist.github.com/kunicmarko20/0af5e61510a68706ecbf658c0c690b8a this is how I did it last time I did it.

vkhramtsov commented 5 years ago

It is also does not work, with file also. Actually it is bug about handling non images uploads

vkhramtsov commented 5 years ago

@kunicmarko20 Moreover, it saves txt files without issues, but svg files only without extension. Sad but true. Would you be so kind to update your gist? Thank you in advance

scasei commented 4 years ago

@vkhramtsov My system stores XML-files without extension and produces HTTP-500 any idea?

vkhramtsov commented 4 years ago

@scasei Unfortunately no. We solved this issue by using adjusted code from gist. It looks like it needs some time for investigation and create PR for solving this issue

scasei commented 4 years ago

@vkhramtsov thank you for your feedback, my installation is based on symfony 4.2 and since the media module uses the extension guesser from http-foundation bundle, i updated to 4.4. Seems to work now, extension is now visible.

vkhramtsov commented 4 years ago

I cannot recheck this, but according to your comment, everything works now. I'm going to close this ticket