Opened 9 years ago
Closed 9 years ago
#34037 closed defect (bug) (fixed)
Setting blog upload limit to 0 doesn't work
Reported by: | boonebgorges | Owned by: | jeremyfelt |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch |
Focuses: | administration, multisite | Cc: |
Description
There's a check in get_space_allowed()
that looks like this:
$space_allowed = get_option( 'blog_upload_space' ); // ... if ( empty( $space_allowed ) ... ) { $space_allowed = 100; }
This means that setting 'blog_upload_space' to 0 can never work. This seems to be a bug: I'd expect that setting it to 0 would mean that uploads were effectively disabled for that site.
This behavior was previously noted https://core.trac.wordpress.org/ticket/19538#comment:10 and changed [19639], but was later reverted [19652] to avoid breaking existing behavior in a minor release.
Attachments (3)
Change History (16)
#2
@
9 years ago
Seems the proper solution is to revert r19652. However wondering what changes to the UI will be needed to support this case (uploads are not allowed). Should the "Media" menu and the "Add Media" button above the editor be hidden? Or should they still be shown but with the appropriate error messages? Empty media library looks... sad.
#7
@
9 years ago
More history:
- [19314] set the check for the site level option to a strict
=== false
before deferring to the network option. Some original tests are up here http://gsoc.svn.wordpress.org/2011/jakub.tyrcha/test_wpms.php - [19639] introduced the
! is_numeric()
check.
#8
@
9 years ago
Once we fix get_space_allowed()
so that 0 is a valid return, we then run into upload_is_user_over_quota()
:
$space_allowed = get_space_allowed(); if ( empty( $space_allowed ) || !is_numeric( $space_allowed ) ) $space_allowed = 10; // Default space allowed is 10 MB
Which could then calculate slightly wrong. More tests needed!
#11
@
9 years ago
- Keywords has-patch added
- Status changed from assigned to reviewing
34037.diff modifies get_uploads_space()
to only accept a numeric value and drops the check for empty. It also adjusts the existing tests accordingly.
While the matching UI isn't perfect, it does exist for other cases where uploads have been restricted. The screenshots attached to this ticket show the current state when attempting to add media while space allowed is 0. We can probably improve this experience with a nicer message in another ticket.
In 34606: