Problem/Motivation

ImageToolkit plugins can easily be made autowirable, but ImageToolkitOperation ones less so as its manager passes the toolkit (that is not a 'proper' service) to the operation and overrides the createInstance() method.

The Imagemagick toolkit requires several services in their operations, and it's currently not possible to autowire there.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3559481

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

mondrake created an issue. See original summary.

mondrake’s picture

Status: Active » Needs review
mondrake’s picture

Title: Let ImageToolkit and ImageToolkitOperations plugins be container aware and autowirable » Let ImageToolkit and ImageToolkitOperations plugins be container aware and autowireable
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

left a comment. If agreed to do the deprecation then a simple CR maybe?

mondrake’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Looks good! Only moving to NW for manual rebase for ImageTest

mondrake’s picture

Status: Needs work » Needs review

rebased

mondrake’s picture

Status: Needs review » Needs work

Uhm, now an ImageToolkit may be autowireable, likely along with the ImageToolkitOperations it provides. But an ImageToolkitOperation provided by a separate module may provide more ImageToolkitOperations that will not be autowireable yet. Need to think its impact and in case provide BC.

mondrake’s picture

Status: Needs work » Needs review

Found a way to make this simpler. We can autowire ImageToolkitOperationBase and make the $toolkit argument nullable - in this case the autowiring will pass a null, then we set the actual toolkit on the operation via setToolkit in the manager.

No need to deprecate anything anymore.

mondrake’s picture

Status: Needs review » Needs work

Actually - let's deprecate the $toolkit argument.

mondrake’s picture

Status: Needs work » Needs review
smustgrave’s picture

All the typehints and return types in the tests was that needed for the autowire feature?

mondrake’s picture

In ImageTest you mean? Yes, they were needed, can't remember exactly why but for sure we could no longer run the test just with mocking the interface, then GDToolkit had to be mocked instead and then all the rest came along.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

ImageTest was the one I meant, sorry should of mentioned.

Wasn't entirely sure how to best test so just applied the MR locally, cleared cache, and did image uploads with different styles being applied. Everything seemed to work.

Test-only ran here https://git.drupalcode.org/issue/drupal-3559481/-/jobs/7882164 which appears to line up with the tests aded

If this is RTBC too soon I apologize!

longwave’s picture

Status: Reviewed & tested by the community » Fixed

The argument juggling here is a bit tricky to follow but I think it's correct; I'm not sure how many real world cases there are where the BC will be triggered anyway. Let's ship this in 11.4 and deal with any fallout if it happens.

Committed and pushed a69a313a746 to main and 7a1b1f74737 to 11.x. Thanks!

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.

  • longwave committed 7a1b1f74 on 11.x
    refactor: #3559481 Let ImageToolkit and ImageToolkitOperations plugins...

  • longwave committed a69a313a on main
    refactor: #3559481 Let ImageToolkit and ImageToolkitOperations plugins...
alexpott’s picture

This is causing errors in tests. We can't have readonly service properties on plugins because they cannot be set in a wakeup - see https://issue.pages.drupalcode.org/-/drupal-3564689/-/jobs/8238108/artif...

I do not know why this is not a consistent error yet but this MR is going to cause problems. We need to remove the readonly from the these properties and I think we need to be more careful about adding the readonly property.

mondrake’s picture

Revert?

alexpott’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.