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

TypeRegistry constructor must check for duplicate instances #6083

Closed

Conversation

mvorisek
Copy link
Contributor

@mvorisek mvorisek commented Jul 1, 2023

Q A
Type bug
Fixed issues n/a

Summary

a) TypeRegistry methods like TypeRegistry::register checks if the type instance is not already registered.
b) TypeRegistry::lookupName method expects the instance to have only one name.

Thus I belive the type registry is expected to not hold duplicate type instances and this PR fixes/asserts that.

Also documented so - https://github.com/doctrine/dbal/blob/3.6.4/src/Types/TypeRegistry.php#L14

@mvorisek mvorisek force-pushed the check_dupl_instance_type_registry branch 2 times, most recently from 0d942e6 to d3d11b4 Compare July 1, 2023 15:37
@mvorisek mvorisek changed the title TypeRegistry registry constructor must check for duplicate instances TypeRegistry constructor must check for duplicate instances Jul 1, 2023
tests/Types/TypeRegistryTest.php Outdated Show resolved Hide resolved
src/Types/TypeRegistry.php Show resolved Hide resolved
@mvorisek mvorisek force-pushed the check_dupl_instance_type_registry branch from 8aebad3 to ba67b42 Compare July 9, 2023 21:46
@mvorisek
Copy link
Contributor Author

mvorisek commented Jul 13, 2023

Landed thru #6082.

@mvorisek mvorisek closed this Jul 13, 2023
@mvorisek mvorisek deleted the check_dupl_instance_type_registry branch July 13, 2023 08:00
derrabus pushed a commit that referenced this pull request Jul 15, 2023
|      Q       |   A
|------------- | -----------
| Type         | performance issue
| Fixed issues | n/a

#### Summary

We use a lot of custom types and migration from `Type::getName()` to
`TypeRegistry->lookupName()` discovered us the reverse lookup was very
slow (O(N)). This PR makes it O(1).

~Index is initialized lazily on the 1st reverse lookup.~ The type
registry is expected to not hold duplicate type instances and this PR
fixes it, in
#6083 (comment) I was
requested to fix it in this PR instead of a separate one.
cgknx pushed a commit to cgknx/dbal that referenced this pull request Aug 30, 2023
|      Q       |   A
|------------- | -----------
| Type         | performance issue
| Fixed issues | n/a

#### Summary

We use a lot of custom types and migration from `Type::getName()` to
`TypeRegistry->lookupName()` discovered us the reverse lookup was very
slow (O(N)). This PR makes it O(1).

~Index is initialized lazily on the 1st reverse lookup.~ The type
registry is expected to not hold duplicate type instances and this PR
fixes it, in
doctrine#6083 (comment) I was
requested to fix it in this PR instead of a separate one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants