Problem/Motivation

EntityBrowserElement and EntityBrowserPagerElement classes in the Entity Browser module extend the deprecated Drupal\Core\Render\Element\FormElement class, which causes deprecation warnings when running Upgrade Status or preparing for Drupal 11:
Class Drupal\entity_browser\Element\EntityBrowserElement extends deprecated class Drupal\Core\Render\Element\FormElement.
Deprecated in drupal:10.3.0 and is removed from drupal:12.0.0.
Use Drupal\Core\Render\Element\FormElementBase instead.

Steps to reproduce

  1. Install Entity Browser module
  2. Run Upgrade Status module scan
  3. Review deprecation warnings for Entity Browser

Proposed resolution

Replace FormElement with FormElementBase in both element classes:

  • The use statement
  • The class declaration
  • The annotation

Remaining tasks

I am attaching a patch that can provide a workaround until this is fixed.

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

titacvetkovic created an issue. See original summary.

titacvetkovic’s picture

Issue summary: View changes

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

recrit’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

created MR. Attached is a clean static patch for composer builds.

recrit’s picture

fixed the class included. Attached is an updated patch of the MR.

csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

Environment

  • Drupal: 11.4.4
  • PHP: 8.5.5
  • Database: MariaDB 10.11.16
  • DDEV: v1.25.2
  • Entity Browser: 8.x-2.15

Prerequisites

  • Entity Browser module installed and enabled.
  • A tool that reports deprecations against the codebase, e.g. the upgrade_status module (/admin/reports/upgrade-status) or a PHPStan/deprecation-testing run targeting Drupal 11/12.

Steps

  1. Apply the fix from MR !146: replace FormElement with FormElementBase (the use statement and the class declaration) in both src/Element/EntityBrowserElement.php and src/Element/EntityBrowserPagerElement.php.
  2. Rebuild caches: ddev drush cr
  3. Run an Upgrade Status scan on Entity Browser (or your deprecation-testing tool) and review the reported deprecations.

Expected results

  • No deprecation is reported for EntityBrowserElement or EntityBrowserPagerElement extending a deprecated class.
  • Both classes extend Drupal\Core\Render\Element\FormElementBase.

Actual results

Before the fix, both EntityBrowserElement and EntityBrowserPagerElement extend Drupal\Core\Render\Element\FormElement, which is deprecated in drupal:10.3.0 and removed in drupal:12.0.0, producing the warning "Class Drupal\entity_browser\Element\EntityBrowserElement extends deprecated class Drupal\Core\Render\Element\FormElement. Use Drupal\Core\Render\Element\FormElementBase instead." for each class. After applying the fix, both classes extend FormElementBase and the deprecation warnings no longer appear.


Testing produced with the assistance of an LLM.

csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Reviewed & tested by the community
berdir’s picture

Version: 8.x-2.15 » 8.x-2.x-dev
Status: Reviewed & tested by the community » Needs work

This is a 10.3 deprecation, the module currently requires 10.2, that needs to be updated.

When touching those lines, we could also update the annotations in those files to attributes, that's safe to do on 10.3 without BC (keeping annotations). other plugins can be done elsewhere.

berdir’s picture

Status: Needs work » Closed (duplicate)

We're merging this into #3613186: Fix Drupal 12 deprecations: migrate hooks to OOP classes and fix views_data_alter fatal, I've added the contributors to that issue already.

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.