Skip to content

Using the bundled PHP web server step triggers Use of undefined constant WP_CLI_ROOT warning #154

@aaemnnosttv

Description

@aaemnnosttv

Bug Report

This is probably not specific to the \WP_CLI\Tests\Context\FeatureContext::start_php_server method but this is where I encountered it.

As of WP-CLI 2.7, this method raises the following warning:

Warning: Use of undefined constant WP_CLI_ROOT - assumed 'WP_CLI_ROOT' (this will throw an Error in a future version of PHP) in vendor/wp-cli/wp-cli/php/utils.php line 44

See wp-cli/wp-cli@b179c7a (Utils\inside_phar() references the constant)

Is your bug report directly related to a specific command?

No

Are you unsure about what repository to post the bug report into?

I think so – I suppose it can be moved if needed 😄

Describe the current, buggy behavior

See above

Describe how other contributors can replicate this bug

  • Test a Behat scenario that uses a (Given|And) a PHP built-in web server step

Is this really not used? 🤔
https://github.com/search?q=org%3Awp-cli+%22a+PHP+built-in+web+server%22

Describe what you would expect as the correct outcome

This would work as before without raising a warning (wp-cli < 2.7)

Let us know what environment you are running this on

2022-10-27T15:43:59.6826507Z ┌─ @BeforeSuite # WP_CLI_Login\Tests\Context\FeatureContext::prepare()
2022-10-27T15:43:59.6827925Z │
2022-10-27T15:43:59.6829160Z │  OS:	Linux 5.15.0-1022-azure #27~20.04.1-Ubuntu SMP Mon Oct 17 02:03:50 UTC 2022 x86_64
2022-10-27T15:43:59.6830110Z │  Shell:	
2022-10-27T15:43:59.6830441Z │  PHP binary:	/usr/bin/php
2022-10-27T15:43:59.6830806Z │  PHP version:	7.4.32
2022-10-27T15:43:59.6831131Z │  php.ini used:	/etc/php/7.4/cli/php.ini
2022-10-27T15:43:59.6831434Z │  MySQL binary:	/usr/bin/mysql
2022-10-27T15:43:59.6831849Z │  MySQL version:	mysql  Ver 8.0.31-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
2022-10-27T15:43:59.6832169Z │  SQL modes:	
2022-10-27T15:43:59.6832627Z │  WP-CLI root dir:	/home/runner/work/wp-cli-login-command/wp-cli-login-command/vendor/wp-cli/wp-cli
2022-10-27T15:43:59.6833207Z │  WP-CLI vendor dir:	/home/runner/work/wp-cli-login-command/wp-cli-login-command/vendor
2022-10-27T15:43:59.6833623Z │  WP_CLI phar path:	
2022-10-27T15:43:59.6833886Z │  WP-CLI packages dir:	
2022-10-27T15:43:59.6834233Z │  WP-CLI cache dir:	/tmp/wp-cli-home/.wp-cli/cache
2022-10-27T15:43:59.6834650Z │  WP-CLI global config:	/tmp/wp-cli-package-test/config.yml
2022-10-27T15:43:59.6835157Z │  WP-CLI project config:	/home/runner/work/wp-cli-login-command/wp-cli-login-command/wp-cli.yml
2022-10-27T15:43:59.6835555Z │  WP-CLI version:	2.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions