- Issue created by @borisson_
- First commit to issue fork.
- Merge request !5132#3395616 Validate preview_image on image settings configuration → (Open) created by marvil07
- last update
about 1 year ago Build Successful - Status changed to Needs review
about 1 year ago 4:54am 26 October 2023 - 🇵🇪Peru marvil07
The
preview_image
key onimage.settings
configuration stores a file path.
Symfony already provides anImage
validator, that checks the file exists and its mime type is an image.
The change on the MR adds that validation. - last update
about 1 year ago Build Successful - last update
about 1 year ago 30,437 pass, 2 fail - Status changed to Needs work
about 1 year ago 12:09pm 26 October 2023 - 🇮🇹Italy mondrake 🇮🇹
I don’t think using \Symfony\Component\Validator\Constraints\ImageValidator is appropriate here. That leverages on GD and PHP
getimagesize
functions, ehich would fit with core’s GD image toolkit. But other toolkits could provide support for other image formats.IMHO the validation here should be based on each site’s active toolkit.
- Status changed to Needs review
about 1 year ago 4:41pm 26 October 2023 - 🇵🇪Peru marvil07
@mondrake,
I don’t think using \Symfony\Component\Validator\Constraints\ImageValidator is appropriate here. That leverages on GD and PHP getimagesize functions, ehich would fit with core’s GD image toolkit. But other toolkits could provide support for other image formats.
IMHO the validation here should be based on each site’s active toolkit.
Yes, symfony's ImageValidator uses GD, but that applies when it receives the parameters to validate sizes.
No parameter is passed, so it is mostly used to validate the image mime type.
As for GD, it should be available.So, yes a custom validator can be created to use drupal image toolkit abstraction, but that may be more useful for other configuration validation cases.
In this case, it is mainly about checking that the file exists, and it is an image, which the image constraint does by extending the File constraint.
Tangentially, I think this configuration option does not even have a UI form available to be set, so tailoring to the currently used image toolkit may be more than is needed here. - Status changed to Needs work
about 1 year ago 5:41pm 26 October 2023 - 🇺🇸United States smustgrave
Seems my comment didn't make it before. But failure seems legit.
- last update
about 1 year ago 30,438 pass - Status changed to Needs review
about 1 year ago 11:20pm 26 October 2023 - 🇵🇪Peru marvil07
Seems my comment didn't make it before. But failure seems legit.
@smustgrave, thanks for pointing it out.
Indeed, the test was failing.
Even if the error is quite obscure, the problem is related to the new configuration validation being triggered.After a lot of debugging, the problem appears clearly: the failing test is testing image settings migration from the drupal 7 fixture, which has an invalid/non-existent image file pointed on the preview image related configuration, for which configuration validation was added.
The test fix is to point the test to use an image that actually exists, instead of an invalid image path.
On one end, it is great that validation is triggered and checks this, but I was amazed by the obscure and generic database connection object non-serialize-able exception, that I had not encountered before.
It would be nice to improve that in some way, but that is definitely out of scope here.Hopefully the test run confirms what I see locally.
- 🇺🇸United States smustgrave
Will see if someone more familiar with schema system can see. But changing the migration tests seems like it would be out of scope?
- 🇧🇪Belgium borisson_ Mechelen, 🇧🇪
Will see if someone more familiar with schema system can see. But changing the migration tests seems like it would be out of scope?
Well, not really, there was a configuration that was wrong before, and now we fixed it. In the required keys issue we had to ignore some test failures, because we had thousands of places where configuration was invalid in the tests.
I think we're going to see this more often. - Status changed to RTBC
about 1 year ago 2:18pm 28 October 2023 - last update
about 1 year ago 30,464 pass - last update
about 1 year ago 30,481 pass 24:13 20:33 Running- Status changed to Needs work
about 1 year ago 11:48am 2 November 2023 - 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
This is not yet ready, because there is an impact on the public API surface that is A) not documented in the issue summary nor change record, B) needs some additional scrutiny, because it is currently on a clear path to confusion 😅
- Status changed to Needs review
about 1 year ago 5:33pm 2 November 2023 - 🇵🇪Peru marvil07
@Wim Leers, thanks for the review! :+1:
The constraint is now renamed on the merge request.
I did not take any action around parameters, e.g. to prevent trying to use the validator options.
I think that is OK for now.This is not yet ready, because there is an impact on the public API surface that is A) not documented in the issue summary nor change record, B) needs some additional scrutiny, because it is currently on a clear path to confusion
I have just added a note on the issue summary.
I will wait for review feedback before opening a change record. - Status changed to RTBC
about 1 year ago 2:48pm 6 November 2023 - 🇺🇸United States smustgrave
With my limited knowledge of the schema system this looks correct to me? My question though @Wim do we need CRs for schema changes?
- last update
about 1 year ago 30,488 pass - Status changed to Needs work
about 1 year ago 3:25pm 6 November 2023 - 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Yes, we do need new CRs for new validation constraints. Recent examples: https://www.drupal.org/node/3383114 → , https://www.drupal.org/node/3372085 → , https://www.drupal.org/node/3376195 → .
- Status changed to Needs review
about 1 year ago 4:06pm 8 November 2023 - 🇵🇪Peru marvil07
@smustgrave, @Wim Leers: thanks for the feedback.
The change record has now been created at https://www.drupal.org/node/3400191 → , back to NR.
- Status changed to RTBC
about 1 year ago 4:26pm 8 November 2023 - 🇺🇸United States smustgrave
Ah that was my bad @wim. CR looks good though.
- last update
about 1 year ago 30,510 pass - 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
I think it's reasonable to RTBC/commit this without test coverage because this is tested upstream, by Symfony 👍
- last update
about 1 year ago 30,516 pass - last update
about 1 year ago 30,520 pass - last update
about 1 year ago 30,531 pass - last update
about 1 year ago 30,560 pass - last update
about 1 year ago 30,602 pass - last update
about 1 year ago 30,605 pass - last update
about 1 year ago 30,606 pass - last update
about 1 year ago 30,668 pass 39:13 35:21 Running- last update
about 1 year ago 30,684 pass - last update
about 1 year ago 30,686 pass - last update
about 1 year ago 30,688 pass - 🇳🇿New Zealand quietone
I read the issue summary and commented. I didn't find any unanswered questions or other work.
The change to the Drupal7 migration fixture caught my eye. I wanted to know if we should make the same change in any other drupal7 migration fixture in core with that line. In turns out that both the forum and tracker modules have a D7 fixture with the same line. But those fixtures aren't used for testing image settings and are unlikely to ever do so. So, they don't need to be changed.
- 🇳🇿New Zealand quietone
I meant to say thanks for the easy to follow issue summary.
- 🇵🇪Peru marvil07
marvil07 → changed the visibility of the branch 3395616-add-validation-constraints to hidden.
- last update
about 1 year ago 30,688 pass - last update
about 1 year ago 30,696 pass - last update
about 1 year ago 30,698 pass - last update
about 1 year ago 30,702 pass - last update
about 1 year ago 30,712 pass - last update
about 1 year ago 30,764 pass - last update
about 1 year ago 30,766 pass - last update
about 1 year ago 25,935 pass, 1,781 fail - last update
about 1 year ago 25,905 pass, 1,801 fail - last update
12 months ago 25,946 pass, 1,830 fail - last update
12 months ago 25,929 pass, 1,814 fail - 🇳🇿New Zealand quietone
Regarding #8. There is an issue for that 🐛 Exception trace cannot be serialized because of closure Needs work and it is a real nuisance when working on migration issues. The work around I use is
composer require mpyw/phpunit-patch-serializable-comparison
. - last update
12 months ago 25,930 pass, 1,820 fail - last update
12 months ago 25,898 pass, 1,814 fail - last update
12 months ago 25,910 pass, 1,808 fail - last update
12 months ago 25,910 pass, 1,841 fail - last update
12 months ago 25,976 pass, 1,842 fail - Status changed to Needs work
12 months ago 11:24pm 4 January 2024 - 🇺🇸United States phenaproxima Massachusetts
With this change, it looks like
image.settings
has constraints on all of its properties. So it should have theFullyValidatable
constraint as well :) - 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
@phenaproxima++
This now indeed needs the
FullyValidatable
constraint to be added toimage.settings
. See https://www.drupal.org/node/3404425 → . - First commit to issue fork.
- 🇮🇳India vakulrai
vakulrai → changed the visibility of the branch 3395616-img-settings-config-validation-constraint to hidden.
- Status changed to Needs review
11 months ago 6:17am 22 January 2024 - 🇮🇳India vakulrai
I have added the constraint validators to the
core/modules/image/config/schema/image.schema.yml
, please review.Thanks !
- Status changed to Needs work
11 months ago 7:35am 22 January 2024 - 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
@vakulrai: that looks fine, thanks!
Next up: all the other points of feedback (on the MR itself).
- Status changed to Needs review
11 months ago 8:43am 22 January 2024 - 🇮🇳India vakulrai
Hi @wim-leers i tried to add my comments on the pending feedback , please review.
Points covered :
- https://git.drupalcode.org/project/drupal/-/merge_requests/5132#note_255633
- https://git.drupalcode.org/project/drupal/-/merge_requests/5132#note_255644
Thanks !
- Status changed to Needs work
11 months ago 8:49am 22 January 2024 - 🇮🇳India narendraR Jaipur, India
This issue can be closed as duplicate of ✨ Add validation constraints to image.settings Fixed which is already fixed.