We want to improve the experience of uploading media when you’re over quota. Part of the task is omitting the upload form for users who are over quota. In core, when the quota is exceeded ​the form isn’t displayed

However, on WordPress.com, is_upload_space_available() always returns true, because the upload_space_check_disabled option is set to true. All of these functions that try to calculate filesystem disk usage don't work on dot com as we check/store that information differently.

tl;dr: the purpose of the filter is to be able to hide the upload form while keeping upload_space_check_disabled set to true.

A heads up, in 3.5, I am thinking about going on a tear through these functions while also removing ms-files.php, since blogs.dir is baked into quite a bit of this. Perhaps most of this can just go away.

21181.patch (replaced the original by accident) includes fixes for other places that call get_dirsize(). I started to implement a filter in get_dirsize() instead of duplicating filters here but decided that wouldn't work, since get_upload_space_available() calls get_dirsize() per file if it gets past the new pre_get_upload_space_available filter. This would cause get_dirsize() to return the filtered version on every call even when we wanted to walk the file tree.

I suppose an alternate approach would be to still filter within get_dirsize() and just remove the filter in get_upload_space_available(). I'm sticking with the more explicit, transparent (if slightly repetitive) solution that calls the blog_space_used filter everywhere needed for now.

The existing test gets skipped when I run the test suite with the following error:

This test is broken when blogs.dir does not exist.

This is as intended, but even when I add a blogs.dir folder, it gets skipped. Maybe it's a case of me doing_it_wrong() in which case I'd appreciate a nudge in the right direction. Anyways, I have a suspicion that this may be why the error in [21387] never got caught, as testing upload_is_user_over_quota() should also in theory test get_space_used().

I still think having a separate test for get_space_used() is a good idea, but I am wondering what the best way to test it is. As is, it will return 0, since there's nothing in the upload directory. I am thinking uploading a temporary file in the test, calculating it's size, making sure get_space_used() matches it and then deleting the file, is what the test should do. What do you think?