Closed (fixed)
Project:
Drupal core
Version:
8.4.x-dev
Component:
configuration system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
18 Apr 2017 at 22:33 UTC
Updated:
22 Apr 2022 at 10:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dawehnerComment #4
dawehnerOops
Comment #5
tstoecklerSo this is interesting, as we otherwise use
\Drupal\Component\Uuid\Uuid::isValid()in core. In general it would be nice to use the upstream validation, but I think if we want to do that we should do so wholesale and deprecate our own version? Or alternatively make ourUuid::isValid()use Symfony's implementation internally?Comment #7
dawehnerInteresting point, well, I was thinking simply "meh". It wouldn't really be worth to reuse this method, because well, every UUID validation will work pretty much the same. In case this is about performance optimization I believe that we are dealing with validating content anyway, which probably isn't even remotely fast.
Comment #8
dawehnerI don't care about this. @tstoeckler can you please make a decision?
Comment #9
wim leersComment #10
wim leersPinged @tstoeckler: https://twitter.com/wimleers/status/857677738320293888
Comment #11
wim leersLet's get this issue moving forward again — almost 2 weeks without progress for something tiny.
So, what uses
\Drupal\Component\Uuid\Uuid::isValid()? 3 classes:\Drupal\Tests\field\Kernel\String\UuidItemTest\Drupal\KernelTests\Core\Entity\EntityFieldDefaultValueTest\Drupal\Tests\Component\Uuid\UuidTestIOW: only tests (which coincidentally implies that we aren't validating UUIDs anywhere … GASP!).
This is reusing
\Symfony\Component\Validator\Constraints\Uuid, whose corresponding pre-existing (!) validator is\Symfony\Component\Validator\Constraints\UuidValidator.Why is this then even subclassing it? Because Drupal uses a annotation-based discovery system.
And so, to add an annotation, we must subclass. And in subclassing, we rename for consistency with Drupal's other validation constraints. And in subclassing, we must override the default
validatedBy()implementation.But, in the end, this is really just reusing the existing validation constraint!
I think it's fine to deprecate
\Drupal\Component\Uuid\Uuidin favor of\Symfony\Component\Validator\Constraints\UuidValidator, but doing so is out of scope here. Opened #2876659: Deprecate \Drupal\Component\Uuid\Uuid in favor of \Symfony\Component\Validator\Constraints\UuidValidator for that.Comment #12
dawehnerThank you for the RTBC.
I made a comment on the other issue :)
Comment #13
wim leersComment #15
kristiaanvandeneynde@Wim in #11: Lame as it may be, that is indeed how core expects constraints to be declared right now :)
See other constraints such as Length or Count. Even though they change the parent's messages, they basically do the same. A solution could be to "discover" symfony constraints along with annotation based discovery, but that is also out of scope for this issue.
Comment #16
dawehnerFixed the failure ...
Comment #17
wim leersComment #18
alexpottCommitted b7eb07e and pushed to 8.4.x. Thanks!
I credited @Wim Leers, @tstoeckler and @kristiaanvandeneynde for reviews as they all considered the impact of adding the constraint and its implementation.
<3
Fixed whitespace on commit.
Comment #21
wim leersComment #23
quietone commentedClosed #2462155: Field settings schema missing for some field types as a duplicate, moving credit.