-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
allow to add uuid as id to proxies #493
base: 2.x
Are you sure you want to change the base?
Conversation
$this->uow->scheduleInsert($userAsReference); | ||
|
||
$this->assertCount(0, $this->uow->getScheduledInserts()); | ||
$this->assertCount(0, $this->uow->getScheduledRemovals()); |
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 wanted to add a
$this->assertCount(1, $this->uow->getScheduledUpdates());
but this lets my tests fail. Was looking for a feeling that my proxy isn't flushed right way, when changing it.
Yea but i can't show it.
So when the tests are green, i would say that's it! Should i add a chanLog entry? Cause: @dantleech is right, this new feature can be confusing. But not more confusing then using What does that really change? |
Ping @dbu time to review or merge? |
I will try and have a proper look tomorrow. |
i think your idea makes sense. however, i fear its a bit more complicated:
i think we need:
i think there is still room for an accident, which is creating a proxy with uuid and then a proxy with path that are both the same node. i don't think we can avoid this without loading the node whenever creating a proxy by uuid, which defies the purpose of the proxy. |
@dbu you mean a duplicate document would occur, when somebody creates a proxy by |
the situation currently would occur for both directions: first getReference, then find. but als first find, later getReference. both can be fixed with the approach i proposed (and maybe there is something better). the last case probably can't be avoided, that when we getReference twice, once with uuid and once with path, and the uuid ref is not resolved yet, we end up with duplicates. we could detect it when the second reference is resolved and throw an exception to tell the user something is going wrong here. |
You mean trying to resolve a proxy on both ways in the same UoW shouldn't be allowed? Ok that makes sense to and is an other reason for proxyMap.
when that document is still scheduled, just to know the id. |
you are right yes. or you could just create a getPathForUuid to UoW and call that. maybe with a flag parameter to tell if you want to load the node or not if its not known yet. i think the case that does not work is when you create first both types of proxy (without first resolving one, as then you would detect on the second that you already have it) and then resolve both proxies, you will notice the clash only on the second resolution. and then you can not merge them anymore as they are separate objects that can be referenced from any place. |
Will try it that evening. |
As reminder for me: Found an other place where Will change that one to, but does the session have got no |
the phpcr session does $node->remove(), or you can use Workspace::removeItem but only with a path. i guess we really want methods on the uow to map between uuid and path and to be sure you have the path instead of all the if isUUID all over the place. |
Btw: Why does the PHPCR does not have that persister mechanism the ORM has? I know that we do the persist operation on the session and the session is a kind of that, but would be able to hide all those stuff in a persister like that:
By doing that we would get rid of all decision $id/$uuid inside of the UoW. Either a document is stored by id or by uuid inside of the identityMap. The array doesn't matter about the different meanings of the key. We just need to train getDocumentById(), registerDocument(), ... to handle both. I think the UoW is consistent with calling those methods |
does orm 2.1 already have this Persister? if not then probably this got refactored after people built phpcr-odm inspired by the orm. if we can refactor a sane part out of the UoW i am very +1 to do that, the UoW is an unwieldy beast and very hard to read and does way too many things. this might turn into a larger undertaking, but the proxy by uuid is only going to make it into 1.2 anyways. |
If somebody just wanna see the reason for this PR just have a look at my failing tests at: But i will go on my work to fix that now :-) |
Soooo, ..
I will shortly look for session calls, which don't like uuid's too (removeNode()). |
Got them all. |
*/ | ||
public function refreshDocumentForProxy($className, Proxy $document) | ||
{ | ||
$node = $this->session->getNode($this->determineDocumentId($document)); |
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.
Will need to check if this will work on my working project, cause as the proxy document is registered, the id don't need to be determined. A mapping should exist.
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.
so needed to roll back that dermineDocuemtnId($document)
not shure why that document isn't mapped.
@ElectricMaxxx do you want to pick up on this again? seems there are still quite a few loose ends. and it would need a rebase on master, its in conflict. |
@dbu thougt we wanted to refactor the complete document-/identiymap Think at the end you had some bad feelings if we do not loose a document The other think I wrote above: lets have a meeting for a |
yeah, its very very tricky if the same document can be identified with both the uuid and the path. if you want to rebase, lets be sure if we can address all i say in #493 (comment) first. the hack-weekend sounds like a fun project. only i am very short of weekends... will send you a personal email to discuss this further. |
so +1 for wrapping this up. but the builds for jackrabbit fail (seems a confusion between simple and full versionable) and there is a lot of open comments. do you want to pick this up again @ElectricMaxxx |
Yes. This would need a rebase too. Mit freundlichen Grüßen Maximilian Berghoff Maximilian Berghoff Mail: [email protected]
|
I think instead of rebasing 100 commits from master i will try to extract my changes in a new commit. |
you could squash those commits |
@ElectricMaxxx hm, seems we never wrapped this one upny chance you can clean it up? |
@ElectricMaxxx any chance we can wrap this one up? |
@ElectricMaxxx do you think we can wrap this one up for 2.0 as well? |
That would be awesome, yes.
I will try that tonight or tomorrow. I think it will be a little bit tricky.
|
cool! i suggest the first step is to move bring your changes into a clean new branch from current master. |
As described in:
https://gist.github.com/ElectricMaxxx/68a7d033a6357e757329
i would wish to create proxies (after calling
$dm->getReference('MyClassName', 'uuid');
) with the uuid as the id. This PR will make it possible that the request on the backend is able to handle the uuid.Normally
$session->getNode($id);
will fetch the node. Now there will be a check if the$id
is an uuid and fetch the node by$session->getNodeByIdentifier($id);
, which is able to look for a node by its uuid.I tried to create more tests for those documents that live as proxies in the UoW, but i do not get it to solve the mocking and i do not know if it is clever to do so, cause if i would mock some implementation depending, we would lose the decoupled view on the backend.