New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2.8.0] Requests 2.0 is a breaking change, causing fatal errors with Composer projects. #5795
Comments
I can also confirm this issue. It is breaking CI for my team. Steps to reproduce
I am less concern with the version numbering; since WP does not always follows semver. However, I am mostly disappointed:
|
Thanks for the report, @justlevine . |
One thing I'd like to note here: Do NOT pull in The You don't need any of this in a Composer stack, and this only opens up a can of worms regarding dependencies. Instead, pull in the individual command packages that you need for your particular project, like |
Thanks @schlessera - and understood. I chose to use |
This isn't specific to WP < 6.2. I'm seeing a fatal error caused because the
TBD: Is the Example composer config:
|
@justlevine I'm trying to reproduce this issue within a test. However, so far, my testing does not reveal any issue. |
I'm not terribly familiar with the A passing test case would be calling code that uses the old v1.x syntax. I can do a stack trace on fatal error to tell you what wp-core method is being called on a real-life visit to the wp-admin dashboard, in case there's a discrepancy between that and a load over cli. One sec: |
@justlevine Does your WordPress project contain a call to |
That was it, @johnbillion . Of course we need to trigger the Composer autoloader if we want to test for conflicts with autoloading. 😜 |
great catch @johnbillion! I abstracted my example from a real-world bedrock site, must not have fully cleared the old one out before I tested the replication. |
I forgot that I need to also version lock it on my composer, did not realize one of the packages depends on wp-cli. (Yes one of the mu plugins in my project calls vendor/autoload.php) Locking wp-cli to 2.7.1 on both composer and the phar works. |
I experienced the same as @johnbillion here #5795 (comment) and locking wp-cli to 2.7.1 fixes it |
Ok, I found the culprit. The Requests v2 library has a static file inclusion in Composer for the compatibility layer. When using WP-CLI with Composer, this compatibility layer gets put in front of the Requests library bundled with Core. The WP-CLI code cannot even prevent this, this all happens before any of WP-CLI's code is ever hit. I'm now looking into including the Requests library with WP-CLI in such a way that the autoloader is not being added. We're manually autoloading Requests anyway, it's just a matter of somehow telling Composer to not include that package's autoloader. |
- remove unused "use" statements - add test
A quickfix seems to be to add:
to your own |
Hey everyone, |
Thanks for the fix @schlessera, installing |
Same here, PHPStan testing is working well again 👍 |
Closing this out, thanks for the quick work! |
* upstream/main: Unlock framework version Add executable bit to DEB build version Update Composer lock file Update Composer lock file Adapt tests for PHP 8.1+ Add minimum stability dev Adapt test to pull dev-main Update make-phar file for requests path change Update Composer lock file Add debug output to test Update wp-cli/search-replace-command to latest (wp-cli#554) Load Composer autoloader Add test to trigger issue wp-cli/wp-cli#5795
Bug Report
Describe the current, buggy behavior
V2.8.0
upgradedrmccue/requests
to the (breaking)v2.0
. However, since 2.8.0 is semantically nonbreaking, any other PHP deps using the older versionrmmccue/requests
alongsidewp-cli
v2.x are now broken.The easiest replication case is simply installing
"wp-cli": ">2.7.0"
as a dev dependency on a Composer-based WordPress install < 6.2 , and you should get a WSOD (since it installswp-cli@2.8.0
and thereforerequests@2.0
to the same namespace used by WP).To illustrate the breadth of the issue effect on the ecosystem, installing
wp-cli-bundle
at a fixed 2.7.1 will cause the same issue (since wp-cli@2.8.0 is meets the SemVer requirements). This holds true if you use tooling likewpbrowser
,phpstan-wordpress
, or something that relies on 'wordpress-stubs' since they all currently use Requests 1.x internally., but install the latest semantically-compliant version ofwp-cli
).(If you have a local plugin or theme, just delete and reinstall your composer deps from your existing lock file, and you'll see those scripts will throw fatal errors).
Temporary workaround is to explicitly set
wp-cli
to v2.7.x` as a local dependency, so any packages that are expecting a SemVer compatible release get locked to the lower version).Describe how other contributors can replicate this bug
wp-cli-bundle
to2.7.x
.E.g.
wp-cli/wp-cli
v2.8.0 was installed (and not 2.7.x), and thatrmccue/requests
is at v2.x (and not v1.8.x)Note:
wp-cli-bundle
is used as a proxy for any composer dependency that doesnt have wp-cli set to a fixed version before 6.1Describe what you expect as the correct outcome
It seems to me a couple things are going wrong here:
wp-cli
2.8.0 should probably not be throwing an error when used on WordPress < 6.2, even if thats WP install is using Composer. I don't think thats really doable without resorting to something equally breaking like namespacing dependencies, which brings me to:wp-cli
2.8.0 (and thereforermccue/requests
) should not be an acceptable Composer version on projects that rely onrmccue/requests@1.x
.Let us know what environment you are running this on
PHP 8.0.26 (wsl2 + devilbox + ubuntu 20.04). Im filling this at 3AM from my mobile device so ill fill this in later.
Provide a possible solution
TBH I think the real solution is to re-release v2.8.0 as v3.0.0, but I doubt thats gonna fly. Barring that however, all projects that depend on
wp-cli
(includingwp-cli-bundle
) will need to lock themselves towp-cli
2.7.x or upgrade their usage ofrmccue/requests
to v2.x (which to be clear means that v2.8.0 will no longer be compatible with Composer-based WordPress < 6.2)Provide additional context/screenshots
As mentioned, im AFK, but here's a real world example affecting Codeception tests in wpgraphql-acf.
The text was updated successfully, but these errors were encountered: