I have seen a large amount of errors like this during a file migration:
[error] File at 'public://some-path/some-file.jpg' does not exist (plugin: imagemagick_identify) (method: loadMetadataFromFile)
I discovered that, while the GD library does not log an error if an image is not found, this module does. In Drupal to Drupal migrations with a large amount of files it is sometimes better to migrate the database and then rsync the files from the source to the destination. This means that there are no files in the file system during the migration which causes that if this module is enabled and set as the image toolkit, then every image being processed will throw an error.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3030830-stop-logging-when-file-does-not-exist-9.patch | 1.02 KB | masterperoo |
| #8 | 3030830-stop-logging-when-file-does-not-exist-8.patch | 560 bytes | alayham |
| #2 | file_mdm-mising_file_errors-3030820-2.patch | 362 bytes | juampynr |
Issue fork file_mdm-3030820
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
juampynr commentedHere is a patch that removes the statement that logs an error.
Comment #3
mondrakeTo be honest I do not think this is appropriate, it'd just hide a problem occurring upstream.
I am not familiar with migrate, but if we end up here most likely it's because an Image object is opened, with a background Imagemagick toolkit, on a non-existing image file. But in that case (either GD or Imagemagick, anyway), the Image object will be invalidated. So either migrate is trying to read image metadata, and is therefore failing to migrate some information, or is doing nothing with the metadata, so it's doing an unnecessary operation. For both cases I think the case of 'migrating a file that does not exist' should be handled upstream in migrate code.
Comment #4
twiik commentedGetting this error is easily reproducible through the use of the https://www.drupal.org/project/stage_file_proxy module at least, especially if you configured it to not download the original images, but instead only the derivates. Then it will happen for every image on every page load if you have image styles that rely on metadata.
No idea if this patch is the appropriate way to fix this, but it's an easy fix for me at least.
Comment #5
piotrkonefal commented@TwiiK correct. This is happening when stage_file_proxy is enabled with an option to not download the original images. I created a D.O. issue for this some time ago (https://www.drupal.org/project/imagemagick/issues/3254511), but honestly I don't know what would be the best approach to handle this.
Comment #8
alayham commentedUpdated the patch for the new release.
Comment #9
Deithso@alayham the issue's number (id) in your patch is incorrect its 3030820 not 3030830
Comment #10
masterperoo commentedIt looks as if nowadays we are dealing with two separate warnings while using imagemagick.
One being
Error getting supported keys for @metadata
this was addressed by patch 8
another
Error getting imagemagick_identify metadata
Attached is a patch addressing both of them.
Still -something for the maintainer to sort out
Comment #13
dieterholvoet commentedI created a new branch & MR with a different approach: instead of not catching the exception anymore, we just shouldn't throw it in the first place. The execution doesn't have to stop when the file is not found: e.g.
\Drupal\Core\Image\Image::$fileSizecan handle being assigned a NULL value by the filesize() function.Drupal\Core\Image\ImageInterface::getFileSize()indicates the same thing in its return value documentation: The size of the file in bytes, or NULL if the image is invalid..The ImageMagick module can also handle
Drupal\file_mdm\FileMetadataInterface::getMetadata()returning NULL:If we really want to log it, an error log would be a better choice than an exception, but I would make that logging optional through a setting in the module. For me personally, and apparently a lot of other people, these kind of errors are not really relevant.
Comment #14
dieterholvoet commentedSeems like 1.x is not supported anymore, changing the base branch to 2.x.
Comment #15
dieterholvoet commentedI added a new setting to control the log level with which this error will be logged, together with the ability to not log the error at all. I'll add an update hook to set this value to the error log level for backwards compatibility reasons, but what should the default log level for new installations be? I'll set that to error as well for now.
Comment #16
dieterholvoet commentedIf you're testing this in combination with the ImageMagick module, make sure to include the patch from #3330803: Fix subclassing and stop overriding constructors.
Comment #17
mondrakeThanks for working on this!
TIL how to avoid extending constructors!
I like the idea of a UI setting for the missing file error logging. However I think the implementation should be a bit different, see details in inline comments in the MR.
We also would need tests here.
Comment #18
dieterholvoet commentedSince the change to
Drupal\file_mdm_exif\Plugin\FileMetadata\Exifis no longer necessary, I created a separate issue for that: #3331098: Fix subclassing and stop overriding constructors.Comment #19
dieterholvoet commentedProcessed your feedback, resulting in a much simpler solution. Thanks! I'm going to pass for the tests for now since I'm not very experienced in that area.
Comment #21
mondrakeComment #22
mondrakeMoving to the 3.0.x branch.
Comment #24
mondrake