Whatever the outcome of the "hardcoded UUIDs in shipped config files" discussion, it will probably require that field.instance.*.yml files stop referencing fields by their uuid. It would make things clearer anyway.
The Entity API cleanups and refactorings that happened since the original "convert Field API to CMI" patch should make that possible now.
| Comment | File | Size | Author |
|---|---|---|---|
| #44 | instance_yml-field_uuid-2143519-44.patch | 1.19 KB | swentel |
| #35 | instance_yml-field_uuid-2143519-35.patch | 1.16 KB | yched |
| #30 | field_uuid_in_instance_yml-2143519-29.patch | 13.29 KB | wim leers |
| #18 | interdiff.txt | 871 bytes | yched |
| #18 | field_uuid_in_instance_yml-2143519-18.patch | 13.3 KB | yched |
Comments
Comment #1
yched commentedHaving a crack at this
Comment #2
yched commentedLet's see what breaks.
Comment #4
yched commentedComment #6
yched commented4: field_uuid_in_instance_yml-2143519-3.patch queued for re-testing.
Comment #7
alexpottSo this takes priority why? For deleted fields, right? I think we should say this here. Also do you think it is worth making it so this will ONLY be used for deleted fields?
Comment #8
yched commentedYes, deleted instances have an additional "field_uuid" property, but I don't want to break if the "field_name" property is still there (it is not "wrong" per se, it's just not the one we want to use for determining which field to use).
So the logic is:
- use the field_uuid if present
- else use the field_name, excluding deleted fields
Making this work only on deleted fields: probably a good idea. Lets us get rid of a field_read_fields() call, so attached patch goes with that.
Comment #10
yched commentedHah, so, you can be a deleted instance of a non-deleted field.
In that case, you have a field_uuid property, but your field is not deleted.
I feel a bit uncomfortable about enforcing that this only gets used by deleted instances actually. I'd rather punt on that for now.
Also, until #1503314: Remove the concept of active / inactive (field types, storage) from Field API gets in (patch should be ready, needs committers feedback on comment #25 ;-)), we still need to account for the case of "inactive, deleted" fields.
So updated patch basically just moves the existing "if field_uuid specified" case on top of the "if entity_type / field_name specified" case, so that it takes precedence.
Comment #11
yched commentedReroll after #2020895: Move save() / delete() logic in Field / FieldInstance to [pre|post]Save(), [pre|post]Delete()
Comment #13
yched commentedForgot a chunk in the reroll.
Comment #14
sunI'd like to better understand this change proposal.
Could you explain why it is a good idea to replace a hard and unique reference ID with a soft reference ID whose target can be switched out and may not be the originally intended target?
I understand the point being made that UUIDs are "ugly" for humans, but
1) I thought we had concluded and decided that humans rarely need to open/touch the raw config files a year ago already, so human-readable configuration file values aren't a priority?
2) Architecturally, we're talking about dependency management here — the weaker the link, the more error-prone is the application. (?)
2.1) Especially when syncing any kind of data between site instances, as a developer or site builder, I'd prefer to have a 100% guarantee that all (entity) references are pointing to the actually intended targets (and not something else by bad luck or coincidence).
2.2) However, I could see the point of this change proposal when limiting its scope to the case of importing default configuration — because e.g. the "body" field will have a different UUID on every installed site. In turn, as a contrib module developer, I cannot provide a default field instance that references the "body" field, as I only know the field name but not its UUID.
If the purpose of this change proposal is 2.2) then I'd think it would make more sense to store both the field_name and the field_uuid in field instance configurations, use the UUID where available, and only support field_name based configuration imports as a fallback where no UUID is known?
Comment #15
yched commented@sun:
Yup, the purpose is 2.2. As per #2121751: [META] Making configuration synchronisation work, we're moving away from "hardcoded UUIDs in default config", in favor of #2133325: Create a site UUID on install and only allow config sync between sites with the same UUID, and a prerequisite is that field instances shipped in default config stop referring to their field by its UUID.
Only non-deleted fields and instances are stored in config, and for those an [entity type, bundle, field_name] is unambiguous. Deleted fields and instances, for which we need a field_uuid in the instance, are stored in state, and there we make sure the field_uuid is present. So in regular runtime operations, field_uuid is not needed in config.
Now that you mention it though - hm, I can indeed think of race conditions during config sync where that would be an issue :-/ So yeah, writing back the field_uuid on save might be a good thing...
Working on it.
Comment #16
yched commentedLet's see this.
Interdiff attached, but this is mostly reverts, so looking at the patch probably makes more sense.
Comment #17
swentel commentedObsolete space at the end. Looks good to me other than that.
Comment #18
yched commentedYup, fixed.
Comment #19
swentel commentedNice - sweet DX++ too.
Comment #21
swentel commented18: field_uuid_in_instance_yml-2143519-18.patch queued for re-testing.
Comment #23
yched commented18: field_uuid_in_instance_yml-2143519-18.patch queued for re-testing.
Comment #25
yched commented18: field_uuid_in_instance_yml-2143519-18.patch queued for re-testing.
Comment #26
yched commentedMore accurate title
Comment #27
catchCommitted/pushed to 8.x, thanks!
Comment #28
catchRolled this back - undefined method getFieldName() broke the installer.
Comment #29
swentel commentedOh yeah, #2143263: Remove "Field" prefix from FieldDefinitionInterface methods broke that.
Comment #30
wim leersIndeed, #2143263: Remove "Field" prefix from FieldDefinitionInterface methods was committed first and renamed
getFieldName()togetName(). Then this patch got committed, which still usedgetFieldName(). Hence: kaput.Simple reroll, with only the
getFieldName()line changed.Comment #31
yched commentedIndeed, sorry, should have thought of this one :-/
Thanks for the reroll, @Wim. #30 should be good.
Comment #32
yched commentedGreen, back to RTBC
Comment #33
catchThanks! Re-committed.
Comment #35
yched commentedThose field_uuid entries we left in field.instance.*.yml are going to be problematic for default config.
As discussed in #2133325: Create a site UUID on install and only allow config sync between sites with the same UUID, the most common real-life workflow is going to be "I populate my module's config/ folder by picking and copying real yml files from my active config".
So we will find leftover 'uuid' and (in the specific case of field.instance.*.yml) 'field_uuid' entries in the default config/ we import.
The direction over there is that 'uuid' entries will just be silently ignored / overwritten by a fresh UUID by the "import default config" process.
But this doesn't apply to our specific field.instance.* 'field_uuid' here, the config system doesn't know about it and won't clean it up. So if present, it will be taken into account in FieldInstance::__construct() and die with a bang because there's no actual field with that UUID...
Attached patch only considers an incoming 'field_uuid' if there's also a 'uuid' present too - i.e it's a yml file from a real "active config" folder. That would work *if* the "import default config" process actually *removes* the leftover 'uuid' entries it finds in default config before doing the corresponding entity_create().
Comment #37
yched commented35: instance_yml-field_uuid-2143519-35.patch queued for re-testing.
Comment #38
swentel commented35: instance_yml-field_uuid-2143519-35.patch queued for re-testing.
Comment #39
alexpottAnyway to test this?
Comment #40
yched commentedThe real-life test case would be to test the import of a field.instance with both 'field_uuid' & 'uuid' leftover entries, since this is what files copied from an active store will look like.
The fix in this patch assumes that leftover 'uuid' entries left in config/ folders will be discarded by the "config import" mechanism before they reach the entity_create() step. Is that the case already ?
If not, one way to test this would be to put in some_test_module/config a field.instance file with a leftover 'field_uuid' but no 'uuid'. Would fail on HEAD and pass with the patch.
But ultimately it would be better to test the real life case.
Comment #41
alexpottThe config installer does not discard or error on existing UUIDs yet. Perhaps this issue should become the more general fix since it has a good chance of providing a test case?
Comment #42
yched commented@alexpott: you mean changing the config installer to discard incoming uuids here in this issue ? Why not, but we're already a followup of a committed patch here.
(#35 is only a one line change and is tightly related to the 1st patch that went in, so it seemed easier to keep it tied to the earlier discussion)
Your call :-)
Comment #43
sunClosely related: #2181631: Use custom block id instead of uuid for plugin derivative id
Comment #44
swentel commentedRerolled, tentatively moving to RTBC so Alex will actually see the answers.
I'd vote for commit here too anyway as it's small.
Comment #46
swentel commentedUrg, imagedisplaytest
Comment #47
catchThis would have been better in a new issue, I got very confused reading it. Since Alex was mentioned by name, moving to him to give a chance to look at it.
Comment #48
alexpott44: instance_yml-field_uuid-2143519-44.patch queued for re-testing.
Comment #49
alexpottCommitted 33ade8c and pushed to 8.x. Thanks!