Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We split up the Config class in #2215413: Split the Config class into StorableConfigBase and ConfigBase. Make ThemeSettings inherit from ConfigBase. to make it easier to re-use. Unfortunately the new classes are not well documented to explain why they are split up and when to use.
See #2201437: [META-1] Config overrides and language for some of the rationale.
Comment | File | Size | Author |
---|---|---|---|
#19 | interdiff-config-docs.txt | 2.66 KB | xjm |
#19 | config-2216961-18.patch | 7.59 KB | xjm |
#15 | interdiff.txt | 1.28 KB | Gábor Hojtsy |
#15 | config-base-class-docs-15.patch | 7.34 KB | Gábor Hojtsy |
#9 | config-base-class-docs.patch | 7.34 KB | Gábor Hojtsy |
Comments
Comment #1
xjmComment #2
xjmComment #3
Gábor HojtsyThe most evident benefit of that change was the removal of several copy-pasted methods from
ThemeSettings
and instead relying on actual OOP features :) Here is the before/after picture:Also StorageConfigBase is very useful to do other config storages that may not support overrides for example as proposed by #2201437: [META-1] Config overrides and language for language.
Comment #4
xjmMy question from the original issue:
Comment #5
xjmThe docblock from ThemeSettings is also less-than-helpful:
(But hey, at least it bothered to add one!) ;)
Comment #6
Gábor Hojtsy@xjm: the answer to that lies in http://drupalcode.org/project/drupal.git/commitdiff/31513883d9b15c997c14... which was committed from #1712250: Convert theme settings to configuration system. The class is only used for runtime config wrapping. See the theme.inc hunk there for how it merges all kinds of data like global theme settings, theme defaults, etc. to construct the config relevant for this specific theme. This is not storable, it will need to be regenerated based on these things later on. Its derivative data, so the configuration storage system is not really suitable for it.
Comment #7
Gábor HojtsyNote that theme conversion patch landed in 2013 May, so the existence of the copy-pasted code and the only-runtime config dates back to that.
Comment #8
Eli-TComment #9
Gábor HojtsyHere is a patch with proposed wording explaining which base class does what and when to use which. I also found some methods in Config which are already defined on StorableConfigBase and are identical. So removed those too. This helps make the differences clearer as you can clearly see the methods in each class belong to their respective responsibilities.
ConfigBase (runtime config handling, eg. derived config like ThemeSettings) >>> StorableConfigBase (with storage, will be useful for non-overridable configuration like languages as proposed in #2201437: [META-1] Config overrides and language) >>> Config (also provides override support).
Comment #11
Eli-THave checked all removed methods are identical to their inherited counterparts, and all looks good.
Very minor comments with two of the class comments:
Should end
...if the data is derived at runtime.
.should end
and are therefore not persisted
Comment #12
Gábor HojtsyLooks like a random fail to me:
That wast the only fail. Retesting.
Comment #13
Gábor Hojtsy9: config-base-class-docs.patch queued for re-testing.
Comment #14
Eli-TThe same test passes on my local with the patch applied:
Comment #15
Gábor HojtsyFixed those concerns with the text :) @alexpott, @xjm do you think this is a worthy improvement to commit?
Comment #16
xjmHuge improvement. I had a long dreditor post of comments to improve the docs but then realized it'd just be faster to tweak the patch myself, so doing so. :)
Comment #17
xjmOh, the "Random test failure" tag is canonical (for the issues that are actually about particular fails, not just where they happen). See #2216701: Random test failure in ToolbarAdminMenuTest for that one.
Comment #19
xjmClarified the relationship between the base classes and implementations a bit, and fixed a couple run-on sentences.
Comment #20
xjmComment #21
Gábor HojtsyChanges look very good :)
Comment #22
alexpottLooks and reads great.
Comment #23
jhodgdonThe docs here look fine to me. However, this is not a docs issue (lots of code changes it looks like? Whole swaths of code are removed in the patch).
Comment #24
Gábor Hojtsy@jhodgdon: the code removed is purely duplicate copy-paste repeated on the inheritance chain superfluously. :)
Comment #25
webchickCommitted and pushed to 8.x. Thanks!
Comment #26
Gábor HojtsySuperb, thanks, this should help a lot!