-
-
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
references by uuid #734
base: 2.x
Are you sure you want to change the base?
references by uuid #734
Conversation
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.
Can you summarize the motivation behind this PR in the description? I don't really know the full implications of this change.
@@ -21,7 +21,8 @@ | |||
"phpcr/phpcr-implementation": "^2.1.0", | |||
"phpcr/phpcr-utils": "^1.2.8", | |||
"doctrine/instantiator": "^1.0.1", | |||
"symfony/console": "^2.3|^3.0" | |||
"symfony/console": "^2.3|^3.0", | |||
"jackalope/jackalope-doctrine-dbal": "~1.0" |
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.
Don't think this should be here...
$node = $this->session->getNode($this->determineDocumentId($document)); | ||
$pathOrUuid = $this->determineDocumentId($document); | ||
$node = $this->getNodeByPathOrUuid($pathOrUuid); | ||
if (UUIDHelper::isUUID($pathOrUuid)) { |
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.
Empty line before if statement
$frozen = $this->session->nodeExists($id) && $this->session->getNode($id)->isNodeType('nt:frozenNode'); | ||
try { | ||
$node = $this->getNodeByPathOrUuid($pathOrUuid); | ||
$frozen = $node instanceof NodeInterface ? $node->isNodeType('nt:frozenNode') : false; |
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.
If the node is not an instance of NodeInterface
then what is it? If we are expecting null
then I think we should check forr null
.
@@ -917,13 +917,11 @@ public function initializeObject($document) | |||
*/ | |||
public function getNodeForDocument($document) | |||
{ | |||
if (!is_object($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.
Why do we remove this validation?
@@ -917,13 +917,11 @@ public function initializeObject($document) | |||
*/ | |||
public function getNodeForDocument($document) | |||
{ | |||
if (!is_object($document)) { | |||
throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given'); | |||
if (!$identifier = $this->unitOfWork->getDocumentId($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.
if (null === $identifier = $this->...
@@ -674,7 +675,7 @@ public function getOrCreateProxy($targetId, $className, $locale = null) | |||
$metadata = $this->dm->getClassMetadata($className); | |||
$proxyDocument = $this->dm->getProxyFactory()->getProxy($className, array($metadata->identifier => $targetId)); | |||
|
|||
// register the document under its own id | |||
// register the document under its own id/uuid |
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.
path/uuid
.
@@ -3113,6 +3126,20 @@ public function getDocumentById($id) | |||
} | |||
|
|||
/** | |||
* Creates a node from a given path or an uuid |
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.
given path or UUID
} catch (ItemNotFoundException $e) { | ||
$frozen = false; | ||
} catch (PathNotFoundException $e) { | ||
$frozen = false; |
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.
$frozen = false
can be moved before the try
block (doesn't need to be repeated twice)
$nodeData = array( | ||
"jcr:primaryType" => $primaryType, | ||
"jcr:system" => array(), | ||
'username' => $username, | ||
); | ||
if (null !== $uuid) { |
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 prefer a blank line before most if statements.
->will($this->returnValue($node)); | ||
} | ||
|
||
|
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.
One blank line too many
This will fail for sure now ... Did a lot of changes
so all documents still live in |
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.
Still not sure what the motivation of this is? Regarding the mapping I wonder if it is worth introducing a Registry class to encapsulate the various maps, reducing complication in this already very complicated class, something like: https://github.com/sulu/sulu-document-manager/blob/master/lib/DocumentRegistry.php.
But maybe something for a later iteration.
@@ -100,6 +101,18 @@ class UnitOfWork | |||
private $documentIds = array(); | |||
|
|||
/** | |||
* @var array | |||
*/ | |||
private $documentUuids = array(); |
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.
Ideally this would be better named $oidToUuidMap
, but to be consistent this naming is fine for now I guess. But it should be commented.
* | ||
* @var array | ||
*/ | ||
private $uuidIdMapping = array(); |
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.
Id
in uuidId
is redundant. Better to name $uuidToPathMap
.
@@ -3058,23 +3076,43 @@ private function unregisterDocument($document) | |||
$this->documentVersion[$oid] | |||
); | |||
|
|||
if (!empty($this->documentUuids[$oid]) && array_key_exists($this->documentUuids[$oid], $this->uuidIdMapping)) { |
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 check for !empty
?
This should wrap up #493
didn't implement the stuff, commented in code not to change.
But there are still the Questions of @dbu
I go top to button through the text/conversation, cause it is really hard to remember what the purpose was, even for me :-)