wp-env: Enable pretty permalinks by default in Docker runtime#75688
wp-env: Enable pretty permalinks by default in Docker runtime#75688youknowriad merged 5 commits intotrunkfrom
Conversation
WordPress core auto-enables pretty permalinks on fresh install via `wp_install_maybe_enable_pretty_permalinks()`, but this fails in wp-env's Docker setup because the CLI container can't reach the WordPress container at the site URL for the loopback test. Add an explicit `wp rewrite structure` command after installation to match WordPress core's default behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +2 B (0%) Total Size: 6.84 MB
ℹ️ View Unchanged
|
Without --hard, wp rewrite structure only does a soft flush (updates the database) but does not write the .htaccess file. This causes Apache to return HTML 404s for /wp-json/* URLs since there are no rewrite rules to route them through WordPress. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- links.spec.js: Use regex for link href instead of hardcoded ?p= URL, and for search result option name that now includes URL slug - navigation-list-view.spec.js: Use .last() for .components-menu-item__item selector that now matches both URL info and title elements - page-list.spec.js: Use regex for slug edit link URL - preload.spec.js: Normalize /wp-json/ REST URLs the same way as ?rest_route= URLs so expected paths remain consistent Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The getCurrentThemeGlobalStylesPostId() method parsed the REST API URL
by splitting on 'rest_route=/wp/v2/global-styles/', which only works
with plain permalinks. With pretty permalinks, the URL uses
/wp-json/wp/v2/global-styles/{id} format. Use a regex that matches the
common path portion in both formats.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Flaky tests detected in 78ca02a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22170051122
|
jsnajdr
left a comment
There was a problem hiding this comment.
This looks good. Ideally wp core install would have CLI options like --enable-permalinks and --no-enable-permalinks that would turn off the autodetection and just force enabling one of the options.
The autodetection doesn't work in our situation where there is a shared filesystem used by two machines (containers). One of the runs the webserver, the other runs the wp command.
I recommend fixing or explaining some of the vibe-coded changes that I flagged: they are either incomprehensible to a human or untasteful.
| requests.push( route + urlObject.search ); | ||
| } else { | ||
| requests.push( url ); | ||
| } |
There was a problem hiding this comment.
For simplicity, we could extract and match just the path, like /wp-abilities/v1/categories. Ignore the query params like per_page=100&context=edit. The test doesn't really care, it wants to verify an explicit list of preload requests.
20 lines of code that processes the request URL are not justified here, let's cut them to something like 2 lines.
The evolution of this test is generally unfortunate. The description says "should make no requests" but as the preload requests have been creeping in, here we are checking that there are in fact four request 🙁
| page.getByRole( 'option', { | ||
| // "post" disambiguates from the "Create page" option. | ||
| name: `${ titleText } post`, | ||
| name: new RegExp( `${ titleText }.*post` ), |
There was a problem hiding this comment.
How is this related? There doesn't seem to be any URL in the text we're matching.
There was a problem hiding this comment.
The "LinkControl" component shows both the slug and the title within each suggestion when pretty permalinks are enabled. This means that the "name" of the DOM element changes a bit.
|
|
||
| return result | ||
| .locator( '.components-menu-item__item' ) // this is the only way to get the label text without the URL. | ||
| .last() |
There was a problem hiding this comment.
Same as above, the LinkControl component shows both the slug and the name of the page when pretty permalinks are enabled, this means that there are two "components-menuitem__item" per element.
Extract just the REST route path without query params, reducing the URL processing logic from ~20 lines to 3. The test only cares about which endpoints are hit, not their query parameters. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The e2e tests were passing in this PR, so my guess is a core commit but let's see. |
|
It's an RTC-related problem coming from the core trunk. |
Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
- Switch Playground from plain to pretty permalinks to match Docker runtime behavior (Docker uses wp rewrite structure '/%year%/...'). Tests were updated for pretty permalinks in #75688, so the Playground runtime needs to match. - Increase saveDraft() timeout in perf-utils from 5s to 60s. Saving 1000 paragraphs in WASM PHP on CI runners can exceed the default 5s expect timeout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Summary
WordPress core auto-enables pretty permalinks on fresh install via
wp_install_maybe_enable_pretty_permalinks(), which makes a loopback HTTP request to verify they work. In wp-env's Docker setup, this loopback fails becausewp core installruns in the CLI container, wherelocalhost:8888doesn't resolve to the WordPress container. As a result, wp-env has always started with plain permalinks — diverging from a real WordPress install.This PR adds an explicit
wp rewrite structure '/%year%/%monthnum%/%day%/%postname%/'command after installation, matching what WordPress core would set if the loopback test succeeded./wp/v2/) out of the box (previously required manual setup)/%year%/%monthnum%/%day%/%postname%/)Test plan
npm run test:unit packages/env— all 120 tests passnpm run wp-env startthenwp-env run cli "wp option get permalink_structure"returns/%year%/%monthnum%/%day%/%postname%//wp-json/wp/v2/posts🤖 Generated with Claude Code