Fix the computation of commit order for circular dependencies
When finding a circular dependencies, we must ensure that all dependencies of a node have been visited before adding it to the sorted list.
This commit is contained in:
parent
11a7f359d1
commit
568c2d308c
@ -164,6 +164,17 @@ class CommitOrderCalculator
|
||||
case self::IN_PROGRESS:
|
||||
if (isset($adjacentVertex->dependencyList[$vertex->hash]) &&
|
||||
$adjacentVertex->dependencyList[$vertex->hash]->weight < $edge->weight) {
|
||||
|
||||
// If we have some non-visited dependencies in the in-progress dependency, we
|
||||
// need to visit them before adding the node.
|
||||
foreach ($adjacentVertex->dependencyList as $adjacentEdge) {
|
||||
$adjacentEdgeVertex = $this->nodeList[$adjacentEdge->to];
|
||||
|
||||
if ($adjacentEdgeVertex->state === self::NOT_VISITED) {
|
||||
$this->visit($adjacentEdgeVertex);
|
||||
}
|
||||
}
|
||||
|
||||
$adjacentVertex->state = self::VISITED;
|
||||
|
||||
$this->sortedNodeList[] = $adjacentVertex->value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user