Changeset 4460

Show
Ignore:
Timestamp:
06/01/08 07:41:27 (13 months ago)
Author:
romanb
Message:

Fixed #1099.

Location:
branches/0.11
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Node.php

    r3884 r4460  
    7171        $this->options = $options; 
    7272         
    73         // Make sure that the tree object of the root component is used in the case 
    74         // of column aggregation inheritance. 
     73        // Make sure that the tree object of the root class is used in the case 
     74        // of column aggregation inheritance (single table inheritance). 
    7575        $class = $record->getTable()->getComponentName(); 
    76         $table = $record->getTable(); 
    77         if ($table->getOption('inheritanceMap')) { 
    78             $subclasses = $table->getOption('subclasses'); 
    79             while (in_array($class, (array) $subclasses)) { 
     76        $thisTable = $record->getTable(); 
     77        $table = $thisTable; 
     78        if ($thisTable->getOption('inheritanceMap')) { 
     79            // Move up the hierarchy until we find the "subclasses" option. This option 
     80            // MUST be set on the root class of the user's hierarchy that uses STI. 
     81            while ( ! $subclasses = $table->getOption('subclasses')) { 
    8082                $class = get_parent_class($class); 
     83                if ($class == 'Doctrine_Record') { 
     84                    throw new Doctrine_Node_Exception("No subclasses specified. You are " 
     85                            . "using Single Table Inheritance with NestedSet but you have " 
     86                            . "not specified the subclasses correctly. Make sure you use " 
     87                            . "setSubclasses() in the root class of your hierarchy."); 
     88                } 
     89                $table = $table->getConnection()->getTable($class); 
    8190            } 
    8291        } 
    83         if ($class != $table->getComponentName()) { 
    84             $this->_tree = $table->getConnection()->getTable($class)->getTree(); 
     92        if ($thisTable != $table) { 
     93            $this->_tree = $table->getTree(); 
    8594        } else { 
    86             $this->_tree = $table->getTree(); 
     95            $this->_tree = $thisTable->getTree(); 
    8796        } 
    8897    } 
  • branches/0.11/lib/Doctrine/Record/Abstract.php

    r4316 r4460  
    132132            return; 
    133133        } 
    134  
    135134        $this->_table->setOption('subclasses', array_keys($map)); 
    136135    } 
  • branches/0.11/tests/run.php

    r4439 r4460  
    4646$tickets->addTestCase(new Doctrine_Ticket_941_TestCase()); 
    4747$tickets->addTestCase(new Doctrine_Ticket_930_TestCase()); 
     48$tickets->addTestCase(new Doctrine_Ticket_1099_TestCase()); 
     49$tickets->addTestCase(new Doctrine_Ticket_NewTicket_TestCase()); 
    4850 
    4951// Only uncomment the following ticket if you want to check free() performance!