Changeset 4696

Show
Ignore:
Timestamp:
07/19/08 17:57:36 (12 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).

Location:
branches/0.11/lib/Doctrine
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Connection/UnitOfWork.php

    r4487 r4696  
    5252 
    5353        $state = $record->state(); 
    54         if ($state === Doctrine_Record::STATE_LOCKED) { 
     54        if ($state === Doctrine_Record::STATE_LOCKED || $state === Doctrine_Record::STATE_TLOCKED) { 
    5555            return false; 
    5656        } 
    5757 
    58         $record->state(Doctrine_Record::STATE_LOCKED); 
     58        $record->state($record->exists() ? Doctrine_Record::STATE_LOCKED : Doctrine_Record::STATE_TLOCKED); 
    5959 
    6060        $conn->beginInternalTransaction(); 
     
    9797        $state = $record->state(); 
    9898 
    99         $record->state(Doctrine_Record::STATE_LOCKED); 
     99        $record->state($record->exists() ? Doctrine_Record::STATE_LOCKED : Doctrine_Record::STATE_TLOCKED); 
    100100 
    101101        foreach ($saveLater as $fk) { 
  • 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);