Drupal\Core\Plugin\DefaultPluginManager fails inside findDefinitions(), I get the error Fatal error: Class 'Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\ImagemagickImageToolkitOperationBase' not found in modules/contrib/image_effects/src/Plugin/ImageToolkit/Operation/imagemagick/AutoOrient.php on line 18

I'm not sure if this is an issue with Drupal or with how the module works, so I figured I'd open it here first.

I'm using Drupal 8.2.0-beta3.

Comments

KarlShea created an issue. See original summary.

karlshea’s picture

Issue summary: View changes
mondrake’s picture

Priority: Normal » Critical

Thanks for the report.

I believe this is strictly connected with #2784703: Branch tests broken.

Something must have happened in Drupal core since the module was working and passing tests OK at least until end of June, then a patch test on July 31 failed: https://www.drupal.org/pift-ci-job/428235, with failures unrelated to the patch.

That one was resolved by adding a test_dependency to ImageMagick so tests can rely on that module being installed.

Maybe this is pointing to the root cause?

mondrake’s picture

I suspect the problem comes from the commit of Drupal core #2763157: Allow plugins to provide multiple forms, specifically from this hunk

+++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
@@ -239,9 +239,20 @@ public function useCaches($use_caches = FALSE) {
+
+    // If no default form is defined and this plugin implements
+    // \Drupal\Core\Plugin\PluginFormInterface, use that for the default form.
+    if (!isset($definition['forms']['configure']) && isset($definition['class']) && is_subclass_of($definition['class'], PluginFormInterface::class)) {
+      $definition['forms']['configure'] = $definition['class'];
+    }

is_subclass_of($definition['class'], PluginFormInterface::class)) probably needs to load the class specified by $definition['class']. Since this AutoOrient is a subclass of Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\ImagemagickImageToolkitOperationBase, and that class is not available as it's from a not installed module, this fails.

Is the module working on Drupal 8.1.x where the above was not committed?

berdir’s picture

We could open a core bug about this, this is clearly a regression.

Other modules had this too, e.g. search_api and they moved dependant classes into an optional submodule.

mondrake’s picture

OK I will log an issue in core's queue.

mondrake’s picture

mondrake’s picture

Status: Postponed » Fixed

This issue should be fixed in core with Drupal 8.2.0-rc2 release, due out soon. Marking as fixed, please reopen if not.

For Image Effects module, a follow-up is #2799867: Skip discovery of ImageToolkitOperations for which the relative toolkit is not installed, which has a patch already. Reviews appreciated.

Status: Fixed » Closed (fixed)

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