Skip to content

Only modify uploads directory when running core test suite. - #15914

Closed
peterwilsoncc wants to merge 1 commit into
WordPress:trunkfrom
peterwilsoncc:fix/63532-test-uploads-for-third-party-plugins
Closed

peterwilsoncc wants to merge 1 commit into
WordPress:trunkfrom
peterwilsoncc:fix/63532-test-uploads-for-third-party-plugins

Conversation

@peterwilsoncc

Copy link
Copy Markdown
Contributor

Limits the dedicated test uploads directory introduced in r65177 / 2700c1f and r65190 / 9dfdf85 to runs of the WordPress core test suite.

Defining UPLOADS as wp-content/test-suite-uploads for every run broke plugins and themes that use the test suite and assert against upload paths or URLs.

  • UPLOADS is now only defined, and the test uploads directory only cleaned, when WP_RUN_CORE_TESTS is set. The core phpunit.xml.dist and tests/phpunit/multisite.xml configurations already set it.
  • The _upload_get_url() test helper falls back to wp-content/uploads when UPLOADS is not defined, rather than causing a fatal error.

Testing:

  • Run vendor/bin/phpunit --group upload,media and confirm the tests pass.
  • Copy phpunit.xml.dist to a new file and remove the WP_RUN_CORE_TESTS constant. Using this configuration, run a test asserting UPLOADS is not defined and wp_upload_dir()['basedir'] ends in wp-content/uploads.

Trac ticket: https://core.trac.wordpress.org/ticket/63532#comment:39

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Drafting the code change and this description, and running the tests. I reviewed the change and the test results.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@peterwilsoncc
peterwilsoncc marked this pull request as ready for review November 11, 2026 23:58
@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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props peterwilsoncc.

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 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the change limiting upload-directory isolation to WordPress core test runs.

No open issues 🎉

What changed in this PR

This PR limits upload-directory isolation to WordPress core test runs, preserving default upload paths for plugins and themes that use the test suite.

Changes:

  • Requires WP_RUN_CORE_TESTS to be enabled before defining and cleaning the dedicated test uploads directory.
  • Adds a wp-content/uploads fallback to _upload_get_url() when UPLOADS is undefined.
File Description
tests/​phpunit/​includes/​functions.php Adds the default uploads path fallback to the URL helper.
tests/​phpunit/​includes/​bootstrap.php Restricts dedicated uploads setup and cleanup to core test runs.

Review effort: Balanced

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified 332a7e1. Two existing WooCommerce cases reproduced the upload-path regression against the base and passed with this patch: MaxMind database paths and download-handler files. The comparison used the original test assertions from before WooCommerce’s workaround with a newer local plugin copy, held constant between runs.

Focused Core upload and media checks passed before and after on single-site and multisite. The bootstrap diagnostic also confirmed that non-Core suites retain their default path and avoid the Core-only cleanup. Full local suites were not run; CI is green, and Copilot reported no issues.

AI review · gpt-6

@lancewillett

Copy link
Copy Markdown
Member

wporg-sync pushed a commit that referenced this pull request Nov 12, 2026
Preserve default upload paths for plugin and theme test suites. Only define and clean the dedicated uploads directory when `WP_RUN_CORE_TESTS` is enabled.

Developed in: #15914

Props peterwilsoncc.
See #63532.


git-svn-id: https://develop.svn.wordpress.org/trunk@65409 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 12, 2026
Preserve default upload paths for plugin and theme test suites. Only define and clean the dedicated uploads directory when `WP_RUN_CORE_TESTS` is enabled.

Developed in: WordPress/wordpress-develop#15914

Props peterwilsoncc.
See #63532.

Built from https://develop.svn.wordpress.org/trunk@65409


git-svn-id: http://core.svn.wordpress.org/trunk@64548 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@peterwilsoncc
peterwilsoncc deleted the fix/63532-test-uploads-for-third-party-plugins branch November 12, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants