Problem/Motivation
Discovered in #3364108: Configuration schema & required keys.
#2663410: TypedConfigManager::_getDefinitionWithReplacements() incorrectly replaces generic definition introduced a regression: it introduced a bug that made TypedConfigManager sensitive to cache pollution. In the
case of hitting the $type = "$type||$sub_type"; edge case, 2 calls to getDefinitionWithReplacements() happen:
#2663410
Steps to reproduce
buildDataDefinition()calls it WITH the$replaceparametergetDefinition()calls it WITHOUT the$replaceparameter
Calling getDefinition() causes the computed type to be overwritten.
Proposed resolution
Cache pollution happens when getDefinitionWithReplacements() is called without the $replacements parameter, so wrapping the defintion update into a condition can solve the problem.
Remaining tasks
Test coverage.
User interface changes
None.
API changes
None.
Data model changes
N/A
Release notes snippet
N/A
Issue fork drupal-3400181
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wim leersComment #4
wim leersCanvas adopted a config schema type that consistently ran into this problem, in #3568264: Update code component props schema to support 'array' type.
— #3568264-13: Update code component props schema to support 'array' type
Consequently, it now has a built-in override of this service to work around the bug.
Comment #5
claudiu.cristeaAdded #3548299: Missing schema on nested config as potentially related
Comment #6
huzookaComment #8
huzookaIf this will be fixed by the MR I just created, I propose giving credit additionally to:
- dimilias for his detailed report at #3548299: Missing schema on nested config (he was also very close);
- Besides claudiu.cristea, also herved for connecting dots;
- alexpott for the test coverage.
I don't think we need any additional test coverage; imho the definition cache clears I removed from the ConfigSchemaTest should be enough.
Comment #9
alorencComment #10
alorencRTBC
A minimal, it prevents TypedConfigManager from caching schema definitions resolved without replacements.
Comment #11
alorencComment #12
quietone commentedThis comment states this is fixing a regression, therefor updating title per the special issue titles.
Comment #13
godotislateCan someone update the Proposed Resolution in the IS to match the approach taken in the MR. At a glance, they are not the same.
Assigned credit, including note form #8.
Comment #14
huzookaComment #15
claudiu.cristeaAs per #8, we don't need tests. We're already covered by removing the cache clears from existing tests