Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
entity system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 May 2015 at 19:14 UTC
Updated:
9 May 2019 at 15:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
cilefen commentedComment #2
xjmThanks @cilefen for filing this!
Per #2495301: Deprecate user_format_name() and the label_callback for 9.x (not 8.x) and #2311219: Fix hook_user_format_name_alter() documentation and stop referring to user_format_name() I think we also need to deprecate the label_callback key for 9.x explicitly in order for the deprecation for
user_format_name()to be correct/complete. I think it'd be alright to do this in one patch. It would involve:EntityType.EntityTypeInterface::getKeys().Anything I'm missing?
Comment #3
xjmAh, we also need to document what to do instead for the label callback. #2450793: Properly deprecate support for entity type label callbacks suggests overriding the
label()method, but AFAIK this would only work for subclasses (i.e. the module that defines the entity), whereas I think one could alter thelabel_callbackinhook_ENTITY_TYPE_build()orhook_ENTITY_TYPE_alter(). I pinged @Berdir for feedback.Comment #4
xjmComment #5
xjmAh, there's more we would need to deprecate, from the summary of #2450793: Properly deprecate support for entity type label callbacks:
Comment #6
berdirSounds about right.
4. Isn't going to happen before 9.x because that would essentially mean that is no longer supported.
5. As commented before, we can actually stop using it as a label callback internally in the user entity without removing the function completely. We're still doing all kinds of code cleanups to reduce technical dept and I can see an argument for doing that. But that's up to the core maintainers to decide in the end :)
Comment #7
andypostRelated issues has collision but but doc block should also point to right interface
9.0 is mostly all over core... is there a rule about?
Also "Use ...AccountInterface:: ..." - function should point to right interface
Comment #8
alivadniy commentedaddressed #7
Comment #10
dcmul commentedDone 1-3 , as we wait for feedback.
Comment #11
andypostThe only broken place
This sentence incomplete, suppose better mention that it would be removed when alternative solution will be found and point to isue
Comment #12
naveenvalechaDo we need to file a new followup for the same? Have question so not changing the issue status.
Comment #13
deepakaryan1988Comment #14
deepakaryan1988Comment #15
deepakaryan1988Sorry bymistake I change the issue status to needs review :(
Comment #16
mile23This function has already been marked as @deprecated, so when the patch applies, it's marked as @deprecated twcie.
This is probably the case for other functions here, as well.
Also, @see comes after @deprecated. https://www.drupal.org/coding-standards/docs#order
Again, @todo comes after @deprecated, and @see.
Comment #17
mile23I suggest not modifying entity.inc and letting that happen here: #2474151: Mark procedural wrappers in entity.inc as deprecated
Comment #18
jeroentAddressed feedback given by Mile23 in #16 + removed changes in entity.inc file.
Comment #19
borisson_Reworded the comment for getKeys and fixed a small typo.
Comment #20
andypostThey are deprecated at interface definition, so this inherited all over.
please remove that
Comment #21
jeroentRemoved the deprecate comments in EntityType class.
Comment #22
andypostI think no reason to have @todo in each deprecated function so RTBC
Comment #23
alexpottWe still telling people to use label_callback. When we deprecate we have to have to be to tell people what to do instead. I think that is implement Entity::label() on their on object.
Comment #24
dcmul commentedHopefully this addresses #23. Thank you for the review.
Comment #25
dcmul commentedFor the testbot to kick in.
Comment #26
andypostLooks each deprecated method needs point what to use instead
Comment #27
mile23EntityTypeInterface::getLabelCallback()is documented as returning a callable.Therefore,
EntityType::label_callbackshould also be a callable (or NULL) rather than a string.This issue should also remove the
label_callbackannotation fromDrupal\user\Entity\Userclass, since all it does is *wrongly* calluser_format_name()which gives us the name, not the label.There should also be a way to denote deprecation for 8.1.x, but apparently that doesn't exist. All the subordinate postponed issues punt on this until 8.1.x, not 9.x. Because this is the system, we *must* support this under-documented, poorly-considered API beyond 8.1.
Still boggles my mind that this is the kind of thing that gets swept under the rug, even when all the work is already done, simply because it doesn't count as 'critical.'
Comment #28
mohit_aghera commented@Mike23
Thanks for your hint.
I have updated patch as per your guidance.
Comment #30
mohit_aghera commentedComment #32
mile23Going back to #24 because #28 and #30 have unneeded deletions.
Some doc tweaks to explain reality better, added a bunch of @see, addressed changes from #27.
Comment #34
mile23Without the 'code' change.
Needs a followup to figure out what User's label_callback should actually be.
Comment #35
mile23Comment #36
jeroentPatch looks good by me and I think that the concerns of alexpott in #23 are addressed now.
Comment #37
mile23Still applies. :-)
Comment #38
mile23Until this is in, user_format_name() is still deprecated for removal before 8.0.0.
Comment #39
alexpottCommitted 5a508f5 and pushed to 8.0.x. Thanks!
Comment #42
wim leersThis came up at #3042745-19: Remove group @legacy from jsonapi tests and fix deprecation messages.1
This does not have a published change record. I think https://www.drupal.org/node/2481845 was intended to be the change record for this commit?
Reopening this to clarify the change record situation.
Comment #43
berdirI commented in your issue, a CR wouldn't have helped you since that usage of this function was never correct anyway, so a CR would not have helped you, a CR can only target those that are correctly using it, meaning, entity types.
We can add a CR in #2450793: Properly deprecate support for entity type label callbacks, when we actually deprecate I'd say.
Comment #44
wim leersIt already is, isn't it?
Comment #45
wim leersQuoting @Berdir from #3042745-21: Remove group @legacy from jsonapi tests and fix deprecation messages:
So that method does have a
@deprecatedannotation, but it actually does not mean "this method is deprecated", it means "this method is deprecated for certain reasons for calling it"?Comment #46
berdir> It already is, isn't it?
Yeah. For me, deprecations that aren't enforced and core is still relying on are fake/pseudo deprecations, per our current rules, we can only deprecate something if stop relying on it in core and enforce it with @trigger_error(). I only consider something really deprecated after that.
The concept of having a label callback is deprecated and unnecessary, you can just implement label now(). That means also the method to access that callback is. And nothing except the default label() implementations of EntityBase and ContentEntityBase should have ever called it in the first place, that is the only proper use case for it.
Comment #47
andypostI'm ++ on broader discussion cos "label" field used not consistently (label(), getName()/getWhatever() and magic getter)
Comment #48
berdirAs suggested, lets continue this discussion in the issue that's still open: [#https://www.drupal.org/project/drupal/issues/2450793]
Comment #49
wim leers#46: thanks for that extra context, I didn't realize that distinction until now.