Problem/Motivation

Drupal\trash\Plugin\QueueWorker\TrashEntityPurgeWorker declares implements ContainerFactoryPluginInterface and injects five services through its constructor, but the class never defines the create() factory method that the interface requires. PHP therefore treats it as having an unimplemented abstract method and aborts:

PHP Fatal error: Class Drupal\trash\Plugin\QueueWorker\TrashEntityPurgeWorker
contains 1 abstract method and must therefore be declared abstract or implement
the remaining methods (Drupal\Core\Plugin\ContainerFactoryPluginInterface::create)
in .../trash/src/Plugin/QueueWorker/TrashEntityPurgeWorker.php on line 2

Proposed resolution

Add the missing create() method and the ContainerInterface import

Issue fork trash-3615288

Command icon 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

leoenriquezp created an issue. See original summary.

leoenriquezp’s picture

Status: Active » Needs review

The merge request I just created is ready for review.

amateescu’s picture

Status: Needs review » Postponed (maintainer needs more info)

The absence of a create() method in TrashEntityPurgeWorker is intentional, because Drupal 11.3.0 provides it automatically: #3452852: Add create() factory method with autowired parameters to PluginBase , and Trash 3.1.x requires Drupal 11.3.3.

What versions of Trash and Drupal are you running?

leoenriquezp’s picture

I am using Drupal 11.3.6 with the Trash module version 3.1.0-beta3.

amateescu’s picture

Can you check whether \Drupal\Core\Plugin\PluginBase has

use AutowiredInstanceTrait;

and

  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return static::createInstanceAutowired($container, $configuration, $plugin_id, $plugin_definition);
  }

in the codebase. Maybe the composer update to Drupal 11.3.6 hasn't updated that file correctly.

leoenriquezp’s picture

I noticed that QueueWorkerBase extends Drupal\Component\Plugin\PluginBase (see core/lib/Drupal/Core/Queue/QueueWorkerBase.php, line 5), not Drupal\Core\Plugin\PluginBase.

The autowired create() method was only added to Drupal\Core\Plugin\PluginBase, so Queue Worker plugins do not inherit it. As a result, TrashEntityPurgeWorker (which extends QueueWorkerBase and implements ContainerFactoryPluginInterface) does not inherit create(), causing that error.

amateescu’s picture

Status: Postponed (maintainer needs more info) » Needs review

Right, nice catch! The problem was this issue #3566682: QueueWorkerBase should inherit from Core's PluginBase, not Component's and that we were testing Trash with Drupal 11.4 instead of the minimum core supported version (11.3.3). Improved the MR a bit.

amateescu’s picture

Status: Needs review » Fixed

Those test failures are for different classes and will be fixed in a followup commit.

Merged into 3.1.x, thank you!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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