Problem/Motivation
The Entity module's DeleteAction class contains a @trigger_error() that fires when the class is discovered during plugin scanning, even when the class isn't actually used. This breaks compatibility with the ECA module which uses extended error handling during plugin discovery.
Steps to reproduce
- Install Entity API module (v1.6.0)
- Install ECA module
- Enable ECA modules
- Check logs for deprecation errors
Current Behavior
When ECA scans for available actions, it triggers the Entity module's deprecation warning:
ECA ran into error from third party in the context of "Collecting all available actions":
\Drupal\entity\Plugin\Action\DeleteAction has been deprecated in favor of \Drupal\Core\Action\Plugin\Action\DeleteAction. Use that instead.
Line 7 of /var/www/html/web/modules/contrib/entity/src/Plugin/Action/DeleteAction.php
This happens because the @trigger_error() fires when the class is loaded during plugin discovery, not just when it's instantiated.
Proposed resolution
Move the deprecation notice from the class level to the constructor, so it only triggers when the class is actually used, not just discovered:
class DeleteAction extends CoreDeleteAction {
/**
* Constructor for DeleteAction.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
@trigger_error('\Drupal\entity\Plugin\Action\DeleteAction has been deprecated in favor of \Drupal\Core\Action\Plugin\Action\DeleteAction. Use that instead.', E_USER_DEPRECATED);
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
}
Patch
Attached is a patch that implements this fix. It follows Drupal's best practices for deprecation by continuing to show the warning when the class is actually used, while preventing errors during plugin discovery.
Impact and Importance
This issue affects any site using both Entity API and ECA modules. Currently, users must disable ECA to avoid the error, limiting functionality. The fix maintains the proper deprecation notice while allowing both modules to work together.
| Comment | File | Size | Author |
|---|---|---|---|
| entity-fix-deprecation.patch | 992 bytes | dan_metille |
Issue fork entity-3532309
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
rajab natshahFacing the same issue
Comment #3
rajab natshahThanks, Dan, for reporting and patching.
Tested your patch, It is working well.
Comment #4
rajab natshahComment #5
bdunphy commentedApplied the patch against Entity API 8.x-1.6 and tested. The core DeleteAction expects 6 parameters not the 3 as stated in the patch file. A PHP error is thrown:
ArgumentCountError: Too few arguments to function Drupal\Core\Action\Plugin\Action\DeleteAction::construct(), 3 passed in /XXX/XXX/XXX/XXXX/web/modules/contrib/entity/src/Plugin/Action/DeleteAction.php on line 24 and exactly 6 expected in *Drupal\Core\Action\Plugin\Action\DeleteAction->construct()* (line 53 of /XXX/XXX/XXX/XXX/web/core/lib/Drupal/Core/Action/Plugin/Action/DeleteAction.php)Comment #8
akalam commentedI've created a MR fixing using the same arguments as in the core's Action Plugin
Comment #9
intrafusionThis appears to be working as the error has gone away
Comment #10
jurgenhaasRTBC+1, this is something that we get quite a lot of support requests in ECA, an early merge and patch release would therefore be much appreciated.
Comment #11
mw4ll4c3 commentedRTBC as well. A clean fix that only triggers the error when it's relevant.
Comment #12
rajab natshahComment #13
trickfun commentedPatch works fine
Comment #14
rakesh.gectcrThe patch works fine
https://www.drupal.org/files/issues/2025-06-25/entity-fix-deprecation.patch
Comment #15
anaconda777 commentedApplied the patch but getting time to time wsod and
ArgumentCountError: Too few arguments to function Drupal\Core\Action\Plugin\Action\DeleteAction::__construct(), 3 passed in /var/www/html/site/web/modules/contrib/entity/src/Plugin/Action/DeleteAction.php on line 24 and exactly 6 expected in Drupal\Core\Action\Plugin\Action\DeleteAction->__construct() (line 53 of /var/www/html/site/web/core/lib/Drupal/Core/Action/Plugin/Action/DeleteAction.php).also got this ajax error while running update from the UI which I usually dont do...