Problem/Motivation

Uninstall validators are all lazy thereby having proxy classes. This because uninstall is not the common action when instantiating the module installer. We can change this to automatically using a service iterator for these and remove a tonne of proxy classes.

Let's wait on #1170362: Install profile is disabled for lots of different reasons and core doesn't allow for that before pulling the trigger here because that adds one. We can start work here in preparation for that one land though so not postponing.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3432595

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

alexpott created an issue. See original summary.

longwave’s picture

Now we can support tags in YAML parsing it would be good to add support for !service_closure in services.yml as per https://symfony.com/doc/current/service_container/service_closures.html - it is also doable by switching to autowiring but good to have both options and be more like Symfony.

longwave’s picture

Looking at the code actually I think this should just use #[AutowireIterator] as per https://symfony.com/doc/current/service_container/service_subscribers_lo...

This gives you a collection of services that are lazily instantiated and that you can iterate over, which is exactly what we need in ::validateUninstall().

longwave’s picture

Status: Active » Needs review

Still needs work to clean up the now-unused proxy classes but BookUninstallTest passes locally so let's see what happens.

longwave’s picture

Also wondering why the ModuleInstaller itself is lazy, it's not injected into anything?

edit: it is injected into some forms and the ConfigImporter, but we probably will need it there anyway, not sure it is worth being lazy just for that - doesn't seem like critical path.

longwave’s picture

Status: Needs review » Needs work

OptimizedPhpArrayDumper is not capable of restoring iterators, it just converts them to arrays, and the services within are not lazily instantiated.

longwave’s picture

Status: Needs work » Needs review

OptimizedPhpArrayDumper can now dump and restore lazy service iterators and the unused proxy classes have been deleted.

longwave’s picture

#2961380: Support IteratorArgument in \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper::dumpValue added IteratorArgument to OptimizedPhpArrayDumper but it turns out the implementation was incomplete as the iterators were no longer lazy and just cast to arrays in the restored container, however this is currently otherwise unused in core so I think it's OK to fix here.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new8 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.

longwave’s picture

Status: Needs work » Needs review
longwave’s picture

Title: Use a service closure for uninstall validators instead of proxies » Use a tagged service iterator for uninstall validators instead of individual lazy proxies
longwave’s picture

Issue summary: View changes
longwave’s picture

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. 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.

longwave’s picture

Status: Needs work » Needs review

Rebased, also added a test that was added over in #3414208: Add support for tagged_iterator to YamlFileLoader

smustgrave’s picture

Status: Needs review » Needs work

May need a rebase, but appears to have a unit test failure.

longwave’s picture

Status: Needs work » Needs review

Fixed unit test, thanks @kim.pepper for the fix over in #3414208: Add support for tagged_iterator to YamlFileLoader

longwave’s picture

longwave’s picture

Status: Needs review » Needs work

Added BC service for the $uninstallValidators argument to ModuleInstaller, probably should add a test for that, and also add back the addUninstallValidator() method and issue a deprecation as well just in case.

longwave’s picture

mglaman/phpstan-drupal doesn't like YAML tags, opened https://github.com/mglaman/phpstan-drupal/pull/743

kim.pepper’s picture

#22 The fix was just tagged by @mglaman in a new release https://github.com/mglaman/phpstan-drupal/releases/tag/1.2.10

spokje’s picture

longwave’s picture

Status: Needs work » Needs review

PHPStan update landed, updated the baseline to include the new deprecation for the BC layer.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. 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.

longwave’s picture

Status: Needs work » Needs review

Rebased following book and forum removals.

smustgrave’s picture

Status: Needs review » Needs work

MR appears to need manual rebase again

kim.pepper’s picture

Status: Needs work » Needs review

Rebased on 11.x

kim.pepper’s picture

Hiding some files.

spokje’s picture

Status: Needs review » Reviewed & tested by the community

Idea is nice, code looks fine, tests are green.

The only thing that I wonder about if there's still time to deprecate/remove in 10.3.0/11.0.0 since the BETAs of both are already out.
I _think_ we're too late and need to deprecate/remove in 10.3.1/12.0.0, but am not sure
I know I've seen documentation on this before somewhere, but my search-fu is failing me now.

Putting this on RTBC so core committers can decide on this.

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

catch’s picture

This should be deprecated in 11.1 for 12.0.0 at this point. We're probably going to have to deprecate some things in 10.4 for removal in 12.0.0 too at some point, but there's no new API for contrib to implement here so it should be fine in 11.1 as cleanup without affecting contrib compatibility with both major branches. Just needs versions changed in the deprecation messages so went ahead and made/applied suggestions to the MR.

spokje’s picture

Thanks @catch.

Since there's not yet a version-tag for 11.1.x in the dropdown (nor Git), I think the correct status for this issue would be postponed and we whack a [11.1.x] in the title to have some kind of visual queue?

catch’s picture

@Spokje because there's the 11.0.x branch open, we can commit 11.1.x-specific stuff to 11.x now. Then we'll eventually branch 11.1.x off 11.x when we want to start committing 11.2.x-specific stuff.

spokje’s picture

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

@catch: Ah, of course, this eludes me every once in a while. Thanks for explaining.

Moving to correct version.

  • catch committed f26598bf on 11.x
    Issue #3432595 by longwave, kim.pepper, alexpott: Use a tagged service...
catch’s picture

Version: 11.0.x-dev » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x, thanks!

Status: Fixed » Closed (fixed)

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

mikelutz’s picture

Status: Closed (fixed) » Needs work

@deprecated in drupal:11.1.0 and is removed from drupal:11.1.0. Inject

Should this not be removed in 12.0.0?

mikelutz’s picture

Status: Needs work » Needs review
alexpott’s picture

Status: Needs review » Fixed

Fixed the deprecation notice - thanks @mikelutz

  • alexpott committed 257fa315 on 11.x
    Issue #3432595 follow-up by mikelutz: Use a tagged service iterator for...

Status: Fixed » Closed (fixed)

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