As was decided in Prague in conclusion to #2051923: Rename \Drupal\Core\Entity\Field\Field, related subclasses and interfaces to *FieldItemList
(clarify the use of "Field" - value object or definition object ? see discussion notes)
The "definition objects for configurable fields and instances" are renamed FieldConfig / FieldInstanceConfig
API changes
This means the following renames
- classes / interfaces :
Fieldinterface -> FieldConfigInterface
Field -> FieldConfig
FieldStorageController -> FieldConfigStorageController
FieldInstanceInterfce -> FieldInstanceConfigInterafce
FieldInstance -> FieldInstanceConfig
FieldInstanceStorageController -> FieldInstanceConfigStorageController
- entity types
field_entity -> field_config
field_instance -> field_instance_config
- hooks:
hook_field_entity_(create|insert|update|delete)() -> hook_field_config_(create|insert|update|delete)()
hook_field_instance_(create|insert|update|delete)() -> hook_field_instance_config_(create|insert|update|delete)()
- yml files : unchanged
Remaining tasks
- Rename the storage controller classes
- Rename the interfaces (might be deferred to a followup to avoid the patch size exploding ?)
Change references to old names in the following change records:
- field_entity:
- Fields are no longer handled individually and are bound to an entity type
- hook_field_CRUD_field() and hook_field_CRUD_field_instance() hooks are replaced by hook_entity_CRUD().
- Field and field instance are now configuration entities
- Field Widget settings now stored independently to instance, new EntityFormDisplay config object
- Bundle CRUD API moved from Field to Entity API
- field_instance:
- Removed _text_sanitize() and safe_value/safe_summary in favor of processed/summary_processed
- Fields are no longer handled individually and are bound to an entity type
- Field types are now plugins
- hook_field_CRUD_field() and hook_field_CRUD_field_instance() hooks are replaced by hook_entity_CRUD().
- Field and field instance are now configuration entities
- Field Widget settings now stored independently to instance, new EntityFormDisplay config object
- Field UI form_id (and URL) changes
- FieldInstance:
- Configuration entities support the links annotation for much easier URI specification
- Field and field instance are now configuration entities
- theme_options_none() is replaced by hook_options_list_alter()
- FieldInterface:
- \Drupal\Core\Entity\Field\Field, related subclasses and interfaces renamed to *FieldItemList
- Added FieldDefinitionInterface. Most code that in D7 interacted with $field and $instance arrays should instead interact with this unified interface.
- Field types can define the UI for their "default values"
- File formatters need to manually check the 'display' property of each item
- Field formatters are now plugins
Follow ups:
- #2200821: Rename Fieldinterface and FieldInstanceInterface
- #2201087: Rename hook_field_update_forbid to hook_field_config_update_forbid
Comment | File | Size | Author |
---|---|---|---|
#59 | field_config_entities_rename-2095303-59.patch | 231.98 KB | plopesc |
#56 | field_config_entities_rename-2095303-56.patch | 231.87 KB | plopesc |
#54 | field_config_entities_rename-2095303-54.patch | 231.56 KB | plopesc |
#43 | field_config_entities_rename-2095303-42.patch | 227.34 KB | yched |
#41 | 2095303-41.patch | 308.17 KB | plopesc |
Comments
Comment #1
swentel CreditAttribution: swentel commentedtagging
Comment #2
swentel CreditAttribution: swentel commentedJust testing .. currently discussing also whether to rename field_entity / field_instance to different id's or not.
Comment #3
swentel CreditAttribution: swentel commentedAlso rename the classes to FieldConfig en FieldInstanceConfig.
Comment #5
swentel CreditAttribution: swentel commentedWith the renames.
Comment #6
yched CreditAttribution: yched commentedThat's probably the automated search / replace, but I'm not sure we want to rename those (& a couple other ones in entity_ref)
Comment #8
swentel CreditAttribution: swentel commentedFixed that - not sure why Drupal can't install though yet.
Comment #10
swentel CreditAttribution: swentel commented#8: 2095303-8.patch queued for re-testing.
Comment #12
jthorson CreditAttribution: jthorson commentedTestbot debugging:
During install, after the configuration page where you enter the site name, admin username/password, timezone, etc, and submit ... the site returns with "The field_config entity type does not exist".
This shows up as text on the install page, with nothing written to the apache exception log.
Comment #13
swentel CreditAttribution: swentel commentedThank you! Found it. Just giving a testbot run now, need to rename the storage controller and interfaces as well.
Comment #15
swentel CreditAttribution: swentel commentedComment #17
swentel CreditAttribution: swentel commentedComment #19
swentel CreditAttribution: swentel commentedrerolling
Comment #21
swentel CreditAttribution: swentel commentedComment #23
swentel CreditAttribution: swentel commentedMajor reroll
Comment #25
BerdirRe-roll, cleaning up the array BC removal, fixing some tests. The field instance edit form problem was related to some symfony black magic that maps request attributes to the name of the variable of the buildForm() method, had to change field_config there to field_config_instance, that should fix a lot of fails.
Not sure why the patch is so much smaller, there are a few instances where changes are no longer necessary, .e.g removed use's.
Comment #27
Berdirfield_instance_config_config... yeah... ;)
Comment #29
claudiu.cristeaFix in hook presave of image.module
Comment #30
amateescu CreditAttribution: amateescu commentedThese comments need to be rewrapped.
How it this related? :)
Needs to go..
Note for further reviewers: This patch will bore you to death!
Comment #32
claudiu.cristeaRenamed interfaces
Comment #34
BerdirLet's not rename the interfaces just yet...
This is #27 + the interdiff of #29 (the patch in #29 seems to be too big?)
Comment #35
BerdirThis script is meant to run in a 7.x environment I think and generate content that then can be exported into a dump to be used for upgrade path tests. But it was already broken before this change, so not sure what to do.
Comment #36
amateescu CreditAttribution: amateescu commentedI'd say revert the changes done by this patch and open a new issue to bring the old code back..
Comment #37
Berdir34: 2095303-34.patch queued for re-testing.
Comment #39
swentel CreditAttribution: swentel commentedunassinging for now
Comment #40
plopescNew patch from scratch. Let's push this issue.
This patch does not rename the interfaces or the Storage Controller as suggested in #13 yet.
Let's see testbot against this monster patch.
Regards.
Comment #41
plopescRe-rolling the monster patch...
Comment #42
yched CreditAttribution: yched commentedReroll - should be a tad smaller because D7 -> D8 hook_update_N()s have been removed from core, so patch has a bit less hunks.
Also, pushed to the field_config_entities_rename-2095303 branch in the sandbox, should help for later rerolls.
Will try to review this asap.
Comment #43
yched CreditAttribution: yched commentedBetter with an upload...
Comment #44
plopescThank you for re-rolling @yched!
Before reviewing, maybe we should decide if we have to rename also the interfaces and the storage controller as proposed @swentel in #13 or keep them as they are now, as suggested @Berdir in #34 (maybe to avoid an even bigger patch).
Any thoughts?
Comment #45
yched CreditAttribution: yched commentedYes, we do want to rename the interfaces & storage controller in the end.
For the interfaces, might be wiser to defer to a followup patch, or at least wait for the current patch to be RTBC. The storage controllers probably have a much smaller impact, maybe we could do that now ?
Comment #46
yched CreditAttribution: yched commentedside note : git diff --word-diff really helps reviewing this :-)
No need to rename $field_instance to $field_instance_config if the $field variable in the same method isn't renamed similarly (and I'm not in favor of renaming it - keeping variables named $field / $instance or $field_instance is fine IMO)
We should actually remove that property now. Earlier in the D8 cycle we used to populate this property ourselves, but it's now populated automatically by the Entity::save() flow, it's not a real property of our own anymore.
Same in FieldInstanceConfig.
We should switch to the new core convention instead (#2158497: [policy, no patch] Use "$this" and "static" in documentation for @return types) :
@return $this
(with no description text - look for other examples of the above in core)Actually, those should rather test $entity->getEntityTypeId()
the var name in image_field_config_update() / image_field_config_delete() is still $field
so similarly, we could just keep $field_instance here.
Same for image_field_instance_config_delete()
Also, while we're in there, those hooks should hint at the interfaces instead.
We could cleanup that code a bit.
The $field and $instance *arrays* are useless, they could be inlined in the entity_create() calls
Then the instance *object* that the method returns can just be named $instance.
Same, should hint at the interfaces
I'd tend to keep $field_instance (same for the other hooks below)
Comment #47
yched CreditAttribution: yched commentedFilled in a real issue summary.
Comment #48
yched CreditAttribution: yched commentedFill in missing tags - the change has been approved in Prague
Comment #49
andypostControllers should be addressed in follow-up issue, probably in one of #1976158: Rename entity storage/list/form/render "controllers" to handlers
Comment #50
BerdirNo, that issue is not related. but it could conflict with it, so maybe separate issue?
Comment #51
yched CreditAttribution: yched commentedHm - #1976158: Rename entity storage/list/form/render "controllers" to handlers has no patch to conflict with ?
I'd rather keep a consistent set of classes here (FieldConfig / FieldConfigStorage), rather than saying "some patch is going to rename those classes some day, let's not touch them and break consistency meanwhile" ?
Comment #52
BerdirAh, we currently only have a storage controller for each of them and nothing else. Let's do it then ;) I thought there would be more. Shouldn't there be?
Comment #53
yched CreditAttribution: yched commented@berdir:
field_ui_entity_info() adds:
- FieldListController - "list" controller for fields
- FieldDeleteForm - "delete" form controller for *instances* (so it's kind of misnamed already)
I guess we might rename them as well...
FieldConfigListController
FieldInstanceConfigDeleteForm
?
Comment #54
plopescNew round addressing comments in #46 and #53.
Let's see testbot...
Comment #55
yched CreditAttribution: yched commentedNeeds a reroll after #2119905: Provide @ConfigEntityType and @ContentEntityType to have better defaults
(@plopesc already merged latest HEAD in the sandbox, just needs re-uploading here)
Other than that, this is RTBC IMO. Thanks @plopesc !
Adding the "avoid commit conflict" tag.
Comment #56
plopescNew Re-roll
Comment #59
plopescNew roll
Comment #60
swentel CreditAttribution: swentel commentedShamelessly pulling the trigger.
Comment #61
alexpott59: field_config_entities_rename-2095303-59.patch queued for re-testing.
Comment #62
swentel CreditAttribution: swentel commentedComment #63
alexpottCommitted 40dc8da and pushed to 8.x. Thanks!
Followups:
During the commit I made the following fixes:
Comment #64
swentel CreditAttribution: swentel commentedcreated #2201087: Rename hook_field_update_forbid to hook_field_config_update_forbid
Comment #65
plopescAfter a search word by word in the change records list, here is the full list of change records containing the names that has been changed in this issue and it follow-ups
- field_entity:
- field_instance:
- FieldInstance:
- FieldInterface:
- FieldInstanceInterface:
- FieldStorageController:
- FieldInstanceStorageController:
From tomorrow, I will start to replace word by word all the references in the issues listed above.
Regards
Comment #66
plopescComment #67
plopescReviewed and changed references in change records referenced in #65