MIME type to file extension mapping is perfomed by an ugly workaround in ImagemagickMimeTypeMapper.

I just published a standalone fileeye/mimemap package that inherits from pear/mime_type, and is focused on providing that mapping.

Use it and drop the workaround; port to 8.x-2.x for deprecation once fileeye/mimemap is stable.

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Status: Active » Needs review
StatusFileSize
new8.84 KB

Patch

mondrake’s picture

Title: Adopt filieeye/mimemap » Adopt fileeye/mimemap

Status: Needs review » Needs work

The last submitted patch, 2: 3026733-2.patch, failed testing. View results

mondrake’s picture

Status: Needs work » Needs review
StatusFileSize
new8.83 KB

Adjustment for fileeye/mimemap 1.0.0-alpha3

  • mondrake committed dedf920 on 8.x-3.x
    Issue #3026733 by mondrake: Adopt fileeye/mimemap
    
mondrake’s picture

Version: 8.x-3.x-dev » 8.x-2.x-dev
Status: Needs review » Patch (to be ported)

Committed to 8.x-3.x. To be ported to 8.x-2.x for deprecation of ImagemagickMimeTypeMapper.

mondrake’s picture

Version: 8.x-2.x-dev » 8.x-3.x-dev

Need to adjust for fileeye/mimemap 1.0.0-beta1

mondrake’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new10.87 KB

  • mondrake committed ac1a0c7 on 8.x-3.x
    Issue #3026733 by mondrake: Adjust to fileeye/mimemap 1.0.0-beta1
    
mondrake’s picture

Version: 8.x-3.x-dev » 8.x-2.x-dev
Status: Needs review » Patch (to be ported)
mondrake’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new15.17 KB

Here's the backport, now fileeye/mimemap has its first stable release.

Status: Needs review » Needs work

The last submitted patch, 12: 3026733-12.patch, failed testing. View results

mondrake’s picture

Status: Needs work » Needs review
StatusFileSize
new15.17 KB
new700 bytes

No deprecations reported in contrib tests, yet.

mondrake’s picture

StatusFileSize
new17.08 KB
new6.59 KB

Added deprecation triggers.

  • mondrake committed 92711e7 on 8.x-2.x
    Issue #3026733 by mondrake: Adopt fileeye/mimemap
    
mondrake’s picture

Status: Needs review » Fixed

Committed to 8.x-2.x.

mondrake’s picture

Issue summary: View changes
jonasdk’s picture

After upgrading to 2.4 going to the status page (/admin/reports/status) creates this message:

The website encountered an unexpected error. Please try again later.
Error: Class 'FileEye\MimeMap\Type' not found in Drupal\imagemagick\ImagemagickFormatMapper->resolveEnabledFormats() (line 191 of modules/contrib/imagemagick/src/ImagemagickFormatMapper.php).
Drupal\imagemagick\ImagemagickFormatMapper->resolveEnabledFormats() (Line: 225)
Drupal\imagemagick\ImagemagickFormatMapper->resolveEnabledExtensions() (Line: 166)
Drupal\imagemagick\ImagemagickFormatMapper->getEnabledExtensions() (Line: 1407)
Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit::getSupportedExtensions() (Line: 1365)
Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit->getRequirements() (Line: 46)
image_requirements('runtime')
call_user_func_array('image_requirements', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('requirements', Array) (Line: 112)
Drupal\system\SystemManager->listRequirements() (Line: 49)
Drupal\system\Controller\SystemInfoController->status()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I have tried the normal remedies like clearing cache and update db.

mondrake’s picture

Can you try a composer show on Drupal root, and see if it shows fileeye/mimemap

...
fabpot/goutte                         v3.2.3             A simple PHP Web Scraper
fileeye/mimemap                       1.0.0              A PHP library to handle MIME Content-Type fields and their related file extensi...
guzzlehttp/guzzle                     6.3.3              Guzzle is a PHP HTTP client library
...
fonant’s picture

Mine, updated using drush, didn't.

The command composer require fileeye/mimemap sorted the problem for me.

Looks like I need to use composer for the imagemagick module...

mondrake’s picture

Not a drush user, sorry...

Yes, the composer way to update the module, if already installed, is

composer update drupal/imagemagick

or to install anew

composer require drupal/imagemagick:^2.4

That will also bring in the required dependencies, fileeye/mimemap being one of them.

sachariew’s picture

Have the same problem as #19. But on shared hosting without drush/composer. Could you advice me which module/library to put where in order for this to work?

Thanks a lot!

mondrake’s picture

Re #23

From the project page:

Requirements

Installation

  • ...
  • Versions 8.x-2.x: Require the module via Composer
    $ composer require drupal/imagemagick:~2.0
    

    then enable the module as usual. If your build cannot use Composer, an earlier alpha-level release 8.x-1.x-alpha6 is generally working, but no longer supported.

sachariew’s picture

Right, so Drupal is not usable without composer anymore? Wasn't there a discussion some time ago, that Drupal should not lose all those who use shared hosting? I know that I can keep the module at the previous version, but someday there will be a security vulnerability preventing me from using older versions. And there are other modules, that might implement imagemagick, but not as well supported and maintained. So, I don't want to sound rude and I am grateful for the work being done here. I can't code php myself. It's just that it is a pity, that the move to composer leaves many users and use cases behind. Ok, I should be able to use composer locally, but still. A pity. :-(

jens peter’s picture

Just ran a standard update and now my site is broke as the ImageMagick now needs Composer for dependencies and was not warned clearly enough on the update page.
I have no clue on what to do now.
Any idea?
I got a very long list of errors, I can only get to a few pages of the administrations menu and almost none of the content pages of the site.

THis is really not a good way to upgrade between minor versions.

ressa’s picture

You could create an issue, requesting Ludwig integration (like Address module has) as an alternative to Composer?

sachariew’s picture

@Jens Peter: Just downgrade to previous version. Seems to work without problems on my site...

jens peter’s picture

@Sachariew thank you. I did just that and it solved the issue.
I still think it is wrong to make a standard update with a change this big as I now have a module not updated and cannot be updated because dependencies are not listed - for the lifetime of this site, I am forced to ignore this one module update.

@ressa Good idea, I have not head about the Ludwig module before. I will give it a test.
Interesting to be able to do updates like this - should be developed as standard function in Drupal and not as a module developers need to set each module up for. It should be possible to update every installation without the need for extra modules or developer styled commands - this way push users away from using Drupal more than include more to our world.

jjmackow’s picture

Thanks @fonant #21. I had updated modules through the admin UI, among which was the latest ImageMagic update here, and wound up with the error showing up after attempting to edit content types that relied on Image fields on the site.
I, fortunately, do use composer, and was able to quickly fix my issue with your suggestion of running from the instance's webroot directory,

composer require fileeye/mimemap

Status: Fixed » Closed (fixed)

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

mondrake’s picture

hongpong’s picture

Ludwig is the way to go here for ducking composer problems including on Pantheon. see #3035270: ImageMagick - Ludwig integration

Eduardo Alvarez’s picture

StatusFileSize
new1.25 KB

Just in case this might be usefull to someone I left here some instructions to have this working without composer.

The idea is to download the PHP library (https://github.com/FileEye/MimeMap) to ./vendor/fileeye/mimemap within the Drupal directory.

And then apply the patch attached to update the autoload.

devad’s picture

@mondrake, please change this issue to "Closed as duplicate" of:
#3035270: ImageMagick - Ludwig integration

So that users can go to the solution-seeking issue.