-
Notifications
You must be signed in to change notification settings - Fork 0
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
Leverage LazyGhostTrait when possible #5
Conversation
@@ -2870,23 +2864,25 @@ public function createEntity($className, array $data, &$hints = []) | |||
break; | |||
|
|||
default: | |||
$normalizedAssociatedId = $this->normalizeIdentifier($targetClass, $associatedId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without normalization, proxies are initialized with type-incompatible values for the identifier fields!?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a bug in the existing Doctrine implementation too. I suggest submitting this fix against 2.13.x
This requirement is a must-have. Without it, change tracking would be broken as Doctrine would not have the old value initialized to compare it on flush. |
or at least, it is a must-have with the current implementation of the UnitOfWork. |
87649b5
to
ce967a2
Compare
0e1ccc1
to
b22c77f
Compare
aa1af65
to
6ec5ab9
Compare
4feaba3
to
6a8d04a
Compare
6a8d04a
to
372a413
Compare
PR updated. Now that LazyGhostTrait initializes also when setting a property, doctrine/persistence#307 is needed, and more importantly it's way easier to integrate with the ORM. This PR is green locally. Ready for more extensive review. @beberlei before I open this on the official repo of doctrine/orm, it'd be happy to know if that work is of any interest to Doctrine. I spent many weeks on it so I hope yes, but you're the one that's going to decide in the end :) /cc @greg0ire, @derrabus and @malarzm also if you can have a look and maybe share your opinion on the PR? |
d76ee6d
to
5b5dbc3
Compare
The changes in the |
@@ -148,10 +148,6 @@ protected function hydrateRowData(array $row, array &$result) | |||
} | |||
} | |||
|
|||
if (isset($this->_hints[Query::HINT_REFRESH_ENTITY])) { | |||
$this->registerManaged($this->class, $this->_hints[Query::HINT_REFRESH_ENTITY], $data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why removing this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I borrowed this from https://github.com/doctrine/orm/pull/6719/files#diff-c9c1faa5750ed5a13ec97a922d181d5b26a9f74fd79345cef5264725054cef2b and it makes tests pass without breaking any when using Common\Proxy
but I must admit I didn't understand this completely yet. Anyone does?
5b5dbc3
to
35057c2
Compare
86ba407
to
926d8a6
Compare
Only one failing test remains: The reason of the failure is that when the cloned proxy is initialized, it registers itself in the manager. The previous proxies were initialized specially when cloning. I'm not sure how to adjust the code for the new proxies. |
cb8fec6
to
760e1c9
Compare
7c9d7ea
to
74d407f
Compare
74d407f
to
5c4cec9
Compare
This PR replaces Doctrine's proxies by VarExporter's
LazyGhostTrait
.It needs doctrine/persistence#307(merged)Requires running
composer require symfony/var-exporter:^6.2@dev doctrine/persistence:^3.1@dev
to enable the new proxies for now.