Functions to be replaced
entity_reference_field_update_field
image_field_update_field
image_field_delete_field
image_field_update_instance
image_field_delete_instance
options_field_update_field
views_field_create_instance
views_field_update_instance
views_field_delete_instance
field_test_field_create_field
field_test_field_delete_instance
Functions to be removed
field_sql_storage_field_create_field
API changes
hook_field_read_field()
hook_field_create_field()
hook_field_update_field()
hook_field_delete_field()
hook_field_read_instance()
hook_field_create_instance()
hook_field_update_instance()
hook_field_delete_instance()
are replace by hook_ENTITY_TYPE_OP.
Comment | File | Size | Author |
---|---|---|---|
#36 | 2013939-36.patch | 25.7 KB | pcambra |
#36 | interdiff.txt | 633 bytes | pcambra |
#34 | 2013939-33.patch | 26.01 KB | pcambra |
#31 | 2013939-31.patch | 26.12 KB | amateescu |
#31 | interdiff.txt | 1.25 KB | amateescu |
Comments
Comment #1
swentel CreditAttribution: swentel commentedJust a quick test on deleting hook_field_delete_field as there's only one implementation.
Also note to self, need to look for hook_field_read_field and hook_field_read_instance implementations.
Comment #2
swentel CreditAttribution: swentel commentedComment #3
swentel CreditAttribution: swentel commentedThis should have them all - except for
read
Comment #5
swentel CreditAttribution: swentel commentedFixes the image tests.
Comment #6
amateescu CreditAttribution: amateescu commentedThis doesn't look right :)
Comment #8
swentel CreditAttribution: swentel commented@amateescu - haha. Note, in case someone starts screaming for a test, do that in a follow up!
In the meantime, fix the rest of the tests.
Comment #9
swentel CreditAttribution: swentel commentedAnd last hooks: goodbye hook_field_read_field() and hook_field_read_instance()
Comment #10
swentel CreditAttribution: swentel commentedThat was so totally wrong
Comment #11
yched CreditAttribution: yched commentedThanks for this !
For performance, I guess it's recommended to rather implement hook_[ENTITY_TYPE]_[OP]() ?
The "generic" hook_entity_[OP]() are there for the cases where you want to react for all config entities, or all fieldable entities...
(also applies to the other hook migrations in the patch ?)
Something looks weird here. $entity->type is checked twice with BC/array and object syntax ?
Since this code is de facto new code, I'd say it should not continue using the BC array syntax. $entity['foo'] definitely looks weird :-)
(same for the new image_entity_[op]() implementations)
double $$
(and switch to ->id() ?)
That's a property that only exists at a specific point in the object lifecycle (during save() if updating an existing field entity), but is documented as always being present. We should move field_has_data() to a method on the Field entity IMO.
Not great either, for the same reasons. Less sure about how we can make that better, though.
This looks like a more general issue with hook_entity_update().
I opened #2017809: how do hook_entity_update() implementations access the "previous" state of the entity ? for this.
No better suggestion for now, let's leave it that way here, I guess...
(same for FieldInstance::$originalInstance - maybe at least name both properties just "$original" ?)
Nitpick: I think core tends to avoid starting function bodies with an empty line.
Comment #12
swentel CreditAttribution: swentel commentedBeen looking for that, but this doesn't seem to be supported, unless I'm really stupid ...
Will look at the other ones this evening.
Comment #13
yched CreditAttribution: yched commentedhook_[ENTITY_TYPE]_[OP]() :
see ConfigStorageController::invokeHook()
Comment #14
swentel CreditAttribution: swentel commentedOh, crap shoot me, I just saw
and was like, damn, that's sad. Note to self: click the actual method, djeezes.
Comment #15
yched CreditAttribution: yched commentedNope, /me won't shoot @swentel
Comment #16
swentel CreditAttribution: swentel commentedThis is pretty badass now. Not sure if the interdiff is useful as it's pretty big :)
- Changed all hooks - talked to timplunkett how the docblock should be for it.
- removed BC where possible
- The 'original' properties are the same
- I left hasData as is for now as it's also used in hook_update_forbid and I didn't want to start touching those hooks as well. I'm fine with a follow up if you're ok with that
- One line nitpicks :)
Let's see if I didn't forget anything.
Comment #18
swentel CreditAttribution: swentel commented#16: 2013939-16.patch queued for re-testing.
Comment #19
yched CreditAttribution: yched commentedOK, let's go with a followup for hasData.
IMO we could write:
which would make code in the func body much easier to understand.
Maybe even :
but I'm less sure about that.
Comment #20
swentel CreditAttribution: swentel commentedGood point, I'll see how it behaves with FieldInterface or FieldInstanceInterface
Comment #21
swentel CreditAttribution: swentel commentedAlright, filed #2018731: Move field_has_data() to Field::hasData()
Comment #22
swentel CreditAttribution: swentel commentedSeems to work fine
Comment #23
yched CreditAttribution: yched commentedLooks good :-)
RTBC if green.
Comment #25
yched CreditAttribution: yched commented"Argument 1 passed to field_test_field_instance_delete() must be an instance of FieldInstanceInterface, instance of Drupal\field\Plugin\Core\Entity\FieldInstance given"
This looks like a missing "use" statement for FieldInstanceInterface in field_test.something :-)
Comment #26
swentel CreditAttribution: swentel commentedYes indeed :) Found two minor docblock mistakes too while fixing it.
Comment #27
yched CreditAttribution: yched commented... if green
Comment #28
yched CreditAttribution: yched commentedRelated : #2020895: Move save() / delete() logic in Field / FieldInstance to [pre|post]Save(), [pre|post]Delete()...
(this one is still RTBC, though)
Comment #29
amateescu CreditAttribution: amateescu commentedRerolled.
Comment #31
amateescu CreditAttribution: amateescu commentedNeeded some more updates for #1818568: Convert files to the new Entity Field API.
Comment #32
alexpottNeeds a reroll
Comment #33
swentel CreditAttribution: swentel commentedThere's more todo than a reroll because of #2018731: Move field_has_data() to Field::hasData()
Comment #34
pcambraActually
entity_reference_field_update_field
is the conflicting function and there's no "has data" check there, so here's a re-roll #31Comment #35
swentel CreditAttribution: swentel commentedThis should go now, people need to use the static method if they want to use it.
Comment #36
pcambraRemoving has data reference mentioned in #35
Comment #37
swentel CreditAttribution: swentel commentedSweet!
Comment #39
swentel CreditAttribution: swentel commented#36: 2013939-36.patch queued for re-testing.
Comment #40
swentel CreditAttribution: swentel commentedComment #41
effulgentsia CreditAttribution: effulgentsia commented#36: 2013939-36.patch queued for re-testing.
Comment #43
effulgentsia CreditAttribution: effulgentsia commented#36: 2013939-36.patch queued for re-testing.
Comment #44
effulgentsia CreditAttribution: effulgentsia commentedBack to RTBC. Sorry for the noise. Just wanted to make sure it still passed after other Field API commits in the last 12 hours.
Comment #45
alexpottCommitted 5ff3e98 and pushed to 8.x. Thanks!
Comment #46
yched CreditAttribution: yched commentedChange notification added at https://drupal.org/node/2054619
Comment #47
yched CreditAttribution: yched commentedMore accurate title for posterity
Comment #48.0
(not verified) CreditAttribution: commentedUpdated issue summary.