Problem/Motivation
Pointed out by @tedbow at #2808217-65: To be able to view Vocabulary config entities via REST, one should not have to grant the 'administer taxonomy' permission, confirmed by @dawehner at #2808217-66: To be able to view Vocabulary config entities via REST, one should not have to grant the 'administer taxonomy' permission and by @Wim Leers at #2808217-68: To be able to view Vocabulary config entities via REST, one should not have to grant the 'administer taxonomy' permission.
#2625258: LocaleConfigManager::updateConfigTranslations() deletes translations if a config object's name happens to match that of a shipped configuration object added this _core key in January 2016, after Drupal 8 shipped, but it did not update \Drupal\serialization\Normalizer\ConfigEntityNormalizer. This was simply an oversight — it was not even discussed there at all!
All normalized config entities expose something like this:
…
"_core": {
"default_config_hash": "lO5ziR5dVI1PpEeHZsSOfQ-Y7NWihSDKW8-MMf6uoms"
},
…
This is:
- weird
- a Drupalism
- useless to API consumers
Note: the reason why existing config entity GET test coverage doesn't include this _core key in the expectations defined in the getNormalizedEntity() methods is as surprising as it is simple: #2625258: LocaleConfigManager::updateConfigTranslations() deletes translations if a config object's name happens to match that of a shipped configuration object only causes _core to be added to shipped configuration, aka default configuration, aka YAML files in MODULENAME/config/install. The tests are each creating config entities in the abstract function createEntity() method that each entity type-specific test subclass must implement.
Proposed resolution
Omit the _core key from the normalization of config entities.
Remaining tasks
Do it.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 2915414-16.patch | 7.05 KB | wim leers |
Comments
Comment #2
wim leersI left a comment at #2625258-48: LocaleConfigManager::updateConfigTranslations() deletes translations if a config object's name happens to match that of a shipped configuration object, pointing here. I also updated the CR https://www.drupal.org/node/2653358 to include this issue as a related issue.
Comment #3
wim leersLet's add both functional and unit test coverage.
They should both fail.
Comment #4
wim leersAnd now with an updated normalizer, it should result in passing tests!
Note that this is testing both the
jsonandhal_jsonformats in the functional test coverage!Comment #6
wim leersComment #7
wim leersNote: the reason why existing config entity
GETtest coverage doesn't include this_corekey in the expectations defined in thegetNormalizedEntity()methods is as surprising as it is simple: #2625258: LocaleConfigManager::updateConfigTranslations() deletes translations if a config object's name happens to match that of a shipped configuration object only causes_coreto be added to shipped configuration, aka default configuration, aka YAML files inMODULENAME/config/install. The tests are each creating config entities in theabstract function createEntity()method that each entity type-specific test subclass must implement.Added this to the IS.
Comment #8
dawehnerWe should ensure that once we open PATCH/POST requests that we cannot override the values. Does that mean we should exclude them in denormalization here already?
Comment #9
wim leers#8: good point, that should be a blocker to #2300677: JSON:API POST/PATCH support for fully validatable config entities in theory? On it!
Comment #10
wim leersTest coverage for #8, should fail.
Comment #11
wim leersAnd the fix.
Comment #12
wim leersOpened a sister issue for the JSON API contrib module: #2915539: Omit "_core" key from normalized config entities, which includes the default config hash.
Comment #14
dawehnerShould we explain why we skip core here? Also: Why do we use once array_diff_key and once unset() ... can't we use the same approach here twice?
Comment #15
wim leersYou ask great questions! 😳
Comment #16
wim leersFixed.
Comment #17
dawehnerWFM
Comment #18
larowlanUpdating review credits
Comment #19
larowlanAny reason we went for
statichere?Comment #21
wim leers#19: because it signals it only uses the parameters it receives, it doesn't change the object. See http://drupal4hu.com/node/416.html.
Comment #22
alexpottThis is only a negative assertion which makes me think that the test might be a bit brittle. I was wondering about why we have this test - but it is the only non-unit test case of the change. It does mean if we remove the configurable language we'd suddenly lose this test coverage.
Comment #23
wim leersExactly: there is complete and explicit unit test coverage, the hunk you quoted is about having a functional regression test. Happy to remove it if you prefer that.
Comment #24
larowlanCommitted as 96452be and pushed to 8.5.x.
Comment #27
wim leers