Problem/Motivation

With the introduction of #2976335: Use Zend-Feed's standalone extension managers to prevent sites breaking, it is no longer needed to maintain a list of Laminas feed services in core.services.yml since the \Drupal\Component\Bridge\ZfExtensionManagerSfContainer now passes default services unregistered to the Drupal container into the standalone extension manager.

Proposed resolution

Deprecated all feed.reader.* and feed.writer.* services in core.services.yml.

Remaining tasks

#2976335: Use Zend-Feed's standalone extension managers to prevent sites breaking

User interface changes

None

API changes

  • feed.reader.* services deprecated
  • feed.writer.* services deprecated

Nothing in contrib is using the feed.writer. services... http://codcontrib.hank.vps-private.net/search?text=feed.writer.&filename=
There are some usages of feed.reader.* in contrib... http://codcontrib.hank.vps-private.net/search?text=feed.reader.&filename= but that's to add a new reader so it it is still supported and will continue to work just fine. The test could be updated to do less work FWIW.

Data model changes

None

Issue fork drupal-2979588

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

Erik Frèrejean created an issue. See original summary.

erik frèrejean’s picture

Status: Active » Needs review
StatusFileSize
new6.05 KB

Added a patch to mark all these services as deprecated, not sure though whether it needs a new CR or that pointing toward https://www.drupal.org/node/2979042 is sufficient.

borisson_’s picture

I think it's sufficient to point to that CR. Great work @Erik Frèrejean! I'm not setting to RTBC yet as I'd like to get feedback from others that have touched this area. I recently saw a discussion between @catch and @alexpott about this bridge, so I feel that they have more knowledge about this.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

alexpott’s picture

+++ b/core/core.services.yml
@@ -1383,67 +1383,88 @@ services:
+    deprecated: The "%service_id%" service is deprecated. You should use the 'feed.bridge.reader' to create a reader instead. See https://www.drupal.org/node/2979042

We should be more specific here and say something like use \Drupal::service('feed.bridge.reader')->get('DublinCore\Entry') instead.

alexpott’s picture

StatusFileSize
new9.91 KB
new6.48 KB

I've updated the change record with a table showing all the deprecated services. This can go in the current published CR because the extension managers are there today and people can update their code already.

We now need to decide in which version of Drupal we are going to do the deprecation and how long we're going to maintain them... see #3088246: [policy, no patch] How to handle Drupal 8.9.x deprecations

Here's a patch that updates the messages to be more specific.

catch’s picture

Version: 8.9.x-dev » 9.1.x-dev

@alexpott pointed out somewhere (I thought it was here but apparently not) that the contrib feeds module uses these services. So given that and the interim decision on #3088246: [policy, no patch] How to handle Drupal 8.9.x deprecations I'm going to move this to 9.1.x

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

alexpott’s picture

StatusFileSize
new6.55 KB

Rerolling for 9.2.x

alexpott’s picture

Issue summary: View changes

Adding info about contrib usage to the issue summary.

longwave’s picture

Patch looks fine but do we need a test? On one hand we usually test everything, but here these aren't used in core, the deprecated service definition key is a Symfony feature, and testing them all individually seems a waste of time.

alexpott’s picture

What I'm a bit perplexed about is why we're not triggering any deprecations. Like why is \Drupal\aggregator\Plugin\aggregator\parser\DefaultParser::parse() not resulting in a deprecation?

longwave’s picture

Because DefaultParser uses feed.bridge.reader which we aren't deprecating?

longwave’s picture

Title: Deprecate zend bridge services » Deprecate Laminas\Feed reader and writer services
Issue summary: View changes

Better title. We aren't deprecating the bridge, we are deprecating the individual readers/writers. And it's no longer Zend!

However I see what you mean now, ZfExtensionManagerSfContainer seems like it should be instantiating the services at some point, so why doesn't that happen here?

longwave’s picture

StatusFileSize
new7.48 KB

When you get the service via a kernel test, the deprecation is correctly triggered, but this doesn't happen at runtime in a functional test.

I *think* this is because during a kernel test, $container is a Drupal\Core\DependencyInjection\ContainerBuilder and ContainerBuilders will trigger deprecations when the service is instantiated. But at runtime, $container is a compiled Drupal\Core\DependencyInjection\Container, and this seemingly has no way of triggering deprecations.

alexpott’s picture

@longwave ohhh that's very very interesting! We need to create an issue for that - I think we should issue a deprecation from \Drupal\Component\DependencyInjection\Container::get() or maybe \Drupal\Component\DependencyInjection\Container::createService() if the service is deprecated.

andypost’s picture

Issue tags: +@deprecated

btw does it mean that this services are not instantiated or unused?

alexpott’s picture

@andypost nope it means the calling \Drupal::service() on a deprecated service does not issue a deprecation notice. Only adding a deprecated service as an argument does... ie. deprecations are issued by ContainerBuilder and not Container. /me is jealous of Symfony and it's private by default service wonderland.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

catch’s picture

So #17 seems fine for testing (with a follow-up for runtime service deprecations somehow) - do we want to add all the other services to the test? Or just not bother...

alexpott’s picture

@catch I think the problem here is that in core we're doing return $this->container->get($this->prefix . $this->canonicalizeName($extension)); in \Drupal\Component\Bridge\ZfExtensionManagerSfContainer but that is not triggering a deprecation because container deprecations only happen on container build. We need to fix that.

catch’s picture

longwave’s picture

StatusFileSize
new7.63 KB

#3215611: Service deprecations are only triggered on container build,not ::get() landed.

Fixed up coding standard issues in #17, let's see where this explodes.

Status: Needs review » Needs work

The last submitted patch, 25: 2979588-25.patch, failed testing. View results

longwave’s picture

Status: Needs work » Needs review

Swapped around the order in ZfExtensionManagerSfContainer so we check the standalone services first and fall back to the container, I think this is the right (and easiest) solution.

Do we need to deprecate retrieving services from the container entirely?

andypost’s picture

longwave’s picture

Status: Needs review » Needs work

Not sure I see how to do that, bumping to NW for now.

andypost’s picture

As MR used

alexpott’s picture

Here's my understanding of the problem:

  • We need to keep the services in the container just in case someone is accessing one via \Drupal::service().
  • We want them deprecated so we issue a deprecation notice when then happens.
  • We can't change the logic in \Drupal\Component\Bridge\ZfExtensionManagerSfContainer::get() because if we do then anything that has decorated one of this services will break.

In order to satisfy the requirements we need to not call $this->container->get() when doing so would result in a deprecation. I think the only way to do this is to add a compiler pass that checks the feed.reader.* and feed.writer.* services, and if the class matches the class defined in core.services.yml, add the service name or extension name to a list stored on \Drupal\Component\Bridge\ZfExtensionManagerSfContainer. Then this list is used to ensure we don't call $this->container->get() for these extension but to calling $this->standalone->get($extension) instead.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

catch’s picture

I don't think we need to support decorating these services. If we're worried that someone actually is decorating them, we could make this change in Drupal 10 for Drupal 11, but that also seems extremely unlikely.

catch’s picture

feed.reader.*: http://grep.xnddx.ru/search?text=feed.reader&filename=

feed.writer.*: http://grep.xnddx.ru/search?text=feed.writer&filename=

Almost no references at all and nothing decorating.

alexpott’s picture

Rebased the branch onto 9.4.x and improved the deprecation message.

mglaman’s picture

I wanted to say that the final fix looks great. Same with the minor clean up in core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php

catch’s picture

Status: Needs work » Needs review
daffie’s picture

Status: Needs review » Needs work

The MR looks good to me. Just 1 remark.

alexpott’s picture

Status: Needs work » Needs review

@daffie I think this unnecessary to be honest. The message is not really tested by the test - ie it's not tested for correctness - it's tested for a match. So it's just massive duplication. And if someone changes the message then we'll have to change it in both places. Even the test added here is superfluous because the ability for a service to be deprecated by adding this key is well-tested upstream. What's more important is testing the we don't get deprecations when accessing readers and writers via the bridge and that's tested here.

longwave’s picture

Extended the test to cover all deprecated feed services.

Crosspost with @alexpott, oh well - it doesn't add a huge amount of extra code, I think this is OK.

alexpott’s picture

@longwave thanks - I guess :) there's no harm in the test but it is not actually testing much more than that we got the deprecation key in the container yaml correct. I guess it is also testing that message format is consistent.

spokje’s picture

Status: Needs review » Reviewed & tested by the community

I believe that @daffies last remaining remark in #39 is now taken care of.

daffie’s picture

+1 for RTBC.

  • catch committed fc90d0c on 10.0.x
    Issue #2979588 by longwave, alexpott, Erik Frèrejean, catch, daffie:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed fc90d0c and pushed to 10.0.x. Thanks!

Cherry-picked to 9.4.x too.

  • catch committed ab0ec7c on 9.4.x
    Issue #2979588 by longwave, alexpott, Erik Frèrejean, catch, daffie:...

Status: Fixed » Closed (fixed)

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