Show
Ignore:
Timestamp:
07/19/08 18:57:36 (6 months ago)
Author:
guilhermeblanco
Message:

Fixed #1222. Added new Record state called STATE_TLOCKED, which means the Record is transient (record is not yet persisted).

Files:
1 modified

Legend:

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

    r4652 r4696  
    7878     */ 
    7979    const STATE_LOCKED     = 6; 
     80     
     81    /** 
     82     * TLOCKED STATE 
     83     * a Doctrine_Record is temporarily locked (and transient) during deletes and saves 
     84     * 
     85     * This state is used internally to ensure that circular deletes 
     86     * and saves will not cause infinite loops 
     87     */ 
     88    const STATE_TLOCKED     = 7; 
    8089 
    8190    /** 
     
    668677        $err = false; 
    669678        if (is_integer($state)) { 
    670             if ($state >= 1 && $state <= 6) { 
     679            if ($state >= 1 && $state <= 7) { 
    671680                $this->_state = $state; 
    672681            } else { 
     
    12911300    public function toArray($deep = true, $prefixKey = false) 
    12921301    { 
    1293         if ($this->_state == self::STATE_LOCKED) { 
     1302        if ($this->_state == self::STATE_LOCKED || $this->_state == self::STATE_TLOCKED) { 
    12941303            return false; 
    12951304        } 
    12961305         
    12971306        $stateBeforeLock = $this->_state; 
    1298         $this->_state = self::STATE_LOCKED; 
     1307        $this->_state = $this->exists() ? self::STATE_LOCKED : self::STATE_TLOCKED; 
    12991308         
    13001309        $a = array(); 
     
    14651474    { 
    14661475        return ($this->_state !== Doctrine_Record::STATE_TCLEAN && 
    1467                 $this->_state !== Doctrine_Record::STATE_TDIRTY); 
     1476                $this->_state !== Doctrine_Record::STATE_TDIRTY && 
     1477                $this->_state !== Doctrine_Record::STATE_TLOCKED); 
    14681478    } 
    14691479 
     
    19251935    public function free($deep = false) 
    19261936    { 
    1927         if ($this->_state != self::STATE_LOCKED) { 
    1928             $this->_state = self::STATE_LOCKED; 
     1937        if ($this->_state != self::STATE_LOCKED && $this->_state != self::STATE_TLOCKED) { 
     1938            $this->_state = $this->exists() ? self::STATE_LOCKED : self::STATE_TLOCKED; 
    19291939 
    19301940            $this->_table->getRepository()->evict($this->_oid);