Problem/Motivation

As reported in #2870878: Add config validation for UUIDs by @tstoeckler at #2870878-5: Add config validation for UUIDs.

Proposed resolution

Deprecate \Drupal\Component\Uuid\Uuid, and make it reuse \Symfony\Component\Validator\Constraints\UuidValidator.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Wim Leers created an issue. See original summary.

dawehner’s picture

I don't believe this makes sense given you want potential UUID validation outside the context of constraints ... The UUID thing is just a generic library.

Having multiple copies of some code is not as bad as we thing it is, especially when its not business logic, as this much less likely will change.

tstoeckler’s picture

Did some archeology and this was in fact never ever used in runtime code since its introduction all the way back in August 2011.

I don't feel strongly generally about deprecating or not, but contrary to #2 I do think it is somewhat problematic to have two different code paths lying around because they are not 100% compatible.
c5199ce3-f18d-8d80-a32b-2e8d5d216e64 , for example, will pass validation by Drupal's Uuid::isValid() but not by Symfony's UuidValidator because the 8 signifies the UUID version and there are only versions 1 through 5.

If we do deprecate Uuid::isValid(), I think it's OK for this sublety to remain in place, but if we do not deprecate it, I think we should explore making Uuid::isValid() use the Symfony validator internally, so that it's just the shorthand for the latter.

kristiaanvandeneynde’s picture

I think we should explore making Uuid::isValid() use the Symfony validator internally, so that it's just the shorthand for the latter.

I'd rather bite the bullet and get rid of it altogether by D9. The old logic allows for invalid UUIDs and serves no real purpose. Why not encourage people to use the Symfony version by explicitly marking our version as deprecated?

dawehner’s picture

Nice research @tstoeckler!

I fear that adding a new dependency to the UUID component, might cause a flood of new discussions.

tstoeckler’s picture

OK, so do you agree with deprecating then?

kristiaanvandeneynde’s picture

+1 from me, but I'm pretty sure you were asking Daniel :)

wim leers’s picture

This is how I interpreted the results of this discussion:

  1. deprecate \Drupal\Component\Uuid\Uuid, but keep until before 9.0.0
  2. (ideally here, potentially follow-up) update existing uses of it, to use \Symfony\Component\Validator\Constraints\UuidValidator instead, so that core has zero uses of this newly deprecated class

Is this correct?

P.S.: great research, @tstoeckler!

dawehner’s picture

Maybe a possible alternative would be to motivate Symfony to extract the actual validation logic into its own component, so other people can use it easily. From my point of view the constrains are not meant to be used outside of the world of constrains.

kristiaanvandeneynde’s picture

That actually makes sense, seeing as we otherwise need a Constrain to pass to the validator. I've never patched Symfony before, where would one start to do such a thing? Or where would one raise a ticket for starters :)

dawehner’s picture

They are really open to contributions and they merge things much quicker (time wise) than Drupal.
https://symfony.com/doc/current/contributing/code/index.html should describe it pretty well, how to contribute to Symfony.

berdir’s picture

Just FYI, core might not use it, but I know for example entity_embed does for validating embedded entities with their UUID. Deprecating is fine of course as long as the other thing can be used as an API directly, not just as a constraint.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.