Skip to content

5.3: Make Text::uuid() configurable #18807

@dereuromark

Description

@dereuromark

Description

in 6.x uuid v4 was switched to v7 (hardcoded) in Text::string().
What if people would need to keep BC across their code base (and plugins).
Or wanted to use v6 instead for sortable?

Would it be sensible here to allow uuid() method here to accept internally a callable config as opt-in to return a custom one if needed?

      public static function uuid(): string
      {
          $generator = Configure::read('Text.uuidGenerator');
          if ($generator && is_callable($generator)) {
              return $generator();
          }

          // Default v7 implementation
      }

https://github.com/josbeir/cakephp-uid/tree/main/src/Database/Type proves my point.
There wouldnt and shouldnt be the need to modify your whole code base.
And extend the core types only for this small change.
3rd party code cannot be changed anyway.

in other frameworks you would usually use DI, but we dont have that on this level

Note: This could also be backported for forward compatibility for new apps that want to use the new version right away.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions