Repository navigation
Media: Skip the multisite upload space check for sideloaded sub-sizes - #15954
adamsilverstein wants to merge 5 commits into
Conversation
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>
On multisite, the classic upload path checks only the original file against the site's upload space. The sub-sizes the server generates from it are written without a check. With client-side media processing each sub-size is sideloaded and was checked on its own, so a site close to its quota rejected some of them and left the attachment with missing sizes. Disable the space check while a sideloaded file is stored, so both paths treat an attachment's sub-sizes the same way. New uploads are still checked. See #66680. Claude-Session: https://claude.ai/code/session_018vwYjSXLpsi7LrGqx7UsrL
Add the `@ticket` annotation, assert the types PHPStan cannot infer, and drop the sentence describing the sideload check, which no longer runs. See #66680. Claude-Session: https://claude.ai/code/session_018vwYjSXLpsi7LrGqx7UsrL
The browser sends each sub-size as multipart form data, which takes a different upload handler than the raw request body the existing test uses. Also confirm the upload space check still applies to the next new upload. See #66680. Claude-Session: https://claude.ai/code/session_018vwYjSXLpsi7LrGqx7UsrL
Disabling the whole upload space check for a sideload also dropped the network's per-file size limit, which is unrelated to the space a site has left. Skip only the two space checks with a flag set while the file is stored, so a sideloaded file is still held to `fileupload_maxk`. See #66680. Claude-Session: https://claude.ai/code/session_018vwYjSXLpsi7LrGqx7UsrL
|
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. |
adamsilverstein
left a comment
There was a problem hiding this comment.
Code looks good, running manual tests.
|
Manual testing on a multisite install confirms the bug on trunk and the fix in this PR, screencasts below. Claude ran the before and after on a multisite Playground site:
Before (trunk): trac-66680-before.mp4After (this PR): trac-66680-after.mp4 |
|
This is an interesting one. I don't have a strong opinion here, but my read (at least from an API perspective) is that checking available space before allowing a sideload request to complete is the correct behaviour. I'd then expect the client-side logic to bail out of the upload with an error message that space is unavailable, rather than work around it on the server by allowing the sideload to complete even though the site is above its threshold. So, just an alternative idea, should or could we add additional error handling in the client-side path and leave this API intact? Or to put the question differently, on balance which is the worse state: not allowing the upload to complete, or allowing a site to go over its available space threshold? 🤔 |
Right that does seem to be what you would expect, except.... thats not how the server upload path works.
I agree it seems odd! Check the original ticket from @desrosj for a bit more history. I think the main point is matching the existing behavior (on multisite) where only the main image size is checked so that all subsizes are generated:
So it is existing behavior and if we want to change it we need a ticket to discuss that, right now the new behavior is technically a regression and is different than what the server path does. Thats what this PR fixes. I guess its mostly used by hosts who set a threshold for their client sites: eg "You get 1 gb of uploads". Its a soft threshold, not a hard/drive limit. That way, when the quota is nearly full, the last upload still works completely with all subsizes uploading if the primary upload fits in the quota. |
Claude Code wrote the fix on top of the tests from #15860, and this description:
Trac ticket: https://core.trac.wordpress.org/ticket/66680
AI Use
The fix and this description came from 🤖 Claude Code, building on the tests in #15860. I will review and test.
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.