From 4a2fac7218d3b15cd8130f9c0dc2ea18e0309255 Mon Sep 17 00:00:00 2001 From: romanb Date: Tue, 4 Sep 2007 12:52:23 +0000 Subject: [PATCH] Fixed a bug in the nestedset implementation. When using single table inheritance all node instances need to use the same tree object. previously every subclass created it's own tree object which resulted in strange behaviour. --- lib/Doctrine/Node.php | 17 ++++++++++++++++- tests/run.php | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/Node.php b/lib/Doctrine/Node.php index 930777197..618f91d4e 100644 --- a/lib/Doctrine/Node.php +++ b/lib/Doctrine/Node.php @@ -68,7 +68,22 @@ class Doctrine_Node implements IteratorAggregate { $this->record = $record; $this->options = $options; - $this->_tree = $this->record->getTable()->getTree(); + + // Make sure that the tree object of the root component is used in the case + // of column aggregation inheritance. + $class = $record->getTable()->getComponentName(); + $table = $record->getTable(); + if ($table->getOption('inheritanceMap')) { + $subclasses = $table->getOption('subclasses'); + while (in_array($class, $subclasses)) { + $class = get_parent_class($class); + } + } + if ($class != $table->getComponentName()) { + $this->_tree = $table->getConnection()->getTable($class)->getTree(); + } else { + $this->_tree = $table->getTree(); + } } /** diff --git a/tests/run.php b/tests/run.php index 711152530..a59b16224 100644 --- a/tests/run.php +++ b/tests/run.php @@ -399,7 +399,7 @@ if (PHP_SAPI === 'cli') { $reporter = new MyReporter(); } -$argv = $_SERVER['argv']; +$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array(); array_shift($argv); $options = parseOptions($argv);