Skip to content

Media: Demonstrate multisite quota checks on sideloaded sub-sizes - #15860

Draft
desrosj wants to merge 1 commit into
WordPress:trunkfrom
desrosj:test/csm-multisite-sideload-quota
Draft

desrosj wants to merge 1 commit into
WordPress:trunkfrom
desrosj:test/csm-multisite-sideload-quota

Conversation

@desrosj

@desrosj desrosj commented Nov 10, 2026

Copy link
Copy Markdown
Member

Adds two multisite tests showing that client-side media processing checks each sub-size against the site's upload space quota, while the classic path only checks the original.

  • test_server_sub_sizes_after_multisite_upload_space_is_used() (passes): the original is uploaded while there is space left, the quota is then set to zero, and wp_update_image_subsizes() still writes the thumbnail.
  • test_sideload_sub_size_after_multisite_upload_space_is_used() (fails): the same situation, but the thumbnail is sideloaded as the browser would, and check_upload_size() rejects it:
{"code":"rest_upload_limited_space","message":"Not enough space to upload. 2 KB needed.","data":{"status":400}}

On a site close to its quota, this can leave an attachment with missing sub-sizes that the classic path would have generated.

The tests are tagged ms-required. To run them: npm run test:php -- -c tests/phpunit/multisite.xml --filter after_multisite_upload_space_is_used

Tests only, no fix yet. The failing test assumes the sideload should match the classic path. It is also reasonable to argue that the quota check is correct and the classic path is the lenient one. In that case, the test should expect the rejection, along with a clear error and no half-processed attachment.

Trac ticket: TBD

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Investigating the issue while reviewing #15512, and drafting the tests and this description. To be reviewed by me.

🤖 Generated with Claude Code


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.

On the classic path, only the original upload is checked against the site's upload space. The image editor then writes sub-sizes even when the original used the last of it. With client-side media processing, every sub-size is sideloaded and checked against the quota on its own, so it is rejected with "Not enough space to upload." and the attachment is left with missing sub-sizes, or deleted when they all fail.

The first test is the classic baseline and passes. The second fails until the sideload endpoint stops checking the quota for an attachment's own sub-sizes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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