Skip to content

Commit

Permalink
some more test and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Stark committed Aug 8, 2011
1 parent 52dc0fc commit db12f15
Show file tree
Hide file tree
Showing 3 changed files with 366 additions and 18 deletions.
8 changes: 7 additions & 1 deletion lib/Doctrine/ODM/PHPCR/Proxy/ReferenceProxyFactory.php
Expand Up @@ -168,6 +168,12 @@ private function getUnsetAttributes(ClassMetadata $class)
$attributes .= '$this->'.$field["fieldName"];
$attributes .= ", ";
}

foreach ($class->associationsMappings as $field) {
$attributes .= '$this->'.$field["fieldName"];
$attributes .= ", ";
}

$attributes = substr($attributes, 0, -2);

return "unset(".$attributes.");";
Expand Down Expand Up @@ -303,7 +309,7 @@ public function __set($name, $value)
$this->$name = $value;
}
public function __get($name)
public function &__get($name)
{
$this->__doctrineLoad__();
return $this->$name;
Expand Down
6 changes: 5 additions & 1 deletion lib/Doctrine/ODM/PHPCR/UnitOfWork.php
Expand Up @@ -426,6 +426,9 @@ private function cascadeScheduleInsert($class, $document, &$visited)
$related = $class->reflFields[$assocName]->getValue($document);
if ($related !== null) {
if ($class->associationsMappings[$assocName]['type'] & ClassMetadata::TO_ONE) {
if (is_array($related)) {
throw new PHPCRException("Referenced document is not stored correctly in a reference-one property. Don't use array notation.");
}
if ($this->getDocumentState($related) == self::STATE_NEW) {
$this->doScheduleInsert($related, $visited);
}
Expand Down Expand Up @@ -607,7 +610,7 @@ public function computeChangeSet(ClassMetadata $class, $document)
if ($actualData[$assocName]) {
if (is_array($actualData[$assocName])) {
foreach ($actualData[$assocName] as $ref) {
if ($ref != null) {
if ($ref !== null) {
$this->computeReferenceChanges($assoc, $ref, $id);
}
}
Expand Down Expand Up @@ -840,6 +843,7 @@ public function flush($persist_to_backend = true)
$refNodesIds[] = $this->nodesMap[$refOid]->getIdentifier();
}
$node->setProperty($class->associationsMappings[$fieldName]['fieldName'], $refNodesIds, $type);
unset($refNodesIds);
}

} elseif ($class->associationsMappings[$fieldName]['type'] === $class::MANY_TO_ONE) {
Expand Down

0 comments on commit db12f15

Please sign in to comment.