@Hyruu opened this Issue on June 7th 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 commented on June 9th 2017 Owner

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 commented on June 9th 2017 Owner

Correct notation is:

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

This Issue was closed on June 9th 2017
Powered by GitHub Issue Mirror