Problem/Motivation

TypedConfigInterface::set() is unused but for ConfigSchemaTest.

Proposed resolution

Remove it.

Remaining tasks

User interface changes

None.

API changes

TypedConfigInterface::set() is removed.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because nothing is broken
Issue priority Normal
Unfrozen changes Not unfrozen
Prioritized changes Not prioritized
Disruption Disruptive for core/contributed and custom modules that use TypeConfigInterface::set(). TypedConfigInterface is rather new, however, both Mapping and Sequence used to have a set() method before #2298687: Sequence and Mapping implement interfaces incorrectly, make them honest about what they support. Still, it is very hard to imagine this method being used. Basically you can use a config schema wrapper to set a config value. If you are using the config schema wrapper at all in your module, you are most probably using it for validation or for getting some sort of metadata about the config, for example whether it is translatable. I'm certain most people are not aware that it's even possible to set a configuration via the wrapper and it's very unintuitive and also completely unnecessary, because whenever you would use it, you probably have a config object at hand, anyway, which you can use to set the configuration value. This is the reason that the Configuration Translation module does not use this method, for example, even though it uses the configuration schema wrapper extensively. The benefit of this change is that it makes it more easily possible to bring config schema inline with the rest of typed data in the future, either in 8.1.x or in contrib and that you do not need to implement a pointless method if you want to provide a new implementation of TypedConfigInterface.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hussainweb’s picture

Status: Postponed » Needs review
FileSize
1.49 KB

With #2298687: Sequence and Mapping implement interfaces incorrectly, make them honest about what they support, I think we are good to go with this. Starting with a simple patch.

Status: Needs review » Needs work

The last submitted patch, 1: remove-set-2429157-1.patch, failed testing.

amateescu’s picture

Component: shortcut.module » configuration system

Shortcut module is the new configuration system? :P

mtift’s picture

Issue tags: +Needs reroll, +Novice
root_brute’s picture

Status: Needs work » Needs review
FileSize
1.14 KB

Removed TypedConfigInterface methods from ConfigSchemaTest

root_brute’s picture

FileSize
1.49 KB

Removed set method from TypedConfigInterface and also from ArrayElement because ArrayElement implements TypedConfigInterface.

Status: Needs review » Needs work

The last submitted patch, 6: remove-2429157-6.patch, failed testing.

tstoeckler’s picture

OK, so let's roll #5 and #6 into one patch and then I'll RTBC :-)

joshi.rohit100’s picture

Status: Needs work » Needs review
FileSize
2.63 KB

Merged #5 and #6 into one.

Status: Needs review » Needs work

The last submitted patch, 9: remove-2429157-9.patch, failed testing.

rteijeiro’s picture

Status: Needs work » Needs review
FileSize
3.15 KB
801 bytes

Fixed failing test.

Status: Needs review » Needs work

The last submitted patch, 11: remove-2429157-11.patch, failed testing.

joshi.rohit100’s picture

Status: Needs work » Needs review
FileSize
3.17 KB
792 bytes

Fixed the exception

Status: Needs review » Needs work

The last submitted patch, 13: remove-2429157-13.patch, failed testing.

tstoeckler’s picture

+++ b/core/modules/config/src/Tests/ConfigSchemaTest.php
@@ -319,7 +313,7 @@ function testSchemaData() {
     // Finally update some object using a configuration wrapper.
     $new_slogan = 'Site slogan for testing configuration metadata';
     $wrapper = \Drupal::service('config.typed')->get('system.site');
-    $wrapper->set('slogan', $new_slogan);
+    \Drupal::configFactory()->getEditable('system.site')->set('slogan', $new_slogan)->save();
     $site_slogan = $wrapper->get('slogan');
     $this->assertEqual($site_slogan->getValue(), $new_slogan, 'Successfully updated the contained configuration data');

Let's just remove that whole hunk. It's also testing the method we're removing here.

root_brute’s picture

Assigned: Unassigned » root_brute
sidharthap’s picture

Status: Needs work » Needs review
FileSize
3.49 KB

Removed the whole hunk as suggested on #15. Please correct me if something wrong here.

tstoeckler’s picture

Nope, that's perfect. Was about to RTBC but we need a beta evaluation here. Will do that tomorrow if no one beats me to it.

root_brute’s picture

@tstoeckler the commit i did in comment #5 isn't necessary. should i remove it and upload the patch once more?

tstoeckler’s picture

Status: Needs review » Needs work

Re #19: Ahh, yes you're right. The first hunk that is removed from the test in fact tests the get() method, not the set() method. Yes, let's revert that commit and leave that part of the test in. Thanks, I had missed that!

tstoeckler’s picture

Issue summary: View changes

Added a beta evaluation. Let's see what committers say. There is some theoretical disruption here, that can't be argued away, but I think it's really, really small, and the benefits greatly outweigh it in my opinion. We'll see.

tstoeckler’s picture

Issue summary: View changes
root_brute’s picture

Assigned: root_brute » Unassigned
Status: Needs work » Needs review
FileSize
2.61 KB
1.08 KB

Added back the hunk that tested get() method.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, thanks!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 23: interdiff-2449743-17-23.patch, failed testing.

rpayanm’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
FileSize
1.08 KB
2.61 KB

Here only copy/paste. Because interdiff extension is .patch and is tested by the testing bot.

@root_brute the interdiff extension files must be .txt
More info: https://www.drupal.org/documentation/git/interdiff

root_brute’s picture

@tstoeckler welcome :)
@rpayanm thanks for the insight.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Prevent setting config using typed config makes a lot of sense. I think this reduces fragility since that config could not actually be saved. Committed b9045f6 and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed b9045f6 on 8.0.x
    Issue #2429157 by root_brute, joshi.rohit100, rpayanm, rteijeiro,...
rpayanm’s picture

@root_brute you are welcome, thank you for contribute to drupal :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.