entity_label()
exploits entity keys to return the entity label unless a 'label callback'
is defined. Atm the label callback is called without passing along the [entity] $type
parameter, thus making impossible implementing a callback generalizing entity label handling (see http://drupal.org/project/title).
Comment | File | Size | Author |
---|---|---|---|
#12 | entity_label-1096446-6.patch | 2.67 KB | plach |
#8 | entity_label-1096446-8.patch | 3.34 KB | plach |
#6 | entity_label-1096446-6.D7.patch | 2.67 KB | plach |
#6 | entity_label-1096446-6.patch | 2.67 KB | plach |
#3 | entity_label-1096446-3.patch | 2.71 KB | plach |
Comments
Comment #1
plachComment #3
plachIt was
$entity_type
instead of$type
(we should uniform this elsewhere).The attached patch updates the documentation accordingly.
Comment #4
Tor Arne Thune CreditAttribution: Tor Arne Thune commentedSubscribing
Comment #5
tstoecklerCode looks good, haven't tried it out, though.
Elsewhere we use
foo($entity_type, $entity)
instead offoo($entity, $entity_type)
. It makes sense to do this here, for backwards compatibility with D7, but since this is marked against 8.x, it does seem a bit weird.Comment #6
plachAgreed.
Rerolled the patch for D7 and changed the argument order in the D8 one.
Comment #7
tstoecklerI just looked through all core invocations of hook_entity_info() and found field_test_entity_label_callback. The tests should not pass because of that. I don't really know why that test is in the Field scope not in the Entity scope, but I guess that's not for this issue.
Comment #8
plachOops, here is a D8 version taking care of tests.
Comment #9
tstoecklerAwesome. This is RTBC.
After committing to D8, http://drupal.org/files/issues/entity_label-1096446-6.D7.patch is RTBC against D7.
Comment #10
Dries CreditAttribution: Dries commentedCommitted to 8.x.
Moving to 7.x for webchick to consider as this is a (small) API change.
Comment #11
plach@Dries:
Thanks :)
@webchick:
As pointed out in #5 the API change is backward compatible, so it should be a harmless change.
Comment #12
plachHere is the D7 RTBC patch from #6 for the bot.
Comment #13
tstoecklerSince http://drupal.org/project/title needs this (among probably others in the future), it's not only a "nice-cleanup" kind of thing, but actually quite needed for getting something like Title in D8 core.
Patch is still RTBC.
Comment #14
andypostSuppose D8 should have the same argument order or we stuck with contrib update|upgrade
D7 version is not forware compatible with D8? Any reason has different signatures?
D8 version been commited is different arguments order from D7
Powered by Dreditor.
Comment #15
plach@andypost:
As explained in #12 this is a design choice to preserve backward compatibility: there might be contrib/custom code around implementing a label callback and adding a parameter in first position would break it whereas appending one would not.
This (already) is nothing more than an API change between D7 and D8, we will see gazillions of them I guess.
Comment #16
tstoecklerRemoving backport tag now.
Comment #17
webchickI'm confused. Does this need backport to D7 or not? If so, why was the tag removed?
Comment #18
Tor Arne Thune CreditAttribution: Tor Arne Thune commentedYes
Comment #19
tstoecklerOh sorry, I thought the tag was to be used for D8 issues that should be assigned to D7 after commit, that's why I removed it. Yes it should be applied to D7.
Comment #20
sunCan we get this in, please? The backported patch seems to be RTBC for D7.
Comment #21
catchI don't see any update documentation added here, is it needed? Adding tag anyway.
Comment #22
plachWhat do you mean? The second hunk is all about updating the documentation...
Comment #23
catchSorry I meant http://drupal.org/update/modules/6/7
There's not a 7/8 page yet (and there is the issue to make API changes node types), but this looks like it could use a mention.
Comment #24
tstoecklerI added a 7.x to 8.x update docs page: http://drupal.org/node/1152742
And added this as the first item.
That would probably need to be updated if the D7 patch got in.
Comment #25
plachComment #26
webchick#12: entity_label-1096446-6.patch queued for re-testing.
Comment #27
webchickThis seems like it should be pretty harmless. If not, there's always another week or so to test.
Committed to 7.x. Thanks!
Comment #28
tstoecklerUpdated the module update documentation: http://drupal.org/node/1152742#label-callback-params