Steps to reproduce:
Result: I expected to see a warning about going over storage capacity, but no error ever appears and the spinner seems stuck. You never get a warning or error message but you can see a quick preview of the image uploading even though the upload won't ever go through! (11m58s)
Tested using Safari 13.1 macOS 10.15.4 on WordPress.com Free site gotravelrewards.blog logged in as testuser0313 unproxied.
~Note: For Business and eCommerce customers who signed up prior to August 2019 we need to make it so that the 200GB upload quota does not apply and they do not see any upload error messages. Let's chat about this once this issue gets picked up.~
Edit by @marekhrabe: separated into #44930, not part of this task anymore
Notes from Backlog Grooming:
I also wonder if it's connected to how these space errors are returned from the API, with that |
as mentioned in https://github.com/Automattic/wp-calypso/issues/43783#issuecomment-651859534
Testing with add_filter( 'get_space_allowed', '__return_zero' );
I get the following error:
I'll try and replicate differently.
In image blocks it's using the wp/v2/media
endpoint, so the bug mentioned in https://github.com/Automattic/wp-calypso/issues/43783#issuecomment-651859534 is not the cause here.
I re-tested this issue today and found the problem is still happening where if I drag an image into the block editor on a blog where the storage limit has been reached then the media upload fails silently without giving a helpful error message. (13m32s)
This is what I saw after giving up after ~12 minutes and closing then re-opening the post:
Tested using Safari 13.1.1 macOS 10.15.4 on WordPress.com Free site gotravelrewards.blog logged in as testuser0313 unproxied.
Next level: instead of saying 14 KB needed, consider adding a call to action such as "Upload limit has been reached. Please review your plan." I didn't find the "14 KB needed" part of the message very helpful from a user perspective. Let me know if you'd like me to open a separate issue for this part!
It works fine in Chrome but I was able to reproduce it in Safari when dragging an image into the block editor without adding a block first. It looks like the API request to upload the image never fires, so I wonder if it's a Gutenberg bug on multisites in Safari.
I couldn't get it to work in Chrome! 馃槙 (1m13s)
Tested using Chrome 84.0.4147.125 macOS 10.15.4 on WordPress.com Free site gotravelrewards.blog logged in as testuser0313 unproxied.
Unable to reproduce in linux/firefox/80.0b8, linux/chromium/85, ios/safari/13.6.1.
Test Steps:
add_filter( 'get_space_allowed', '__return_zero' );
to sandbox.add_filter( 'get_space_allowed', function () { return 5; } );
in case 0 was a special case.In all cases I saw the "Not enough space to upload. 2,453 KB needed" message.
Above we have reports of the issue happening in mac/chrome/84 and mac/safari/13.1.1. I'm also wondering if there's something other than the browsers causing the different results.
logged in as testuser0313 unproxied.
@mreishus Not sure it could be related but just in case have you tried whether proxied/unproxied yields a different result?
Hmm, have not, I was proxied the entire time I was testing. That could be it.
Switched to User through store admin and I can reproduce it. It only happens when user drags an image to the canvas. I will report later my findings or just fix it.
The problem derives from the fact that add_filter( 'get_space_allowed', '__return_zero' )
returns no available space at all where in fact the reality is totally different for most of our users. Let's say a user has 1mb left space, uploading an image of exact 1024kb would be very surprisingly and rare. Let's assume they upload an image of 1000kb. The space left then would be 24kb insufficient for any image upload.
Cases:
1) uploading through the media library or the image block return the correct error (the api is triggered)
2) dragging the image to the editor stalls, the api is never triggered
Steps to reproduce (2)
blog_upload_space
so that you have available less than 100kb (value should be in mb, accepts decimal). Be careful to note down the previous valueI assume it is something Gutenberg related as the user suggested they have seen this behaviour again in a non WordPress.com site. I keep digging.
To debug Gutenberg on your environment you may use pc9Uba-1F-p2
Adding a debugger here may give you a headstart
https://github.com/WordPress/gutenberg/blob/4405e7ba37cdf1ea1249a8dd5799952b3b757bf5/packages/components/src/higher-order/with-notices/index.js#L92-L105
I think I've tracked down the issue. I'm not sure how best to solve for it, but here's what's happening:
maxUploadFileSize
to determine if we should open a request or not to upload the filemaxUploadFileSize
will be consistentwp_max_upload_size()
to set itwp_max_upload_size()
is actually variable determined by the maximum file size OR the amount of space left after it gets filtered through this function:function upload_size_limit_filter( $size ) {
$fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 );
if ( get_site_option( 'upload_space_check_disabled' ) ) {
return min( $size, $fileupload_maxk );
}
return min( $size, $fileupload_maxk, get_upload_space_available() );
}
After removing that check for the maxUploadFileSize
in order to force an upload, we get this correct behavior when dragging an image onto the editor canvas:
I'm not sure what the best route to fix this would be. Do we:
wp_max_upload_size()
to set the maxUploadFileSize
so that it's consistent? wp_max_upload_size()
in core so that it's always consistent?Thanks @jeryj for looking into this. From my point of view, the problem is that wp-calypso (or Gutenberg) doesn't do anything (?) on the error reported by Gutenberg. It seems like a callback function is not firing or a render doesn't happen.
Back to Gutenberg... If there鈥檚 not enough space left when you try to upload a file, it returns the error without ever trying to upload the file
In fact, it is far better to prevent the upload itself and show the error than wait for the API to respond with the error. This way:
Actually, I assume we need to fix the following
https://github.com/WordPress/gutenberg/issues/21559
Actually, I assume we need to fix the following
WordPress/gutenberg#21559
Agreed! That looks like one of the issues. I guess there are two separate things:
maxUploadFileSize
is not always the correct error. We should have a way to catch the difference between a file being uploaded that is too large for the system vs a file that is exceeding the amount of space left on the server.The maxUploadFileSize is not always the correct error. We should have a way to catch the difference between a file being uploaded that is too large for the system vs a file that is exceeding the amount of space left on the server.
You are right @jeryj! Thanks for bringing this up! It seems that they used maxUploadFileSize
as a shortcut for two different things. Are you up on creating a separate issue to address/triage it?
I have tested and reviewed the following PR which will ultimately close the current issue
https://github.com/WordPress/gutenberg/pull/24398
Issue created for the incorrect Gutenberg upload error message: https://github.com/WordPress/gutenberg/issues/24948
I created a new PR so we can make progress faster
https://github.com/WordPress/gutenberg/pull/25004
The PR is merged, so the fix will be shipped with the next Gutenberg version in WordPress.com