rewrite-command icon indicating copy to clipboard operation
rewrite-command copied to clipboard

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

Open david-binda opened this issue 5 years ago • 1 comments

Feature Request

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.

david-binda avatar Mar 19 '20 13:03 david-binda

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

danielbachhuber avatar Aug 29 '23 21:08 danielbachhuber