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
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 #3
leoenriquezp commentedThe merge request I just created is ready for review.
Comment #4
amateescu commentedThe absence of a
create()method inTrashEntityPurgeWorkeris 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?
Comment #5
leoenriquezp commentedI am using Drupal 11.3.6 with the Trash module version 3.1.0-beta3.
Comment #6
amateescu commentedCan you check whether
\Drupal\Core\Plugin\PluginBasehasand
in the codebase. Maybe the composer update to Drupal 11.3.6 hasn't updated that file correctly.
Comment #7
leoenriquezp commentedI noticed that
QueueWorkerBaseextendsDrupal\Component\Plugin\PluginBase(seecore/lib/Drupal/Core/Queue/QueueWorkerBase.php, line 5), notDrupal\Core\Plugin\PluginBase.The autowired
create()method was only added toDrupal\Core\Plugin\PluginBase, so Queue Worker plugins do not inherit it. As a result,TrashEntityPurgeWorker(which extendsQueueWorkerBaseand implementsContainerFactoryPluginInterface) does not inheritcreate(), causing that error.Comment #8
amateescu commentedRight, 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.
Comment #10
amateescu commentedThose test failures are for different classes and will be fixed in a followup commit.
Merged into 3.1.x, thank you!