Updated: Comment #N
Problem/Motivation
The picture module saves configuration files with keys with a dot in them. For example:
id: mapping_one
uuid: 2638a632-9d17-4aa3-b204-4f81e8976db8
label: 'Mapping One'
mappings:
custom.user.small:
1x: thumbnail
2x: ''
custom.user.medium:
1x: medium
2x: ''
custom.user.large:
1x: large
2x: ''
breakpointGroup: atestset
status: true
langcode: en
The use of the breakpoint id, for example custom.user.small
does not work out for config because a dot in a config key has a special meaning - the next level in the array. So if you did \Drupal::config('picture.mappings.someentity.yml')-get('mappings.custom.user.small.1x')
it would not return a value of thumbnail
. This would expect the format to be something like:
id: mapping_one
uuid: 2638a632-9d17-4aa3-b204-4f81e8976db8
label: 'Mapping One'
mappings:
custom:
user:
small:
1x: thumbnail
2x: ''
medium:
1x: medium
2x: ''
large:
1x: large
2x: ''
breakpointGroup: atestset
status: true
langcode: en
Additionally dots inside config key names completely break config schemas.
Proposed resolution
We have two possible solutions:
- Make the picture mapping config entity produce configuration as described in the second YAML structure above
- Translate the breakpoint id to not contain dots
Remaining tasks
- Agree solution
- Create patch
- Test
- Review
User interface changes
None
API changes
Probable config schema change and maybe changes to the picture mapping config entity.
Comment | File | Size | Author |
---|---|---|---|
#18 | 2132551.17.patch | 773 bytes | alexpott |
#14 | 2132551.14.patch | 3.38 KB | Gábor Hojtsy |
#9 | 2132551.9.patch | 3.38 KB | alexpott |
#9 | 8-9.interdiff.txt | 2.92 KB | alexpott |
#8 | picture.mappings.user_profile.png | 142.77 KB | vijaycs85 |
Comments
Comment #1
YesCT CreditAttribution: YesCT commentedadding tags.
Comment #2
YesCT CreditAttribution: YesCT commentedComment #3
gddI vote for "Make the picture mapping config entity produce configuration as described in the second YAML structure above". This seems to be more in line with how everyone else is doing similar things.
Comment #4
catchThis seems like a release blocker.
Comment #5
alexpottIt also blocks beta because it is a configuration data change
Comment #6
kfritscheThe problem I see when changing the schema here is, that this "custom.user.small" is the id for the breakpoint. This is needed in example in the formatter for getBreakpointById.
Changing the breakpoint id, somehow feels not right as splitting with (dot) is something very common and do exceptions only for this, seems just wrong.
But as we need the ids, the best I could think of was changing it afterwards again to the current format, but save it splitted for the config.
So in conclusion its a starting point, but somehow I'm not sure if it is the right way to do it.
Comment #8
vijaycs85Just did a manual test and seems the mappings are getting saved as per the proposed solution #1 (in issue summary). However there are some minor change in schema which is fixed and validated with config inspector (ref: picture.mappings.user_profile.png).
Comment #9
alexpottThis use of references seems overly complex and hard to understand.
How about something like the patch attached?
Comment #10
vijaycs85+1 to #9, if we are sure they key is fixed (i.e. 3 part).
Comment #11
alexpott#10 well if this changes the schema is wrong too :) - it has to be fixed.
Comment #12
slashrsm CreditAttribution: slashrsm commentedI agree that #9 looks much nicer. I tested (created, edited mapping) and it works as expected. Looks good to me.
Comment #13
catchI'm finding the number of 'sequence' in the schema a bit confusing, do we really have this many layers named the same thing?
ID.
Comment #14
Gábor Hojtsy@catch: re the sequence concern, the issue summary states that this change is made:
BEFORE:
AFTER:
So now it is a three level nesting storage. They are not "names the same thing", sequence is their type, not their name :) They have different names (labels) on different levels.
I've updated the patch for (2) to change "id" to "ID". I think this is back to RTBC.
Comment #15
catchCommitted/pushed to 8.x, thanks!
Comment #16
alexpottUnfortunately the schema is still not correct. We missing a whole level.
A current example YAML file
The current schema.
The correct schema.
Comment #17
vijaycs85I guess not. Please refer inspector screenshot in #8. We don't get the keys as they are dynamic and we skip them in schema.
So in example, module, narrow and 1x are OUT!
Comment #18
alexpottHere a patch to fix the schema - wow do we need #2130811: Use config schema in saving and validating configuration form to ensure data is consistent and correct to land.
Whilst looking at this issue I was wondering if maybe we made the config file look like this it'd be simpler.
Comment #20
alexpott18: 2132551.17.patch queued for re-testing.
Comment #23
alexpott18: 2132551.17.patch queued for re-testing.
Comment #24
Gábor Hojtsy@alexpott: looking at this data, I don't get your patch:
Multipliers are 1x, 2x, etc. But the values under them are NOT sequences, they are single string values for each multiplier in this file. So your proposed schema change to have a sequence of strings be the structure under the multipliers does not click for me with the data structure.
Comment #25
alexpott#24 you are correct. Doh!
S
orry for the noise.
Comment #27
Eli-T