#3395616 Validate preview_image on image settings configuration
Closes #3395616
Merge request reports
Activity
- Resolved by Marco Villegas
- Resolved by Marco Villegas
1 <?php 2 3 namespace Drupal\Core\Validation\Plugin\Validation\Constraint; 4 5 use Symfony\Component\Validator\Constraints\Image; 6 use Symfony\Component\Validator\Constraints\ImageValidator; 7 8 /** 9 * Image filepath constraint. 10 * 11 * @Constraint( 12 * id = "ImageFilePath", IMO this name is a bit confusing because it makes it look like this could only validate this is a path to an image file. However, it looks like the actual validator can do much more: https://symfony.com/doc/current/reference/constraints/Image.html.
The intention is that it will only be used as that. @lauriii Please find the rename conversation above at !5132 (comment 225922)
2 3 namespace Drupal\Core\Validation\Plugin\Validation\Constraint; 4 5 use Symfony\Component\Validator\Constraints\Image; 6 use Symfony\Component\Validator\Constraints\ImageValidator; 7 8 /** 9 * Image filepath constraint. 10 * 11 * @Constraint( 12 * id = "ImageFilePath", 13 * label = @Translation("Image filepath", context = "Validation"), 14 * type = { "string" } 15 * ) 16 */ 17 class ImageFilePathConstraint extends Image { @phenaproxima Agree , I think the idea here is to support the constraint validation as a plugin that can be added to any
schema.ymlfiles and skip any validation raised byconfig:inspectcommand.Edited by Vakul RaiI think you misunderstood @phenaproxima , @vakulrai
Adam is saying he thinks this new validation constraint should not be added at all (i.e. this PHP file), and that we should instead use Symfony-provided constraint.
29 29 // These settings are not recommended... 30 30 $this->assertTrue($config->get('allow_insecure_derivatives')); 31 31 $this->assertTrue($config->get('suppress_itok_output')); 32 $this->assertSame("core/modules/image/testsample.png", $config->get('preview_image')); 32 $this->assertSame("core/modules/image/sample.png", $config->get('preview_image')); @phenaproxima it seems the image name has been either changed or replaced in the core image module except this test file , and while running the tests it was probably resulted in failure. not sure how this was not catched by CI.
Edited by Vakul Rai
added 1 commit
- f1ef7723 - 3395616: Adding the validation constraint to image schema.
