Problem/Motivation
The configuration system has a couple of areas that could do with tidying up. These have to be done together as the procedural code unnecessarily ties everything together.
- Several of the procedural functions in config.inc have no OO equivalents impeding the ability to swap out functionality and unit test.
- config.inc is included in _drupal_bootstrap_configuration() yet none of the functions it contains are regularly used during runtime.
- The ConfigImporter is currently injecting services it is not using and additionally is calling out to procedural code.
Proposed resolution
- Create a new ConfigManager that implements the functionality of contained with config.inc where appropriate
- Remove or deprecate functionality in config.inc where appropriate
- Remove unneeded dependencies from ConfigInstaller
This blocks beta since it is an API change to the configuration system. A followup should remove the include and usages of config()
, typed_config()
and config_get_storage_names_with_prefix()
.
Remaining tasks
Patch
User interface changes
None
API changes
- Remove config_get_entity_type_by_name()
- Remove config_uninstall_default_config()
- Deprecate config_get_storage_names_with_prefix()
- Deprecate typed_config()
- Remove config_import_create_snapshot()
- Remove config_diff()
- Add ConfigManager
- Change ConfigImporter constructor
- Change ConfigInstaller constructor
Change records
There appears to be no change records to update as a result of this change. When we remove config() we should update https://drupal.org/node/2065313
Comment | File | Size | Author |
---|---|---|---|
#26 | 2188595-follow-up.patch | 1.59 KB | andypost |
#24 | 2188595-follow-up.patch | 1.59 KB | andypost |
#20 | 2188595.20.patch | 38.7 KB | alexpott |
Comments
Comment #1
alexpottHere's a patch doing what is outlined in the issue summary.
Comment #2
tim.plunkettI know we use this check in other places, but why not switch to
return $entity_info->isSubClassOf('\Drupal\Core\Config\ConfigEntityInterface');
?Comment #3
alexpottBecause we need the config entity prefix so that we can determine what type of config entity the supplied configuration name is.
Comment #4
tim.plunkettDuh. I misread the snippet. Carry on.
Comment #5
alexpottNow actually removing the function from config.inc
Comment #6
tim.plunkettMy only worry is that we're provide a wrapper around entity manager, but only one method (getStorageController). It provides a nice place for getEntityTypeIdByName, but it seems like there might be later confusion about whether one should use this or the entity manager directly for getting the storage controller.
public function
This can be {@inheritdoc} since its on the interface
Contains \Drupal
Double blank line
Constructs ... and missing the @param description
Were these just completely unused? Heh.
Comment #7
jibranFixed #6
Comment #8
alexpottI agree with @timplunkett that we should avoid creating a confusion with the entity manager. I've refocussed the patch to address the ultimate aim which is removal of config.inc. The patch gets round the confusion by implementing
getEntityManager()
on the newConfigManager()
object so theConfigImporter
andConfigInstaller
don't need to have theEntityManager
injected as well.I have not provided an interdiff because the changes are extensive and main addition has been renamed resulting in an interdiff larger than the patch.
Comment #9
alexpottComment #11
xjmSo, this is a good cleanup, but after having read the issue and the patch, I don't understand why it's critical or a beta blocker. I'd propose it as a major beta target/maybe beta deadline instead. We could even provide a deprecation/BC layer after beta, I think; it would just be cleaner not to.
Edit: In the summary, this statement has a false premise:
Not all API changes to CMI block beta -- only the critical ones. Non-critical ones (which IMO this is) should be done so the CMI API is stable and pleasant, but we'd release a beta with or without it and tough luck.
Comment #12
xjmAlso, re: the change record, we should update it, not delete it, so that there's something for people who ported with
config()
to find.Comment #13
alexpottOk sure let's make it a beta target then - but I'd like to get this in before doing more work on the Importer because had all the additional services and lack of ability to right unit tests against annoys me.
Comment #14
alexpott8: 2188595.8.patch queued for re-testing.
Comment #15
alexpottRerolled due to #2165155: Change $entity_type to $entity_type_id and $entity_info to $entity_type/$entity_types. Attached diff of two patches as interdiff possible.
Comment #16
BerdirAgree with the naming, change I found ConfigEntityManager also confusing, given that we're about to introduce ConfigEntityType, where it really is a subclass of EntityType with config specific additions.
Looks great to me.
Applied the patch, and the only remaining functions in there are config_get_storage_names_with_prefix(), config() and config_type(). config.inc still says "This is the API for configuration storage." in the @file declaration, which is obviously bogus.
Wondering if we don't simply want to go ahead and move those three left-over functions to bootstrap.inc or maybe even drop config_typed(), it's used in exactly one location outside of tests. If not that, then maybe an explicit follow-up issue to remove config.inc and delete those functions? The not-deleting of config() for example resulted in new calls to it that were introduced as late as 22. january 14 :( Or move + follow-up?
Comment #17
alexpottI deprecated everything in config.inc with the idea of making it a follow up, so here it is: #2192693: Remove config.inc. I don't think there is any point in cleaning up the documentation in config.inc here as that issue will remove the entire file. I didn't remove all usages of the 3 remaining functions to keep the patch size sensible.
Comment #18
BerdirWorks for me, let's do this.
Comment #19
catchPatch looks great overall, had a few nitpicks:
Is this really deprecated or are we going to nuke it later?
Could use a @todo on https://drupal.org/node/1848266
Comment #20
alexpottFixed up the comments.
Comment #21
catchComment #22
andypostneeds follow-up, point to the issue
Comment #23
Berdir@andypost: It already does, that is the follow-up issue?
Comment #24
andypost@Berdir see #19
Patch also fixes doc-block
Comment #25
alexpottlol - I hang my head in shame
Comment #26
andypostmissed 'T'
Comment #27
xjmCan we please not reuse majors for minor docs cleanups?
Comment #28
catchYes please start another issue for that and attach the patch there. It's also hard to tell whether the change notice or the patch is CNR/RTBC.
Comment #29
alexpottChange record https://drupal.org/node/2193603 created
Comment #30
alexpottCreated #2193607: Fix documentation in ConfigManager
Comment #31
jibran#2194061: Fix documentation in ConfigSync and other doc follow up.