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 (cli): Add config:delete to delete a key #16576 #16608

Closed
wants to merge 6 commits into from

Conversation

javier-de-juan
Copy link

@javier-de-juan javier-de-juan commented Oct 24, 2020

This PR tries to add the delete command for config file. For array positions deletion, just admit numeric number because if the code removes one labeled position from the array, all other keys are lost (dumpConfig method related), so I preferred to avoid bad config generation.

Copy link
Member

@tsteur tsteur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers for the PR @javier-de-juan very appreciated. Added 2 comments to check if we need certain features.

To use arguments, supply one or more arguments in the following format:

Remove section:
$ ./console config:delete 'section'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javier-de-juan do you need the feature to remove an entire section? Cause if used wrongly it could do a lot of harm and break Matomo (eg if someone removes General or any other sections and forgets to pass a key, then Matomo be broken probably). If you need this feature, we'd probably need another flag like only-section just to be sure this is wanted

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tsteur! In my case it's not needed but I tried to think in all cases. I can remove this feature and keep it simple. I'll do it ASAP, today will be done ;)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this feature and, in my opinion, it could be useful. Finally I decided to put a confirm question to avoid undesired behaviour. What do you think???

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where it would be useful? Not sure there is any section that can be removed without breaking anything actually.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok @tsteur The feature was also removed. Actually the command will only remove settings in sections 👍

'config_setting_key' the name of the setting

To remove an array setting position, supply an argument like this:
$ ./console config:set 'section.config_setting_key[position]'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javier-de-juan in case you don't need this feature be great to remove it as well just as it adds a bit of complexity and people might rarely know the correct index of an array etc. Happy to keep it though if needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same with this, I could remove it. I'm going to wait for someone with different opinion and If there's no comments today I will change it and give just the posibility of remove settings in sections ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Be great to remove it and if needed it can be always added quickly. This way it's less things to maintain that otherwise maybe nobody would use etc and simplifies the documentation, the code etc. Let me know once you made the changes and we'll review 👍 Thanks for this, very appreciated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature was completely removed from the code ;)

@tsteur tsteur added the Needs Review PRs that need a code review label Oct 27, 2020
@tsteur tsteur added this to the 4.0.0-RC milestone Oct 27, 2020
@diosmosis
Copy link
Member

diosmosis commented Oct 27, 2020

@tsteur the original issue references having a --value option to delete array elements by value. Is this no longer a requirement?

@tsteur
Copy link
Member

tsteur commented Oct 27, 2020

@diosmosis good one. That could be useful indeed. @javier-de-juan I think previously one had to set a specific index to delete a value within an index. But the correct index is always hard to know. If it was possible to use --value to delete a value within an array only when it matches that value that might be indeed quite useful. Sorry about that. Would it be possible to add that?

@javier-de-juan
Copy link
Author

Ok, there's no problem. But... what's the desired behavior? If 2 settings have the same value the command deletes both? The section is always required, optional? I need a description about what you need to avoid wrong implementation.

@tsteur
Copy link
Member

tsteur commented Oct 28, 2020

I would say deleting value from an array would only work when specifying the key and the section as well.

Basically --section=General --key=trusted_hosts --value=mydomain.com .

When a value is set, and the configured value is a string (or a number) then we would only delete that value if the configured value matches the value from the value option. AKA if $config->$section[$key] == $configuredValue.

If the configured value is an array, then we only remove that one value from the array that matches the value from the option.

Meaning if [General] trusted_hosts[]="foobar" trusted_hosts[]="barbaz" is configured, then when using --section=General --key=trusted_hosts --value=barbaz then it would remove the last entry from that index. If --value=helloworld was used, nothing would be removed because no value matches that entry.

--section=General --key=trusted_hosts would remove the entire array.

Does this help?

@tsteur
Copy link
Member

tsteur commented Nov 2, 2020

@javier-de-juan be great to comment once you made the adjustments then we will do another review. Thanks for all this again

@tsteur tsteur modified the milestones: 4.0.0-RC, 4.1.0 Nov 9, 2020
@tsteur
Copy link
Member

tsteur commented Dec 21, 2020

@javier-de-juan are you maybe still working on this PR?

@mattab mattab modified the milestones: 4.1.0, 4.2.0 Dec 21, 2020
@sgiehl sgiehl added the Waiting for user feedback Indicates the Matomo team is waiting for feedback from the author or other users. label Jan 14, 2021
@mattab mattab modified the milestones: 4.2.0, 4.3.0 Feb 22, 2021
@sgiehl sgiehl added Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. and removed Needs Review PRs that need a code review labels Mar 15, 2021
@sgiehl
Copy link
Member

sgiehl commented Mar 15, 2021

@javier-de-juan do you maybe have some time to apply the review feedback? Would be awesome if we could merge this for the next release.

@mattab mattab modified the milestones: 4.3.0, 4.4.0 May 26, 2021
@tsteur
Copy link
Member

tsteur commented Jul 27, 2021

@javier-de-juan I will close this PR due to inactivity. If you are still keen on it feel free to let us know and we reopen the PR

@tsteur tsteur closed this Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. Waiting for user feedback Indicates the Matomo team is waiting for feedback from the author or other users.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants