Repository navigation
Only use the server-command router when there is an index.php to route to - #371
softglazee wants to merge 1 commit into
Conversation
…e to The router of wp-cli/server-command sends every request for a missing file to index.php. When the project under test has wp-cli/server-command in its vendor directory, as in the automated tests of the bundle, the "a PHP built-in web server" step also used the router for a plain directory of files without an index.php. A request for a missing file then failed with a fatal error (a 500, or an error page with a 200 when errors are displayed) instead of a 404. That is why "Install from a remote zip URL that returns 404" in wp-cli/package-command fails in the automated tests.
|
Hello! 👋 Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project. Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation. Here are some useful Composer commands to get you started:
To run a single Behat test, you can use the following command: # Run all tests in a single file
composer behat features/some-feature.feature
# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123You can find a list of all available Behat steps in our handbook. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Problem
Since #363,
start_php_server()passes the router of wp-cli/server-command tophp -Swhenever that package is in the vendor directory of the project under test. The router sends every request for a missing file toindex.php. In a plain directory of files without anindex.php, thatrequire_oncefails, so a request for a missing file gets a fatal error instead of a 404: a 500 when errors are not displayed, or an error page with a 200 when they are.Each command's own CI does not install wp-cli/server-command, so this does not show there. The automated tests of the bundle do have it, and "Install from a remote zip URL that returns 404" in wp-cli/package-command has failed there since at least 20 September, for example in the run of 23 October:
https://github.com/wp-cli/automated-tests/actions/runs/39875417033
Changes
start_php_server()only uses the server-command router when the served directory has anindex.php, so a WordPress installation still gets pretty permalinks and a plain directory is served as-is.behat-steps.featureput a small router in the run directory'svendor/wp-cli/server-command/: without anindex.php, a missing file must be a 404; with one, a request for a pretty permalink must go through the router.Testing
index.phpfail with the fatal error from the router. With it, all 4 "a PHP built-in web server" scenarios pass. They also pass without wp-cli/server-command installed.composer phpcs,composer phpstan(including the PHP blocks in feature files),composer lintand gherkin-lint pass.Summary by CodeRabbit