Problem/Motivation
For 8.1.x, in #2624770: Use more specific entity.manager services in core.services.yml we convert services that using @entity.manager
to use the new entity services, but only those that are using methods belonging to a single new service.
The module developers are working based on 8.0.x and they using core (and core modules) as a primary inspiration source. They will continue to use @entity.manager
because in YAML their IDE do not mark that value as deprecated. Very few of them will go the the service class and see the deprecation note.
We have to encourage them to use the new entity services instead of EntityManager.
Proposed resolution
Add docs (comments) to 8.0.x *.services.yml
to tell that @entity.manager
is deprecated and will be removed in the future.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#20 | interdiff.txt | 41.15 KB | claudiu.cristea |
#20 | 2627938-20.patch | 54.85 KB | claudiu.cristea |
Comments
Comment #2
claudiu.cristeaComment #3
claudiu.cristeaComment #4
claudiu.cristeaOuch!
Comment #5
claudiu.cristeaComment #6
claudiu.cristeaPatch. This should go in both 8.0.x & 8.1.x.
Comment #7
claudiu.cristeaI think this is more likely to be in 8.1.x and cherry picked to 8.0.x?
Comment #8
jhodgdonDeprecating something is not really a Documentation issue (it's a core maintainer decision to deprecate something, not just a matter of making sure something is documented accurately), so I am moving this over to the Entity component.
And by the way, the docs look OK to me... however I am not sure that anyone will notice them there, and I know that they will not be shown on api.drupal.org on the docs page for the entity.manager service, because it doesn't parse # comments in YML files at all.
So.
My feeling is that this should be documented somewhere else in addition:
- Maybe on the class Drupal\Core\Entity\EntityManager it could be mentioned? And is that class going away too?
- Is there a Drupal:: method that returns the entity manager? If so it should definitely be deprecated as well.
Comment #9
claudiu.cristeaI know. That service was already deprecated but there's no evidence in
core.services.yml
. With this patch, we want to narrow the possibility that module developers will use the deprecatedEntityManager
service. It's just another reminder point. So, we are not deprecating anything here, we only make the deprecation bold.Comment #10
claudiu.cristeaBack to 'documentation' component as per #9.
Comment #11
jhodgdonOK. Still should be Needs Work based on #8. The documentation added here is not going to be noticed.
Comment #12
jhodgdonSo someone just filed #2641704: Suggest alternative to EntityManager::getStorage, which I've marked as a duplicate of this issue. It illustrates what I said in #8 quite nicely -- so yes, EntityManager is deprecated but unfortunately whoever did that did not tell what to do as an alternative. This information needs to be added to the EntityManager class, and all of its methods probably.
Comment #13
claudiu.cristeaOK. Here's a patch. And, yes, this should go in 8.0.x.
Comment #14
jhodgdonWow, thanks for all the work that went into this patch! A great start.
I think there are a couple of things that need to be improved before we can commit it:
I'm wondering if we should perhaps add a blank line before this comment? We do not have comments in front of services anywhere else in Core that I am aware of... it will at least set this off a bit!
split in => split into
how about just saying:
... that should be used instead of this service:
(not say "in contrib and custom modules")
I'm a bit confused about why we're documenting services as "providing an interface" ??? These don't make sense to me.
It looks like these lines got taken from some interface one-line descriptions. Really I don't think this is the best way to document what the services do.
see above notes about "in contrib and custom modules" and "split in"
Um... This is a class, not an interface? Strange documentation.
interface? Please check the rest of these.
So... Really people cannot use this method directly. They need to get the service and call a method on it. I am not sure this is the best way to document what people should be using.
I would suggest something like:
Use the clearCachedDefinitions() method on the 'entity_type.manager' service instead.
The @see makes sense to me though, since it would lead to docs about the method they would call.
But shouldn't it be linking to an interface method instead of a particular class's implementation of it? If possible it should (if the interface exists).
See comment about the clearCachedDefinitions() method. Applies to this one too, and all the rest.
Comment above about @see also applies here, and to all the rest of the methods.
This one is missing the @see and/or has an extra blank line in the docs.
Also missing the @see.
Comment #15
tim.plunkettThese are not true, either point to the interface, or give it a concrete definition.
Okay, so it's more helpful than before, but I find this redundant. Either add it to the @deprecated, or use @see.
Also we usually point to interfaces.
Comment #16
claudiu.cristeaOK.
#14.9 and #15.2: This I fixed as @jhodgdon suggested in #14.2 because the
@see
will cause useful clickable links on api.drupal.org but also in most of IDEs.Comment #17
jhodgdonThanks! This is definitely looking better.
A few things still to fix:
... for loading entity types ... from entity types....
What does this mean? How can you load an entity type from an entity type?
Needs comma before "and"
needs comma before "and"
comma before "and"
This interface also handles entity form modes.
The list items in this section... see comments on the core.services.yml file above; all apply here as well.
Comment #18
claudiu.cristeaFixed all but...
#17.5
True but the term "entity display" refers to both, view and form. There are "entity view displays" and also "entity form displays". Both are descendants of \Drupal\Core\Entity\EntityDisplayBase abstract class. Also as entity display modes we have "view modes" and "form modes". So, I used the generic word and that is "display", covering "view" and "form".
#17.7
I prefer @see because is creating clickable links in the IDE but, I think, also in the api.drupal.org. In this case the main deprecation message is in the interface docblock:
because when you replace the deprecated element, you don't replace the method but implement a class directly from the correct interface. That's why I pointed to the correct interface in the interface header and not in each method. So methods got only simple deprecation statements and the @see statement to have a reference to the method from the correct interface.
Comment #19
jhodgdonGood point on #17-5 on display modes. I've never liked the terminology -- to me "display" is a synonym of "view", but that is not your fault. ;)
Regarding @deprecated, see
https://www.drupal.org/node/1354#deprecated
So the docs about replacement should be in each @deprecated tag docs itself, not in a separate @see section, even in the methods.... noted below.
"entity types related data" ... This is awkward wording/punctuation. It needs to be either
entity-type-related data
or
data about entity types
or maybe just
entity type data
Yes, I think that last choice would be the best, really. Sorry I didn't notice this in the last review.
And don't forget to update the class docs too.
reacting on -> reacting to
This applies to a bunch of spots in the docs, everywhere it says "reacting on". Sorry I didn't notice this in the last review.
And don't forget to update the class docs too.
Oh gracious.
I just realized that all of these @deprecated and @see tags are in with @inheritdoc.
You either need to have @inheritdoc by itself, or you need to have a proper docs header. This violates our standards and does not work on api.drupal.org -- it doesn't pick up the inherited docs. Check this method as it is now and you'll see this. And if you want to discuss the standard, the issue for that is #1994890: Allow {@inheritdoc} and additional documentation; PLEASE do not discuss the standard here. We just need to follow it for now.
So this needs to be fixed.
Probably wherever it is inheriting the docs from is where the @deprecated statement needs to be? Otherwise you'll need to copy the docs from there into here.
Applies to all of the methods.
This does need to have the replacement documented in the @deprecated tag. Please.
Here too.
Comment #20
claudiu.cristeaComment #21
jhodgdonOK, that looks better.
So the question remains: should we be putting the @deprecated on the class method, interface method, or both?
Comment #22
claudiu.cristeaYou mean in EntityManagerInterface? There needs to be on interface. You requested also on methods. IMO on interface is mandatory, I explained in #18 why.
Comment #23
jhodgdonSorry, I think my question was not understood.
Let's step back a moment.
We are deprecating (or rather have deprecated) the EntityManager class and all of its methods. In core currently, the EntityManager class and most of the methods already have @deprecated tags in their docs headers. However, they look like this:
which is not allowed.
The docs from these methods are intended mostly to be inherited (with additions, which is the part that doesn't work and violates our docs standards) from the corresponding EntityManagerInterface methods.
So my question is this:
Should the @deprecated tags be on the EntityManager methods (in which case they need to have full doc blocks and not try to use syntax like the above with "inheritdoc + more")? Or should the @deprecated tags be on the EntityManagerInterface methods? Or both?
Comment #24
claudiu.cristeaIf you look in EnityManagerInterface you will see that there are only 2 methods left there: getLastInstalledDefinition() and getLastInstalledFieldStorageDefinitions(). So, yes, we deprecate in EntityManager. And for those 2 methods, let's keep the deprecation in both. Nothing to lose, more clarity.
Comment #25
jhodgdonAh, right! Sorry, I missed seeing that. You even patched the EntityManagerInterface file's doc blocks. :)
I think this patch is ready to go then.
Comment #26
catchWhat's wrong with this from a coding standards point of view? It seems much more preferable to duplicated documentation onto a method that's been deprecated.
Also I'm not at all sure about this:
- the class docs are discoverable on api.drupal.org, this isn't.
- Not having profiled it, but I'd expect Symfony's YAML parser to have to parse these comments line by line and detect the '#', so there's potentially a small cost from adding this
- Symfony 2.8/3.0 adds a deprecation framework for services, so we could use that once we've updated and figured out how to integrate it. See #2611816-20: Update to symfony 2.8 and down for some discussion of that.
Comment #27
jhodgdonThere's a separate issue about "inheritdoc plus other stuff". It does not work and cannot be made to work like that, really it can't. It is also a violation of our coding standards, even though it is all over core unfortunately. See the lengthy discussion on #1994890: Allow {@inheritdoc} and additional documentation for details. I don't want to repeat the entire discussion here.
And I totally agree with you that putting the docs in .yml files is not all that great, which is why early on in this issue I insisted on getting the docs into the classes and methods too. Everyone else wanted to though... totally happy with that being overruled.
Comment #28
claudiu.cristea@catch, @jhodgdon I disagree with your point. Putting the deprecation messages in
core.services.yml
makes sense because the developers are jumping to that file to search for the right service to use. As a module developer, I'm keeping that file open most of the time. Imagine you are writing a module and you need to use a service. Where do you go first if you need to use the EntityTypeManager but you don't remember its service ID? Does api.drupal.org help you in some way? When I'm asking myself "What is the service ID of the EntityTypeManager", I'm quickly searching the answer incore.services.yml
. Or is api.drupal.org offering a quicker way to find the answer to this question? And when going there I wanted with this issue to prevent developers of using deprecated services. But there, there's no way there to find that EntityManager is deprecated.Related to performance. C'mon! That file is parsed once and then is cached. I don't see any regression here.
Comment #29
jhodgdonIt occurred to me... maybe we could move the deprecated services to a new file, called deprecated.services.yml -- I'm not sure whether the container would recognize it, but that would be one way to proceed without adding these docs to the core.services.yml file.
Comment #31
charginghawk CreditAttribution: charginghawk at Genuine commentedIn response to these two comments...
catch:
claudiu.cristea:
In fact, I search api.drupal.org using Google - "site:api.drupal.org MethodImSeeking" (or even without the "site:" filter) - and based on my interactions on IRC, many people refer to the api.drupal.org pages primarily as well. It's the power of the Google. IMO, documenting the replacement method on method pages is more important than class pages, because, Google again, there's more method pages and they're more likely to be the landing page for somebody working through this.
I'm for the patch in #20, and I think this issue should moved to major, because the EntityManager is a key class in D8, and currently accounts for the largest chunk of deprecated code (not to mention undocumented deprecated code).
Comment #37
BerdirI'm not certain if this should remain open, with the latest patch in #2886622: Deprecate all EntityManager methods with E_USER_DEPRECATED, all methods on EntityManager now have @trigger_error(), looks like the deprecation messages have also been improved since this patch was created. We can most likely not yet add an official @deprecated tag on the service because there will likely be *some* calls to it left.
Comment #42
quietone CreditAttribution: quietone as a volunteer commented@claudiu.cristea, thanks for bring this idea up and making patches.
According to the deprecation policy for services a deprecation message can be added to a service using the 'deprecated' key.
This was for Drupal 8 which is now EOL
Therefore, closing as outdated. If this is incorrect reopen the issue, by setting the status to 'Active', and add a comment explaining what still needs to be done.
Thanks!