Problem/Motivation

When a service is deprecated, not injected anywhere, but is retrieved via Container::get(), no deprecation is given.

Steps to reproduce

Proposed resolution

Trigger a deprecation notice from Container::get() if the service is deprecated.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

catch created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new3.16 KB

This one is going to be fun because we don't have the info from the ContainerBuilder so we're going to have to somehow provide it. Here's an approach with a compiler pass.

Let's see if we trigger any deprecations!

longwave’s picture

I found #2529516: Decouple tests from relying that $container is a container builder while trawling for Bug Smash Initiative, that seems at least tangentially related because of the finding in the upstream issue that deprecations work in kernel tests but not functional tests.

alexpott’s picture

StatusFileSize
new2.27 KB
new5.43 KB

@longwave nice find - I agree related but not a blocker per se here.

Here's a test. The test only patch is the interdiff.

The last submitted patch, 2: 3215611-2.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 4: 3215611-4.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new2 KB
new1.52 KB
new6.91 KB

Fixing the deprecation now triggered in HEAD & fixing the test namespace so that run-tests.sh can run it.

The last submitted patch, 7: 3215611-7.test-only.patch, failed testing. View results

longwave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Looks like a reasonable approach. We could add the deprecated definition to OptimizedPhpArrayDumper::getServiceDefinition() but that would only cover services - aliases would need special handling to extract and store their deprecation messages. The compiled container won't be much different so this method seems like far less code for the same result.

Good that we found a missed deprecation in our own code as well :)

  • larowlan committed d8ad12f on 9.2.x
    Issue #3215611 by alexpott, longwave: Service deprecations are only...
  • larowlan committed 70175bc on 9.3.x
    Issue #3215611 by alexpott, longwave: Service deprecations are only...
larowlan’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 70175bc and pushed to 9.3.x. Thanks!

Backported to 9.2.x

Nice solution

Status: Fixed » Closed (fixed)

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

fabianx’s picture

This was not a good approach as it is a SEVERE performance regression in the critical path.

At least move it later in the function.

It would indeed be better to put that into the dumper as that looks at every service anyway ...

larowlan’s picture

Can we get a follow up issue @fsbianx?