For both file fields and image fields, the 'Maximum upload size' is ignored.

It's easy to replicate:

  1. In a content type create a file and/or image field and set the 'Maximum upload size' to a really small value like "512" (512 bytes) or "4 KB" (4 kilobytes).
  2. Create a node and notice that the descriptions do say 'Files must be less than 512 bytes' and 'Files must be less than 4 KB'. Select a file/image that is larger than that.
  3. Now press the upload button on the field or simply save the node. No warnings or errors are displayed and the files are successfully uploaded.

The expected behavior is that an error is displayed that the files are too large, and that the upload is unsuccessful.

Remark: this is not related to #1218256: MAXIMUM UPLOAD SIZE not working! which was related to php.ini.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wmostrey’s picture

Title: 'Maximum upload size' is ignored for file fields and image fields » 'Maximum upload size' is ignored for file fields and image fields for uid 1 (undocumented)
Priority: Normal » Minor

It's only ignored for uid 1 but this is not documented for the end user. Should uid 1 be allowed to do this, even though all other $validators are respected? If so, feel free to close this issue.

wmostrey’s picture

Title: 'Maximum upload size' is ignored for file fields and image fields for uid 1 (undocumented) » Remove 'Maximum upload size' bypass for uid 1
Version: 7.4 » 8.x-dev
Status: Active » Needs review
FileSize
1.51 KB
1.51 KB

I attached the patches to remove the bypass in Drupal 7 and Drupal 8. There is no reason to bypass the maximum upload size restriction for uid 1, while enforcing all other restrictions like maximum image dimension for example.

Bojhan’s picture

Category: bug » feature

I see no reason why we should change this in D7. This is a feature, that its not documented is a bug on its own - removing it is a feature request.

All that a side, yes - I think we should remove as many special casing for UID1 as ppossible

Status: Needs review » Needs work

The last submitted patch, upload_restrictions_for_uid1_drupal8-1223194.patch, failed testing.

wmostrey’s picture

Status: Needs work » Needs review
FileSize
2.18 KB

Removing the associated test and leaving Drupal 7 as it is for now.

droplet’s picture

Priority: Minor » Normal
Status: Needs review » Reviewed & tested by the community
chx’s picture

Status: Reviewed & tested by the community » Needs work

That was a very short reasoning (ie nothing at all) for an RTBC of a possibly feature. uid 1 is supposed to be god-like so why the restriction?

wmostrey’s picture

If uid 1 is supposed to be god-like then this should turn into a patch that also removes the image dimension restriction for example. I see no good reason to only bypass this one restriction.

droplet’s picture

UID 1 able to config the site to allow ownself to upload larger files. I don't see any reason of bypass this one

wmostrey’s picture

Status: Needs work » Needs review
FileSize
2.22 KB

Re-rolled the patch.

Dave Reid’s picture

Status: Needs review » Reviewed & tested by the community

Correct. I've encountered several people filing bug reports because their user was allowed to upload larger files then they thought they should (either more than the limit set in the field instance settings or the PHP max upload size), because they were user 1.

Dave Reid’s picture

Issue tags: +sprint, +Media Initiative
catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +sprint, +Media Initiative

The last submitted patch, upload_restrictions_for_uid1_drupal8-1223194.patch, failed testing.

wmostrey’s picture

Status: Needs work » Needs review
FileSize
2.32 KB
danlinn’s picture

Status: Needs review » Needs work
Issue tags: +sprint, +Media Initiative

The last submitted patch, remove_max_upload_size_uid_1-1223194-15.patch, failed testing.

marthinal’s picture

Dave Reid’s picture

Gábor Hojtsy’s picture

Issue tags: -Media Initiative +D8Media

Fix media tag.