Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console config:set not working properly with string values and 'section.key=value' syntax #11774

Closed
Hyruu opened this issue Jun 7, 2017 · 2 comments
Labels
c: Usability For issues that let users achieve a defined goal more effectively or efficiently.
Milestone

Comments

@Hyruu
Copy link

Hyruu commented Jun 7, 2017

Hi there,

When trying to set a string value using the section.key=value syntax, the console is unable to parse the command correctly. For example, trying to set the Debug.log_level property to DEBUG gives the following :

./console config:set Debug.log_level=DEBUG

[InvalidArgumentException]
Invalid assignment string 'Debug.log_level=DEBUG': could not parse value as JSON

Trying to enclose the value or even the keys in quotes does not solve the issue. The following commands gave exactly the same error message. I insist on the exactly as all quotes are removed in the 'Debug.log_level=DEBUG' part of the exception message.

./console config:set Debug.log_level=DEBUG
./console config:set Debug.log_level="DEBUG"
./console config:set Debug.log_level='DEBUG'
./console config:set "Debug"."log_level"="DEBUG"

This only happens with string values, as any numerical input works, and only for the section.key=value syntax. The following two commands do work :

./console config:set Debug.log_level=1
./console config:set --section="Debug" --key="log_level" --value="DEBUG"
@mattab
Copy link
Member

mattab commented Jun 9, 2017

Thanks for the report. I've just improved the help text of the command a bit which now reads:

Usage:
 config:set [--section="..."] [--key="..."] [--value="..."] [assignment1] ... [assignmentN]

Arguments:
 assignment            List of config setting assignments, eg, Section.key=1 or Section.array_key[]=value

Options:
 --section             The section the INI config setting belongs to.
 --key                 The name of the INI config setting.
 --value               The value of the setting. (Not JSON encoded)
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question
 --piwik-domain        Piwik URL (protocol and domain) eg. "http://piwik.example.org"
 --xhprof              Enable profiling with XHProf

Help:
 This command can be used to set INI config settings on a Piwik instance.
 
 You can set config values two ways, via --section, --key, --value or by command arguments.
 
 To use --section, --key, --value, simply supply those options. You can only set one setting this way, and you cannot
 append to arrays.
 
 To use arguments, supply one or more arguments in the following format:
 $ ./console config:set 'Section.config_setting_name="value"'
 'Section' is the name of the section,
 'config_setting_name' the name of the setting and
 'value' is the value.
 
 NOTE: 'value' must be JSON encoded, so 'Section.config_setting_name="value"' would work but 'Section.config_setting_name=value' would not.
 
 To append to an array setting, supply an argument like this:
 $ ./console config:set 'Section.config_setting_name[]="value to append"'
 
 To reset an array setting, supply an argument like this:
 $ ./console config:set 'Section.config_setting_name=[]'
 
 Resetting an array will not work if the array has default values in global.ini.php (such as, [log] log_writers).
 In this case the values in global.ini.php will be used, since there is no way to explicitly set an
 array setting to empty in INI config.


@mattab
Copy link
Member

mattab commented Jun 9, 2017

Correct notation is:

./console config:set 'Debug.log_level="DEBUG"'

@mattab mattab closed this as completed in 57cb99a Jun 9, 2017
@mattab mattab added this to the 3.0.5 milestone Jun 9, 2017
@mattab mattab added the c: Usability For issues that let users achieve a defined goal more effectively or efficiently. label Sep 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Usability For issues that let users achieve a defined goal more effectively or efficiently.
Projects
None yet
Development

No branches or pull requests

2 participants