Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Conversation

@mattheu
Copy link

@mattheu mattheu commented Jul 6, 2022

Avoid use of GLOB_BRACE as is not always available.

When I try to run WP Hammer I get the following errors:

PHP Warning:  Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' (this will throw an Error in a future version of PHP) in ...wp-hammer/includes/Command.php on line 55
PHP Warning:  glob() expects parameter 2 to be int, string given in ...wp-hammer/includes/Command.php on line 55
PHP Warning:  Invalid argument supplied for foreach() in ...wp-hammer/includes/Command.php on line 64

Looking at the PHP docs for glob, I notice the following.

Note: The GLOB_BRACE flag is not available on some non GNU systems, like Solaris or Alpine Linux.

My local environment is docker based on Docker, that I think is built on Alpine Linux, so explains why this is not available.

Alternate Designs

It seems an easy enough change to avoid the use of GLOB_BRACE to ensure wp-hammer works on more environments.

Possible Drawbacks

GLOB_BRACE is neater, and probably more efficient. But seems like a pretty small difference.

Verification Process

  • Run hammer commands and verify they still run OK.
  • Test on an environment without GLOB_BRACE available and verify hammer commands are working.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Changelog Entry

Credits

Props @

@mattheu mattheu marked this pull request as ready for review July 6, 2022 14:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant