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.

CommentFileSizeAuthor
entity-fix-deprecation.patch992 bytesdan_metille

Issue fork entity-3532309

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

dan_metille created an issue. See original summary.

rajab natshah’s picture

Facing the same issue

rajab natshah’s picture

Status: Active » Reviewed & tested by the community

Thanks, Dan, for reporting and patching.
Tested your patch, It is working well.

rajab natshah’s picture

Title: Deprecation notice from DeleteAction class causes errors in ECA module » Fix Deprecation notice from DeleteAction class causes errors in ECA module
bdunphy’s picture

Status: Reviewed & tested by the community » Needs work

Applied 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)

akalam made their first commit to this issue’s fork.

akalam’s picture

Status: Needs work » Needs review

I've created a MR fixing using the same arguments as in the core's Action Plugin

intrafusion’s picture

Status: Needs review » Reviewed & tested by the community

This appears to be working as the error has gone away

jurgenhaas’s picture

RTBC+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.

mw4ll4c3’s picture

RTBC as well. A clean fix that only triggers the error when it's relevant.

rajab natshah’s picture

Priority: Normal » Major
trickfun’s picture

Patch works fine

rakesh.gectcr’s picture

anaconda777’s picture

Applied 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...

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /update.php/start?id=1378&op=do_nojs&op=do
StatusText: OK
ResponseText: 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 23 of /var/www/html/site/web/modules/contrib/entity/src/Plugin/Action/DeleteAction.php