Problem/Motivation
Trying to set language specific config, for example Spanish site name:
$ drush -y config:set language.es:system.site name "Hola Mundo"
Raises the following exception:
Invalid character in Config object name language.es:system.site.
Whereas the following two commands just work fine:
$ drush config:get language.es:system.site name
'language.es:system.site:name': 'Hello World'$ drush -y config:set system.site name "Hello World"
// Do you want to update name key in system.site config?: yes.Proposed resolution
in core/lib/Drupal/Core/Config/ConfigBase.php inside public static function validateName($name) the following
// The name must not contain any of the following characters:
// : ? * < > " ' / \
if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) {
throw new ConfigNameException("Invalid character in Config object name $name.");
}
may better be
// The name must not contain any of the following characters:
// : ? * < > " ' / \
// Except for language-specific collections.
if (!preg_match('/^language.[a-z]{2}:/', $name)) {
if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) {
throw new ConfigNameException("Invalid character in Config object name $name.");
}
}
to exclude at least language-specific collections from invalid character check. Although I'm not sure if it's not even better to make that a more general solution, for example if there are other collections than language collections. But are or can be there any other collections except language collections?
Remaining tasks
* patch provided
* reviews needed
* tests to be run
* documentation to be written
User interface changes
- None -
API changes
Unsure about that.
Data model changes
- None -
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 3011276-18.patch | 1.31 KB | eddie_c |
| #6 | drush_cset_for_other_than_default_collections-3011276-6.patch | 809 bytes | progzy |
Comments
Comment #2
norman.lolInitial patch added.
Comment #3
norman.lolNeeds review
Comment #4
progzy commented@leymannx thank you for the patch it helped me. However it does not work for some languages because of the "[a-z]{2}" in the regex. This is the case for Chinese for example (zh-hans).
Comment #5
norman.lolAh yes, thanks for reporting. I didn't consider subtags.
Comment #6
progzy commentedI've uploaded an update of your patch.
Comment #7
thiagogomesverissimo commentedThe pacth #3011276-6 worked for pt-br language.
Comment #8
norman.lolHide old patch
Comment #9
larowlanAs this is a bug, we need a test to go with it.
Thanks
Comment #10
larowlanComment #13
norman.lolWhat kind of test would be needed here? Where do we add it?
Comment #16
jigariusThough this works for me, I'm facing a strange issue which might or might not be related to this ticket.
Can anyone else reproduce this or know why this might be happening?
Comment #17
simgui8 commentedPersonally, #6 fixes the raised exception, but config table blob entry is not altered.
After clearing cache (and navigating to frontend), non-default collection updated config
reverts to the blob data in config table.
I have ended up db updating the data blob entry.
Comment #18
eddie_c commentedUpdated patch with test included
Comment #20
simgui8 commentedAfter revisiting this one,
#18 fixes the problem
The problem was happening when doing a drush updb after upgrading from Drupal 9.2.9 to 9.2.10
Thanks!
Comment #23
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Confirmed this issue on Drupal 10.1 with a standard install
With drush 11.
Enabled german language.
Think this will need a follow up: Installing the language did not default the site system for translation. Running the drush command kept giving
Had to manually go to the site system page in my default language. Click translate and save the page before I could run the drush command
After I did that the command worked.
Just needs someone to opened that follow up.
Comment #24
nikhil_110 commentedPatch for 10.x
Comment #25
smustgrave commentedPatch 18 applies to d10 just fine. Hiding 24 and removing credit for uploading the same patch. You can verify by clicking the test link under the patch.
Also please include an interdiff with all patches may have helped show there is no difference