Ticket #1750 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

Loop references between models FAILS script execution

Reported by: nodkz Owned by: romanb
Priority: critical Milestone: 1.1.0-BETA2
Component: Record Version: 1.1.0-BETA1
Severity: Keywords: Record, validition, function nesting level
Cc: Has Test: no
Status: Pending Core Response Has Patch: no

Description

I have following YAML schemas:

Bill:
  columns:
    id: {type: integer(4), primary: true, autoincrement: true, unsigned: 1, notnull: true}
    customer_id: {type: integer(4), unsigned: 1}      # Id заказчика
    amount: {type: decimal, length: 18, default: 0}   # Cумма по счету
  relations:
    BillItem:                                        
      local: id
      foreign: bill_id
      type: many

BillItem:
  columns:
    id: {type: integer(4), primary: true, autoincrement: true, unsigned: 1, notnull: true}
    bill_id: {type: integer(4), unsigned: 1}          # Id счета
    title: string(255)                                # Название товара  
  relations:    
    Bill:                                          
      local: bill_id
      foreign: id  

At startup set validation attribute:

Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);

And now try to save record:

$BillItem = new BillItem();
$BillItem->bill_id = 3;
$BillItem->title = 'test';
$BillItem->save();

PHP generate error:

Fatal error: Maximum function nesting level of '100' reached, aborting!

Nesting calling was produced in method Record->isValid(); Problem in Record.php line 331:

            foreach ($this->_references as $reference) {
/////////    <---- HERE we must check on looping of _references ---->
                if ($reference instanceof Doctrine_Record) {
                    if ( ! $valid = $reference->isValid()) {  
                        break;
                    }
                } ...
            }

Change History

Changed 7 months ago by jwage

  • milestone changed from New to 1.1.0-BETA2

Changed 7 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [5311]) [1.1] Fixed infinite loop problem with isValid() (closes #1750)

Note: See TracTickets for help on using tickets.