Repository navigation
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
0f781a9 to
c3cb218
Compare
78e67a3 to
7f341bd
Compare
| // without a framework, we rely on the filter for full control. | ||
|
|
||
| if ( null !== $filter_value ) { | ||
| add_filter( 'got_rewrite', array( $this, 'filter_got_rewrite' ) ); |
There was a problem hiding this comment.
I think a closure would make more sense here. No need for a method and no need for $this->temp_filter_value
| * @return array[] { | ||
| * @type bool $expected The expected result. | ||
| * @type bool $apache_loaded Whether mod_rewrite is loaded (simulated via filter). | ||
| * @type bool|null $filter_value The value to return from the filter. | ||
| * } |
There was a problem hiding this comment.
Let's use PHPStan array shape syntax since there's no need to target WordPress Developer docs.
There was a problem hiding this comment.
Not sure of the ask here
So I asked AI to help
Did it get it right?
There was a problem hiding this comment.
Yeah. That looks right. We can remove the old one though. Added a suggestion.
52f84ae to
17c6cad
Compare
17c6cad to
1f73812
Compare
9532b95 to
84a37f5
Compare
…ne/wordpress-develop into 65134-misc-got_mod_rewrite
Co-authored-by: Weston Ruter <westonruter@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
Every dataset overrides Apache detection with a non-null filter value, leaving got_mod_rewrite()’s unfiltered default behavior untested and allowing an incorrect constant result to pass.
1 open issue
What changed in this PR
Adds PHPUnit coverage for the WordPress admin helper got_mod_rewrite(), supporting Trac ticket #65134.
Changes:
- Introduces a data-driven test for boolean overrides through the
got_rewritefilter. - Adds admin/rewrite group annotations and function coverage metadata.
| File | Description |
|---|---|
tests/phpunit/tests/admin/includes/misc/gotModRewrite.php |
Adds the test class and three filter-driven datasets for got_mod_rewrite(). |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
The earlier scope and closure requests are addressed. The affected classes passed randomized single-site and multisite runs. Optional: remove the unused apache_loaded column and duplicate true row, and describe these as final-filter checks rather than Apache detection. Copilot’s detection suggestion need not become another delegation test. One CI job is cancelled, so this is code approval, not a claim that the full matrix completed.
AI review · gpt-6
|
I tried rerunning the cancelled PHPUnit job, but GitHub rejected the request because the run is over a month old. Its annotation records a 20-minute timeout; the log is no longer available to identify the slow step. Please refresh the branch against current trunk to get a fresh CI result before landing. The existing code approval and optional cleanup feedback remain unchanged. AI review · |
|
@westonruter The closure and array-shape changes you requested are now present, and the refreshed CI is green. Your changes-requested review and two outdated threads are still open. Could you confirm whether the current patch addresses your review? I’m holding the SVN landing for that confirmation. AI review · |
Co-Authored-By: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Previously every dataset installed a `got_rewrite` filter that replaced the detected value, and the `apache_loaded` parameter never configured any server state, so a constant detection result would have passed all cases. Each dataset now sets the `$is_apache` global (restored in `tear_down()`) and asserts the unfiltered result before adding the filter, then asserts that the filter overrides it. The four datasets cover both detection outcomes, each overridden to true and to false. The separate test of the unfiltered result is dropped, since the datasets cover it now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Outside Apache's own process, apache_get_modules() is unavailable, so on Apache got_mod_rewrite() returns the `true` default rather than the result of real module detection. Say so in the comment, the assertion message, and the test summary, so they don't overstate what is covered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The callback previously ignored its argument, so the test would still pass if got_mod_rewrite() passed the wrong value to the filter. Capture the value the callback receives and assert that it matches the detection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This matches set_up(), which documents the `$is_apache` global it backs up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lancewillett
left a comment
There was a problem hiding this comment.
Weston’s approval covers the current head, and the previous review requests are addressed. The test now checks the unfiltered server result, the filter override, and the value passed into the filter.
The four new provider cases passed alongside two existing rewrite checks in randomized single-site and multisite runs: six tests, 14 assertions per mode. PHP lint and coding standards pass, and current CI is green. This checks the documented CLI fallback, not actual Apache module discovery.
AI review · gpt-6
|
PR #11656 landed in https://core.trac.wordpress.org/changeset/65156 |
Verify `got_mod_rewrite()` uses the server flag for its CLI fallback and passes that detected value to `got_rewrite`. Check that the filter can override the result and restore the server flag after each test. Developed in: #11656 Props pbearne, westonruter. Fixes #65134. git-svn-id: https://develop.svn.wordpress.org/trunk@65156 602fd350-edb4-49c9-b593-d223f7449a82
Verify `got_mod_rewrite()` uses the server flag for its CLI fallback and passes that detected value to `got_rewrite`. Check that the filter can override the result and restore the server flag after each test. Developed in: WordPress/wordpress-develop#11656 Props pbearne, westonruter. Fixes #65134. Built from https://develop.svn.wordpress.org/trunk@65156 git-svn-id: http://core.svn.wordpress.org/trunk@64305 1a063a9b-81f0-0310-95a4-ce76da25c4cd

Reference: https://core.trac.wordpress.org/ticket/65134
This PR adds comprehensive unit tests for the
got_mod_rewrite()function insrc/wp-admin/includes/misc.php.The tests cover:
got_rewritefilter.Trac ticket: https://core.trac.wordpress.org/ticket/65134
Use of AI Tools
AI assistance: Yes
Tool(s): Junie (JetBrains)
Model(s): gemini-3-flash-preview
Used for: Identifying untested functions, generating the test skeleton, and implementing the
dataProviderlogic. All code was reviewed and verified against WordPress core testing patterns.