Skip to content

Bootstrap/Load: Avoid duplicating the query string in wp_fix_server_vars() on IIS - #16125

Open
ankit-addweb wants to merge 1 commit into
WordPress:trunkfrom
ankit-addweb:fix/44766-wp-fix-server-vars-tests
Open

ankit-addweb wants to merge 1 commit into
WordPress:trunkfrom
ankit-addweb:fix/44766-wp-fix-server-vars-tests

Conversation

@ankit-addweb

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/44766

What changed

  • wp_fix_server_vars() (src/wp-includes/load.php) now appends QUERY_STRING
    to REQUEST_URI only if REQUEST_URI doesn't already contain a ?.
  • Adds tests/phpunit/tests/load/wpFixServerVars.php covering the function,
    including a regression case for the duplicated query string.

Why

On IIS, when no rewrite headers or PATH_INFO are present, REQUEST_URI
can already include the query string. The function then added it again:
/foo/?a=1&b=2 became /foo/?a=1&b=2?a=1&b=2.

How to test

  1. Check out the branch and run:
    npm run test:php -- --filter Tests_Load_WpFixServerVars
  2. Confirm all 25 tests pass.
  3. Revert the change in load.php and confirm the
    "IIS with a REQUEST_URI that already has the query string" case fails.

Notes

  • Real IIS isn't available, so IIS behavior is simulated through $_SERVER values.
  • The cgi-fcgi SAPI exclusion can't be unit-tested because PHP_SAPI is a constant.
  • The ticket's other complaint (mod_rewrite detection on newer IIS) isn't addressed.

🤖 Generated with Claude Code

…vars()` on IIS.

When `REQUEST_URI` already contains the query string, `wp_fix_server_vars()`
appended `QUERY_STRING` a second time, producing URLs like `/foo/?a=1&b=2?a=1&b=2`.
The query string is now only appended when `REQUEST_URI` has no `?`.

Adds unit tests for `wp_fix_server_vars()`.

See #44766.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @ankit-addweb.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant