Problem/Motivation

Three plugins in Entity API are still discovered through annotations. Drupal core
deprecated annotation-based plugin discovery in favour of PHP attributes, and each of
these now emits a deprecation on every plugin discovery run:

  Using @Action annotation for plugin with ID entity_delete_action is deprecated and is
  removed from drupal:13.0.0. Use a Drupal\Core\Action\Attribute\Action attribute instead.
  See https://www.drupal.org/node/3395575

  Using @ViewsField annotation for plugin with ID entity_link_revision is deprecated and is
  removed from drupal:13.0.0. Use a Drupal\views\Attribute\ViewsField attribute instead.
  See https://www.drupal.org/node/3395575

  Using @ViewsField annotation for plugin with ID entity_link_revision_revert is deprecated
  and is removed from drupal:13.0.0. Use a Drupal\views\Attribute\ViewsField attribute
  instead. See https://www.drupal.org/node/3395575
  

Because discovery runs on every cache rebuild, any site with a deprecation-reporting
test suite gets three failures it cannot act on, and the module will stop working
entirely on Drupal 13.

This is the annotation half of the Drupal 12 and 13 readiness work.
#3610940 covers the
separate problem of entity.views.inc no longer being autoloaded.

Steps to reproduce

  1. Install Entity API 8.x-1.6 on Drupal 11.2 or later.
  2. Enable the Views integration so the field handlers are discovered.
  3. Run any kernel test with deprecation reporting enabled, or rebuild caches with
    error_reporting set to E_ALL.
  4. Observe the three deprecations above.

Proposed resolution

Replace the annotations with the equivalent core attributes, keeping every plugin ID,
label and deriver identical so no configuration changes:

  • src/Plugin/Action/DeleteAction.php@Action becomes
    #[Action], with the label as a TranslatableMarkup object
    and the deriver referenced as DeleteActionDeriver::class.
  • src/Plugin/views/field/EntityLinkRevision.php@ViewsField
    becomes #[ViewsField('entity_link_revision')].
  • src/Plugin/views/field/EntityLinkRevisionRevert.php
    @ViewsField becomes #[ViewsField('entity_link_revision_revert')].

The @deprecated docblock on DeleteAction and its
@trigger_error() call are left untouched; only the discovery annotation moves.

Remaining tasks

  • Decide what happens to core_version_requirement. It is currently
    ^10.1 || ^11. Drupal\Core\Action\Attribute\Action arrived in
    10.2.0 and the Views attributes later still, so a straight conversion drops support
    for 10.1. Either raise the requirement or keep both annotation and attribute on the
    classes, which core's discovery explicitly supports.
  • Review the patch and open a merge request.

User interface changes

None. The plugin IDs, labels and derivers are unchanged, so existing views and action
configuration keep working untouched.

API changes

None.

Data model changes

None.

Issue fork entity-3614512

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

daften created an issue. See original summary.

daften’s picture

Assigned: daften » Unassigned
Status: Active » Needs review

Created an MR for this.