Skip to content

Tests: Avoid physical image uploads in Tests_Admin_ExportWp - #13495

Open
SainathPoojary wants to merge 2 commits into
WordPress:trunkfrom
SainathPoojary:fix/66074-export
Open

Tests: Avoid physical image uploads in Tests_Admin_ExportWp#13495
SainathPoojary wants to merge 2 commits into
WordPress:trunkfrom
SainathPoojary:fix/66074-export

Conversation

@SainathPoojary

Copy link
Copy Markdown

Optimizes fixture setup in Tests_Admin_ExportWp by avoiding physical image uploads and thumbnail generation during sample data preparation.

As noted in the ticket description for #66074, Tests_Admin_ExportWp is driven by fixture and I/O cost. Previously, wpSetUpBeforeClass() called create_upload_object(), which physically copied four JPEGs to the uploads folder and generated intermediate image sizes for each of the 11 tests running in separate PHP processes.

export_wp() tests only assert that post and attachment database records appear correctly in the exported XML, they do not inspect physical files or image dimensions. Replacing create_upload_object() with $factory->attachment->create() creates the necessary database records and thumbnail relationships directly, eliminating disk writes and GD/Imagick sub-size generation.

Performance

Local measurements across three runs (each running 11 tests across separate processes):

Run Trunk Test Time Trunk Wall Time Fix Test Time Fix Wall Time
Run 1 10.63s 34.17s 7.96s 27.24s
Run 2 8.01s 26.46s 8.36s 26.65s
Run 3 9.01s 29.13s 8.53s 29.20s
Average 9.22s 29.92s 8.28s 27.70s
  • Average JUnit runtime: ~10.1% reduction (from 9.22s to 8.28s).
  • Average PHPUnit runtime: ~7.4% reduction (from 29.92s to 27.70s).
  • Setup time per process: Dropped from ~0.72s to ~0.60s.

While the local time gain is modest and subject to process variance, eliminating disk I/O and thumbnail generation removes unnecessary filesystem churn across all separate test processes.

Validation

  • All 11 tests and 35 assertions pass on both single-site and multisite.
  • Verified attachment parent relationships and featured image IDs (set_post_thumbnail) are intact.
  • PHPCS passes with 0 errors and 0 warnings.

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

Use of AI Tools

AI assistance: Yes
Tool(s): Github Copilot
Used for: Edge-case checks, and assistance with the PR description. Implementation and testing were made and reviewed by me.


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.

@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. You can also manually ask me to refresh this list by adding the props-bot label.

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

Props sainathpoojary.

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

@lancewillett
lancewillett self-requested a review September 11, 2026 14:38

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

The simplification looks reasonable.

Before landing, please investigate the PHPUnit failures.

I reproduced that failure locally when running the export tests, the IncludesMedia upload fixtures, and the REST filename tests together.

Upload cleanup and the $ignore_files snapshot look worth investigating. A comparison didn’t guarantee clean uploads, so I haven’t established whether this PR introduces or exposes the problem.

Please resolve the failure and get CI green before we approve and commit this.

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.

2 participants