Steps to reproduce:
* Create a new config form that modifies an custom configuration
* Create a route for the config form
* Make sure the custom_config doesn't exist in the active configuration
* Create a *.config_translation.yml for the custom configuration
* Go to the route for the config form
A fatal error occurs:
TypeError: Argument 2 passed to Drupal\Core\Config\TypedConfigManager::createFromNameAndData() must be of the type array, boolean given, called in /core/lib/Drupal/Core/Config/TypedConfigManager.php on line 78 in Drupal\Core\Config\TypedConfigManager->createFromNameAndData() (line 391 of core/lib/Drupal/Core/Config/TypedConfigManager.php).
This happens with Drupal 8.4.2 because the system tries to read the configuration, but since the data doesn't exist it returns FALSE, hence the error.
Issue fork drupal-2925297
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2925297-fatal-error-on
compare
- mpp-9.2.x-patch-88647
changes, plain diff MR !195
Comments
Comment #2
mmrares commentedComment #3
jrockowitz commentedThis regression/error was most likely triggered by the recent change to Added \Drupal\Core\Config\TypedConfigManagerInterface:: createFromNameAndData() to make it easy to get a typed configuration object.
Comment #4
michielkenis commentedI'm having the very same issue here... I'm trying to work something out!
Comment #7
paulvandenburg commentedCame across this same issue.
And I've worked something out.
The problem lies indeed in the TypedConfigManager as it requires the StorageInterface::read to always return an array.
But the interface clearly defines it's return type as array or false.
This requirement of always returning a value for the Typed Config was spread throughout the manager. So it was easiest to convert this possible false value to an empty array. rather than let the Typed Config manager handle the possible lack of a value.
See the enclosed patch.
Comment #8
leksat commented#7 works great. Thanks!
Comment #9
catchThis seems like a real error condition that should show a warning- what I think we're missing is handling the error correctly somewhere (i.e. showing that the configuration is missing, rather than this fatal). Is there any way to reproduce this via the UI or can it only happen when manually manipulating config and/or custom code.
Regardless of the approach, also needs some test coverage.
Comment #10
shubhangi1995I also faced the same bug with webform module , on trying to access webforms confirgurations from admin/structure/webform/config
I have translation enabled, the patch was working perfectly.
Drupal core version: 8.6.10
Webform version: 8.x-5.2
Comment #11
mpp commented@catch, this happens when you have a module that provides a simple config schema but no default config and/or the config is ignored.
The error will occur on the edit and translation routes of such a config object.
The patch in #7 will resolve the fatal error but instead of writing an empty configuration file (we're on the edit form, we don't want to write anything there) we may need to display a message that no config exists.
Comment #12
mpp commentedAdded tests only.
Comment #13
mpp commentedAdded patch.
Comment #15
renguer0 commentedLGTM
Comment #16
catchThe comments in #9 and #11 still need to be resolved here, we should give some kind of indication either in the UI or a log message that there's no configuration to translate.
Comment #17
shubhangi1995in the enityt_type manager is it ok to log a warning when the default config are not found or egnored?
Comment #18
paulvandenburg commentedAdded logging to solve feedback from #9 and #11.
Comment #19
guptahemant commentedI recently faced this issue when one of my custom config form was config ignored and no default value was present for it, The patch from #18 solved the issue for me.
Thanks
Comment #20
andypostComment #21
renguer0 commentedSolve that issue in D8.8.5 and PHP 7.4.5.
Looks good to me.
Comment #24
pavelculacov commentedFixed, Worked
Comment #25
michel.g commentedDoes this still occur in 9.2.x?
We might need to reroll the patch before tagging it as reviewed and tested.
Comment #27
spokjeTest only patch #12 still fails on D9.2.x.
Patch #18 still applies cleanly to D9.2.x and solves the issue.
Comment #29
mpp commentedCreated a Merge Request and fixed the orthography of "not existing" to "non-existent".
Comment #30
catchA trigger_error() seems more appropriate for this one - then depending on error reporting it'll show people in the UI too.
Comment #32
spokjeAs said in the MR thread, I don't see any
Resolvebuttons to close the last unresolved comment.Putting this on NR nevertheless.
Comment #33
spokjeComment #37
nevergoneAnd now?
Comment #38
vodde83 commentedI still had this issue on D9.4.x, but the patch from #18 still applies neatly and resolves the error.
Comment #40
thomjjames commentedLike vodde83 I'm also still getting the error on Drupal 9.4.8 but the patch in #18 does also seem to fix it.
Comment #41
martijn de witUsing https://git.drupalcode.org/project/drupal/-/merge_requests/195.diff from #32. Works like a charm. The real error's / warnings are now popping up.
Comment #42
spokjeLet's see if the diff from the MR applies to all branches.
Comment #43
martijn de witSeems RTBC to me :)
Comment #44
spokjeTagging with BugSmash
Comment #46
catchCommitted/pushed to 10.1.x, cherry-picked back through to 9.4.x, thanks!