Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guid::uuid4() doesn't generate a Guid #306

Open
prolic opened this issue Apr 7, 2020 · 8 comments
Open

Guid::uuid4() doesn't generate a Guid #306

prolic opened this issue Apr 7, 2020 · 8 comments
Labels

Comments

@prolic
Copy link

prolic commented Apr 7, 2020

echo get_class(Ramsey\Uuid\Guid\Guid::uuid4());

will return

Ramsey\Uuid\Rfc4122\UuidV4.

I didn't expect this behavior at all.

@prolic prolic added the bug label Apr 7, 2020
@prolic
Copy link
Author

prolic commented Apr 7, 2020

Also consider this:

$f = new Ramsey\Uuid\UuidFactory(new Ramsey\Uuid\FeatureSet(true));

var_dump($f->uuid4());

will return:

PHP Fatal error: Uncaught Ramsey\Uuid\Exception\InvalidArgumentException: The byte string received does not contain a valid version in vendor/ramsey/uuid/src/Guid/Fields.php:83

@ramsey
Copy link
Owner

ramsey commented Apr 7, 2020

Are these two different issues, or do you consider them related?

As for the 1st issue, please see #301. The static methods are not part of the interface and should not be used from the subclasses. This is a bug. I’m sorry for the confusion.

@prolic
Copy link
Author

prolic commented Apr 7, 2020 via email

@ramsey
Copy link
Owner

ramsey commented Apr 7, 2020

The first issue is an oversight on my part. You should not have access to Guid::uuid4(). This is a bug. Only the Ramsey\Uuid\Uuid class should have the static methods. I will roll out a release soon that disables these static methods on child classes (they are only child classes for the sake of BC and easy transition from version 3 to 4; they will no longer be child classes in version 5).

I’ll look into the second issue. At a glance, this looks like it should work, so I think you’ve uncovered another bug here.

Thanks!

@prolic
Copy link
Author

prolic commented Apr 7, 2020

$f = new Ramsey\Uuid\UuidFactory(new Ramsey\Uuid\FeatureSet(true));

var_dump($f->uuid4());

This is solved in master branch already, not working on 4.0.1 though.

@ramsey
Copy link
Owner

ramsey commented Apr 7, 2020

The master branch is the same as 4.0.1 right now. The only difference is white space. How can this work in master and not in 4.0.1?

@prolic
Copy link
Author

prolic commented Apr 7, 2020 via email

@enumag
Copy link
Contributor

enumag commented Dec 29, 2020

@ramsey It's not fixed. The bug just doesn't always appear, it's random. I posted more details in the separate issue: #314 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants