- πΊπΈUnited States smustgrave
Could you provide additional steps maybe? Tried replicating in D10 but was unable to generate the error.
- πΊπΈUnited States pookmish
- Install Drupal 10 using the "Standard" profile
- Create an "Article" content and upload an image to the image field via '/node/add/article' page
- Observe the image file size you've uploaded
- Edit the image field settings to be lower than your image size via '/admin/structure/types/manage/article/fields/node.article.field_image' page (even 1KB would work but I suggest 100KB lower than your uploaded image size)
- Go back and edit the article from earlier
- attempt to save with no changes on the form
- Observe the error won't allow saving
This works for any entity type in my findings: Node, Media, Paragraph, Taxonomy, User, etc.
- πΈπ°Slovakia poker10
I tested this and was able to replicate it using the steps from #14.
diff --git a/core/modules/file/tests/src/Kernel/FileItemValidationTest.php b/core/modules/file/tests/src/Kernel/FileItemValidationTest.php - $this->assertCount(2, $result); + $this->assertCount(1, $result); $this->assertEquals('field_test_file.0', $result->get(0)->getPropertyPath()); - $this->assertEquals('The file is <em class="placeholder">2.93 KB</em> exceeding the maximum file size of <em class="placeholder">2 KB</em>.', (string) $result->get(0)->getMessage()); - $this->assertEquals('field_test_file.0', $result->get(1)->getPropertyPath()); - $this->assertEquals('Only files with the following extensions are allowed: <em class="placeholder">jpg|png</em>.', (string) $result->get(1)->getMessage()); + $this->assertEquals('Only files with the following extensions are allowed: <em class="placeholder">jpg|png</em>.', (string) $result->get(0)->getMessage());
Initially I was not sure why we need to lower the error count here, because the code is run on
EntityTest::create()
, but it seems like we are referencing an existing file, so this could be a reason why it should skip the size validation.I think this also means that we should add an explicit test for this bug, because we are not testing if the files size validation is/is not applied for new/existing files.
- πΊπΈUnited States pookmish
Looks like the test changes from #16 were actually implemented in another change.
Rerolling the patch with just the .module change for D10.2.0+
- First commit to issue fork.
- πΊπΈUnited States capysara
capysara β changed the visibility of the branch 10.1.x to hidden.
- πΊπΈUnited States capysara
capysara β changed the visibility of the branch 11.x to hidden.
- πΊπΈUnited States capysara
capysara β changed the visibility of the branch ddev1223-drupal-11 to hidden.
- πΊπΈUnited States capysara
capysara β changed the visibility of the branch 3306916-check-for-new to hidden.
- πΊπΈUnited States capysara
I was able to replicate the issue in D11 using the steps in #14.
When I tried to edit and save my existing node I got an error message:
I'm moving this to a merge request instead of patches. Note: the function file_validate_size is deprecated in 11, so this change was made in the validate method of FileSizeLimitConstraintValidator.php instead.
I updated FileItemValidationTest, repeating the work from #16.
After the update, a user can save a node even if they previously added a file that exceeds the new limit.
After the update, the file limit validation still applies correctly when a user attempts to upload a files that exceeds the limit. The same behavior applies if you remove the image and attempt to re-add it.
Tests are still needed as per #17.
- π―π΄Jordan abu-zakham
Patch #18 created in the core directory, re-roll the patch from the root directory.
- π¦πΊAustralia kim.pepper πββοΈπ¦πΊSydney, Australia
file_validate_size() is deprecated in 10.2.0 and removed in 11.0.0. See https://www.drupal.org/node/3363700 β