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
- Install Entity Browser module
- Run Upgrade Status module scan
- 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.
| Comment | File | Size | Author |
|---|
Issue fork entity_browser-3565236
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
titacvetkovic commentedComment #5
recrit commentedcreated MR. Attached is a clean static patch for composer builds.
Comment #6
recrit commentedfixed the class included. Attached is an updated patch of the MR.
Comment #7
csakiistvanComment #8
csakiistvanEnvironment
Prerequisites
upgrade_statusmodule (/admin/reports/upgrade-status) or a PHPStan/deprecation-testing run targeting Drupal 11/12.Steps
FormElementwithFormElementBase(theusestatement and the class declaration) in bothsrc/Element/EntityBrowserElement.phpandsrc/Element/EntityBrowserPagerElement.php.ddev drush crExpected results
EntityBrowserElementorEntityBrowserPagerElementextending a deprecated class.Drupal\Core\Render\Element\FormElementBase.Actual results
Before the fix, both
EntityBrowserElementandEntityBrowserPagerElementextendDrupal\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 extendFormElementBaseand the deprecation warnings no longer appear.Testing produced with the assistance of an LLM.
Comment #9
csakiistvanComment #10
berdirThis 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.
Comment #11
berdirWe'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.