Hello
When I modify a view, I get this error:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "lazy_image" plugin does not exist. Valid plugin IDs for Drupal\Core\Field\FormatterPluginManager are: address_plain,...etc."
It looks like the src/Plugin/Field/FieldFormatter/LazyImageFormatter.php isn't executed (this file contains the declaration of the fieldformatter)
I'm confused since I can't uninstall the Lazy module (the same error message occurs) and I need to make changes to my views.
The wesite does work and isn't impacted by the issue, the problems happens only in the admin.
Thank you for your help
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | lazy-formatter-settings-dependency-3118015.patch | 1.22 KB | james.williams |
Comments
Comment #2
MNSTR commentedI have found the root cause of the issue.
For some reason, the "Additional image formatters" where disabled in the module configuration. It was probably enabled for some time.
Maybe there should be a workaround in the module source code for this case.
Comment #3
james.williamsThe lazy module's formatters should declare the
lazy.settingsconfiguration as a dependency, because otherwise display modes can contain the formatter despite them being disabled -- even iflazy.settingsmight be about to enable them in the same config sync. But because the dependencies aren't flagged,lazy.settingsisn't imported first, as needed.So each of the formatters needs a
calculateDependencies()method added, which should returnlazy.settings. That should be a relatively simple patch.Comment #4
james.williamsHere's a patch that should solve it, at least as long as the lazy formatter isn't disabled in lazy.settings after saving the display mode settings!
Dynamically disabling a formatter is a pretty weird pattern that is going to leave a bunch of edge cases like this :-( But at least this should solve the most common issue, I believe.
Comment #5
osmanTIL,
calculateDependencies()...thanks for this James, and the patch :)
After adding the patch,
core.entity_view_display.<entity_type>.<bundle>.<view_mode>.ymlwould list lazy.settings independencies.config.However, without the patch it would already list the lazy module as a dependency in
dependencies.module.I was hoping it would disallow uninstalling the module, when the extra field formatters enabled.
Comment #6
james.williamsAs per this screenshot - this just follows Drupal's standard behaviour, which allows modules to be uninstalled, and Drupal will replace the formatter with the default formatter in the display mode.
Otherwise uninstalling modules would be really tricky! If you want to make it difficult to uninstall the module, I don't think that's helpful. I think the normal behaviour that Drupal facilitates should be followed here.
Anyway -- as you say, the lazy module is listed as a dependency in this way, regardless of this module, so this patch is not doing that. This patch is just about ensuring that configuration can be reliably synchronised (i.e. so lazy.settings gets synchronised before display modes using the formatters). Handling uninstallation could be a separate issue, if you wanted to discuss that?
Comment #8
osmanHey James, I am happy to include the
calculateDependencies()method, thank you :) With your patch now the dependencies are synced correctly for the "Image (Lazy-load)" and "Responsive image (Lazy-load)" image-formatters.However, I noticed that the core's "Image" and "Responsive image" formatters are still missing the
lazy.settings. I am still investigating...Meanwhile, I totally agree uninstalling modules should not be tricky or complicated.
So, to make things less complicated, I decided to make the "Image (Lazy-load)" and "Responsive image (Lazy-load)" image-formatters enabled at all times, as long as the core's "Image" and "Responsive image" modules, respectively, are already enabled.
MNSTR, would you like to give the dev branch a shot on your development environment, and share your experience? :)
Comment #9
james.williamsOh ace, thanks! I don't think it's a big issue for the core formatters to be missing lazy.settings from their dependencies, as they will still function fine if that config was missing - they just wouldn't get the added enhancement of lazy loading (even if configured to use lazy loading).
I'll give the update a look if I can get time... if only that came easily!
P.S. What does 'MNSTR' mean? :)
Comment #10
osmanComment #12
vishal prasad commentedI had the same error
in that case if you have a backup of the configuration then that will be great and importing the configuration using
drush cimshould solve the error, but if u don't have the backup then just runcomposer updateand that should solve the issue.