Problem/Motivation

When pass an undefined typed data type (e.g resource, object etc) for a config key which has config schema, getting endless look on Config->castValue()

Proposed resolution

Fix the castValue() so that throws Exception for such case.

Remaining tasks

User interface changes

No

API changes

No

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vijaycs85’s picture

Initial patch with test-only-fail patch...

The last submitted patch, 1: 2172941-config-cast-value-loop-1-test_only-fail.patch, failed testing.

vijaycs85’s picture

Category: Task » Bug report
Priority: Normal » Major
vijaycs85’s picture

alexpott’s picture

Status: Needs review » Needs work
Issue tags: -CMI +Configuration system

The test currently works because an exception is being thrown by Symfony's YAMP dumper \Symfony\Component\Yaml\Exception\DumpException. I think it is an improvement to move the error up to the Config class and make it independent of the Config storage layer.

But I think we need to ensure that the exception thrown is consistent. So we have to decide how to do this. Config data is set through two methods - we could throw an exception in the set() method if the value is an unsupported data type. But we have an issue with setData(). The current patch won't throw this exception for config that does not have schema.

So I think we need to add a catch in FileStorage::encode() for the DumpException and rethrow a UnsupportedConfigDataTypeException. Actually looking at the name of the exception I think iUnsupportedDataTypeConfigException is better since this extends ConfigException. In order to test this we need to try saving to a config file that has no schema. The test should also assert that the config object has no schema just in case someone tries to implement one at a later date.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
4.86 KB
6.06 KB
4.42 KB

- Renames exception
- Catches DumpException in FileStorage::write (Not in encode, so we can provide the config name).
- Added a new test for this, that has no config schema.
- Minor other changes.

The last submitted patch, 6: 2172941-6-test-only-FAIL.patch, failed testing.

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

It's going to be great to get helpful error messages from CMI +1

catch’s picture

Status: Reviewed & tested by the community » Fixed

Nice change, committed pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

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