Problem/motivation
In #1866610: Introduce Kwalify-inspired schema format for configuration the schema files were merged into one big file per module/theme on suggestion from @effulgentsia & moved into the regular config directory. Practical application of this (eg. with Views at #1910606: Improve the configurations schemas for Views significantly) proved ineffective and the need to move it out of the regular config directory came up as well as the possibility to split schema files into more logical units as needed.
Proposal
- Modify schema discovery to look for schema files under a subdirectory in config directories called 'schema'.
- Move all existing files there.
- Make schema discovery code find all schema files in that directory not just one.
Comment | File | Size | Author |
---|---|---|---|
#36 | 1914366-move-config-schema-36.patch | 13.82 KB | Gábor Hojtsy |
#33 | 1914366-move-config-schema-33.patch | 13.82 KB | vijaycs85 |
#33 | 1914366-diff-31-33.txt | 345 bytes | vijaycs85 |
#31 | 1914366-move-config-schema-31.patch | 13.49 KB | vijaycs85 |
#23 | 1914366-move-config-schema-23.patch | 13.55 KB | vijaycs85 |
Comments
Comment #1
gddI'm in favor of this. The current way is going to make our import code more complex, which I'd like to avoid.
Comment #2
Gábor HojtsyHere is a patch only moving the files. The reading of the files is currently handled with regular config storage (and schema files are indeed copied to the active store, etc, which is not good/intended). So I think we'll need to revert back to the state from #1648930: Introduce configuration schema and use for translation where InstallStorage was used to look up from specific places from the file system. Someone more knowledgeable with the config system would be great to help here.
So far this will only demonstrate it fails if the schema files are moved out from where the system expects them :) So it will bounce itself to needs work.
Comment #4
Gábor HojtsyComment #5
vijaycs85Thanks for your tips on IRC @Gábor Hojtsy. Here is a patch with my understanding of what need to be done here:
1. Crated SchemaStorage which fetches schema from sub folder "config/schema"
2. Updated changes in InstallStorage (from #1648930-298: Introduce configuration schema and use for translation).
if they are right,
Yet to do:
1. Make SchemaDiscory to use SchemaStorage (i.e.SchemaDiscory->storage = SchemaStorage)
2. Load multiple file in same dir - as per current schema files, it should work without this fix (i.e. single schema file per module).
Comment #6
Gábor HojtsyInterdiff looks pretty good to me, taking over the needed pieces from #1648930: Introduce configuration schema and use for translation. Now the schema discovery need to use this storage and the moving of files would be accomplished. Making it read and merge all the files could be a bit harder, but we don't need to dynamically find keys in files or anything, just merge all files outright from the module AFAIS.
Comment #7
Gábor HojtsyComment #9
Gábor HojtsyAll the above fails are expected, since the files are moved, but discovery is not yet updated.
Comment #10
vijaycs85Updating patch to discover schema configurations. Tests passing locally but need to confirm the way it has been implemented. Sure this patch is not final, but just to confirm the right path.
Comment #12
vijaycs85#10: 1914366-move-config-schema-10.patch queued for re-testing.
Comment #13
Gábor HojtsyNonono! It should not copy the schema files to active storage, no. That behaviour is a side effect of the current design that is in fact not desired. The schema should be kept with the module and it cannot / will not be changed. So instead of copying it over, schema discovery should change to not look at the active config store but look at the original place with the component.
Comment #14
vijaycs85I had to register another class to make it check in module's folder and locally some part of test cases still failing because of meta data of configs (i.e. config_typed()->get('system.site')->get() looking at SchemaDiscovery for definition).
Comment #16
vijaycs85Removing unnecessary class and function added in #14
Comment #18
alexpottThe TypedData manager needs access to config data as well as schema so it needs both the config.storage and config.storage.schema services injected.
I've updated the SchemaStorage to issue it's own exceptions as the InstallStorage exceptions do not make sense.
The interdiff is a bit tricky as @vijaycs85 needs to update his git config so the moves of the schema files are detected and not treated as new files see http://drupal.org/documentation/git/configure
Comment #20
jthorson CreditAttribution: jthorson commentedTestbot died on APC warnings and a segfault. :(
Comment #21
jthorson CreditAttribution: jthorson commented#18: 1914366-move-config-schema-18.patch queued for re-testing.
Comment #22
Gábor Hojtsy@alexpott, @vijaycs85: thanks! Looking at the patch I only found one problem:
phpdoc not fully updated to current arguments.
Also, do we want to tackle reading more than 1 file from there in this issue or in another one? :)
Comment #23
vijaycs85Thanks for the review @Gábor Hojtsy. Attached patch address both issues:
1. read all schema files in a module - implemented using storage->listAll().
2. Comments - Fixed.
Comment #24
Gábor HojtsyLooks pretty good to me. (Will be committable once testbot comes back green).
Comment #26
vijaycs85#23: 1914366-move-config-schema-23.patch queued for re-testing.
Comment #27
alexpottAn additional file has made it into the patch...
core/modules/system/config/schema/system.data_types.schema.yml
Comment #28
vijaycs85@alexpott, yes, that is intentional. patch in #23 reads multiple schema files...
Comment #29
vijaycs85#23: 1914366-move-config-schema-23.patch queued for re-testing.
Comment #31
vijaycs85Re-rolling...
Comment #33
vijaycs85Seems config_test module's schema file wasn't at right place. locally ran test cases failing on #31 and got green.
Comment #34
Gábor HojtsyGiven other changes and introductions of schema, it would be great to prioritise this for commit (there are other RTBC issues for config schemas but those are easier to reroll, this one is harder). So moving back to RTBC and adding Avoid commit conflicts.
Comment #35
YesCT CreditAttribution: YesCT commentedDoing a docs review.
function definition should type hint. array $list
Comment #36
Gábor HojtsyAdded the array typehint to that hunk. No other items found that this would apply to. So no interdiff. Given such minimal change, this should still be RTBC.
Comment #37
catchThe drupal_get_path() and drupal_system_listing() etc. calls aren't much fun, but that's not the fault of this patch. Committed/pushed to 8.x.
Comment #38
Gábor HojtsyThanks! That should help us reroll the 30 or so patches for schemas in http://drupal.org/project/issues/search/drupal?issue_tags=Configuration%... :) Superb!
Added this to the changelog at http://drupal.org/node/1905120 and updating the docs at http://drupal.org/node/1905070 :)
Comment #39
Gábor Hojtsyhttp://drupal.org/node/1905070 (doc page) fully updated for new location: http://drupal.org/node/1905070/revisions/view/2571372/2573208
Comment #41
chx CreditAttribution: chx commented