wp-cli / rewrite-command

Lists or flushes the site's rewrite rules, updates the permalink structure.
MIT License
20 stars 13 forks source link

Remove unused variable `$new_assoc_args` in `wp rewrite structure` subcommand #40

Open david-binda opened 4 years ago

david-binda commented 4 years ago

Feature Request

- [x] Yes, I reviewed the [contribution guidelines](https://make.wordpress.org/cli/handbook/contributing/). **Describe your use case and the problem you are facing** I have been reviewing the code of the `wp rewrite structure` command and have run into unused `$new_assoc_args` variable , which looks like a residuum after past code updates: https://github.com/wp-cli/rewrite-command/blob/377b731cbcfb14db64bbbf9b9e16d26cb6f72ce3/src/Rewrite_Command.php#L163 The variable was introduced in https://github.com/wp-cli/rewrite-command/commit/3be1d9877a9739a6642248c4965c22618a1e4056 where `\WP_CLI::launch_wpcli` was used for launching the flush command. But it was later changed to `WP_CLI::runcommand` ( in https://github.com/wp-cli/rewrite-command/commit/bf6c7c093b977bc84bd932d10c3ec4689a452c16 ) which does not accept the assoc args param, and the `--hard` flag is being appended to the `$cmd`. Keeping the `$new_assoc_args` variable in place makes the code less readable. **Describe the solution you'd like** Removing the `$new_assoc_args` variable definition and the only other usage in the code, as the variable is never really used: https://github.com/wp-cli/rewrite-command/blob/377b731cbcfb14db64bbbf9b9e16d26cb6f72ce3/src/Rewrite_Command.php#L163 https://github.com/wp-cli/rewrite-command/blob/377b731cbcfb14db64bbbf9b9e16d26cb6f72ce3/src/Rewrite_Command.php#L167 I'm happy to open a pull request, if we agree that this issue is valid.
danielbachhuber commented 1 year ago

@david-binda Feel free to open a PR for this, if you'd like!