/** * All queries are for roots (guaranteed in findMulti), so anything that falls * through and has to be queried from storage will actually need to be doing a * special condition either joining against flow_tree_node or first collecting the * subtree node lists and then doing a big IN condition * * This isn't a hot path (should be pre-populated into index) but we still don't want * horrible performance * * @param array $queries * @return array * @throws \Flow\Exception\InvalidInputException */ protected function findDescendantQuery(array $query) { $roots = array(UUID::create($query['topic_root_id'])); $nodeList = $this->treeRepository->fetchSubtreeNodeList($roots); if ($nodeList === false) { // We can't return the existing $retval, that false data would be cached. return array(); } /** @var UUID $topicRootId */ $topicRootId = UUID::create($query['topic_root_id']); $nodes = $nodeList[$topicRootId->getAlphadecimal()]; return array('rev_type_id' => UUID::convertUUIDs($nodes)); }
/** * @param UUID[] $postIds * @return UUID[] Map from alphadecimal id to UUID object */ protected function fetchRelatedPostIds(array $postIds) { // list of all posts descendant from the provided $postIds $nodeList = $this->treeRepo->fetchSubtreeNodeList($postIds); // merge all the children from the various posts into one array if (!$nodeList) { // It should have returned at least $postIds // TODO: log errors? $res = $postIds; } elseif (count($nodeList) === 1) { $res = reset($nodeList); } else { $res = call_user_func_array('array_merge', $nodeList); } $retval = array(); foreach ($res as $id) { $retval[$id->getAlphadecimal()] = $id; } return $retval; }