Problem/Motivation

Filter plugins use \Drupal::service() instead of dependency injection.

Steps to reproduce


FilterCaption->process()

https://git.drupalcode.org/project/drupal/-/blob/main/core/modules/filte...

Proposed resolution

Replace use of \Drupal::service() in filter plugins in FilterCaption, FilterHtml, EntityLinks, FilterNull.

Remaining tasks

- Compare CR draft with other argument changes.
- Remove filter_manager deprecation.
- Check if other filter plugins need dependency injection.

API changes

Release notes snippet

CommentFileSizeAuthor
#5 3534414-nr-bot.txt1.84 KBneeds-review-queue-bot

Issue fork drupal-3534414

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

graber created an issue. See original summary.

graber’s picture

Version: 11.2.x-dev » 11.x-dev

graber’s picture

Status: Active » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.84 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

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

mortona2k’s picture

Status: Needs work » Needs review

Rebased and simplified. Added deprecation warning and draft change record for requiring FilterManager and RendererInterface arguments, but they are optional for now.

The $filter_manager argument is changed to $filterManager, so there is a warning in the CR that code using named parameters to instantiate the class will need to be updated. However there is no good reason to have written it that way, and I found no code that uses it via Drupal Code Query MCP.

Used AI to rebase.

mortona2k’s picture

Title: Caption filter - inject renderer » Filter plugins - inject renderer
Assigned: graber » mortona2k
Issue summary: View changes
Status: Needs review » Needs work
mortona2k’s picture

Assigned: mortona2k » Unassigned

Similar CRs:
Constructor property promotion across Drupal core
Says there should be no BC break for the vast majority of code, but code constructing a class with named arguments may need updating where a parameter changed from snake_case to camelCase.

New parameters added as optional with a deprecation (CR) in #3226806, then made required for D12 in #3620747.

Same for #3539178 and #3064751. #3223012 used the same pattern and still has its fallback on main.

image_path_flush(), image_style_options() and IMAGE_DERIVATIVE_TOKEN have been deprecated
#3567618 added a required ImageDerivativeUtilities argument to ImageFormatter, ImageUrlFormatter and MediaThumbnailFormatter with no deprecation; the CR does not mention the constructor change.

If this is targeting D12, should I just make the arguments required with no deprecation warnings?