10quality / wpmvc-commands

Ayuco commands for Wordpress MVC,
MIT License
2 stars 4 forks source link

Ensure the set command doesn't replace undesired strings. #83

Closed garretthyder closed 4 years ago

garretthyder commented 4 years ago

While PR #82 does a decent job resolving the issue in #70 it's not perfect. Testing I found the set commands can have some conflicts. For instance if you call your textdomain namespace for instance and then set it to something else it will change both the textdomain but also the key for 'namespace' which is undesireable.

To safety this we may want to look at Regex replacement here so instead of just replacing the old string with the new string for any of the set commands we take into account what should be set (version, namespace, etc) and use their key in the regex to ensure uniqueness and avoid the set changing undesired portions of the config.

To reproduce the issue; php ayuco set domain:namespace php ayuco set domain:anything *You'll find in app.php the 'namespace' key has been changed to 'anything'.

By using a regex match that includes the key w/ => we ensure we don't overwrite other keys or words by accident.