Permalink
Browse files

Tweak merge logic

  • Loading branch information...
1 parent 04d3375 commit e28ef6ec39c7fefc419e8e17047e8d309905ac9d @petesiss petesiss committed Jun 16, 2012
Showing with 13 additions and 11 deletions.
  1. +13 −11 src/Jackalope/ObjectManager.php
@@ -263,27 +263,29 @@ public function getNodesByPath($paths, $class = 'Node')
// Return it from memory if we already have it
$nodes[$absPath] = $this->objectsByPath[$class][$absPath];
} else {
+ $nodes[$absPath] = '';
@lsmith77
lsmith77 Jun 20, 2012 Member

there seems to be a problem with this logic.
if i call http://cmf.lo/app_dev.php/_configurator/

i end up with an exception because the method is returning an empty string as part of the nodes array.

$fetchPaths[$absPath] = $this->getFetchPath($absPath, $class);
}
}
if (!empty($fetchPaths)) {
- $data = $this->transport->getNodes($fetchPaths, $class);
+ $data = $this->transport->getNodes($fetchPaths, $class);
+ $dataItems = array();
+
foreach ($data as $fetchPath => $item) {
- $absPath = array_search($fetchPath, $fetchPaths);
- $nodes[$absPath] = $this->getNodeByPath($absPath, $class, $item);
+ $dataItems[$fetchPath] = $item;
}
- }
- // preserve order of requested paths
- $ordered = array();
- foreach ($paths as $path) {
- if (array_key_exists($path, $nodes)) {
- $ordered[$path] = $nodes[$path];
+ foreach ($fetchPaths as $absPath => $fetchPath) {
+ if (array_key_exists($fetchPath, $dataItems)) {
+ $nodes[$absPath] = $this->getNodeByPath($absPath, $class, $dataItems[$fetchPath]);
+ } else {
+ unset($nodes[$fetchPath]);
@dbu
dbu Jun 20, 2012 Member

i think this has to unset at absPath as well. probably the reason for the problem @lsmith77 mentions above.

i will increase test coverage for this and update the code.

@petesiss
petesiss Jun 20, 2012 Contributor

yes - doesnt need to unset $fetchPath at all - just $absPath.

+ }
}
- }
+ }
- return new ArrayIterator($ordered);
+ return new ArrayIterator($nodes);
}
/**

1 comment on commit e28ef6e

@dbu
Member
dbu commented on e28ef6e Jun 20, 2012

fixed the issue with absPath vs fetchPath in 29d4a52 - it looks like the sandbox is using non-normalized paths somewhere, otherwise the error would not show

Please sign in to comment.