Development

Changeset 7392

You must first sign up to be able to contribute.

Changeset 7392

Show
Ignore:
Timestamp:
02/07/08 18:52:17 (10 months ago)
Author:
hartym
Message:

sfPropelImpersonatorPlugin: added a check to avoid having orphans objects fetched, will avoid headaches

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelImpersonatorPlugin/trunk/lib/sfPropelObjectPeerImpersonator.class.php

    r7391 r7392  
    163163                        'type'         => self::RELATION_I18N, 
    164164                        'classTo'      => $_class_to, 
    165                         'classFrom'      => $_class_from, 
     165                        'classFrom'    => $_class_from, 
    166166                        'local'        => $c->getPhpName(), 
    167167                        'distant'      => $c->getRelatedTableName(), 
     
    394394        if ($index/*&&$isNewObject*/) 
    395395        { 
     396          $linkedRelationsCounter = 0; 
     397 
    396398          foreach ($this->getRelationsFor($index) as $relation) 
    397399          { 
     
    424426                $currentObject->{'add'.$foreignClass}($foreignObject); 
    425427                $foreignObject->{'set'.$relation['classTo']}($currentObject); 
     428 
     429                $linkedRelationsCounter++; 
    426430                break; 
    427431 
     
    448452                  $object->{'set'.$relation['classTo'].'I18nForCulture'}($i18nObject, $this->getCulture()); 
    449453 
     454                  $linkedRelationsCounter++; 
    450455                } 
    451456                break; 
     
    477482                  $foreignObject->{'init'.$relation['classFrom'].'s'}($rowObjects[$index]); 
    478483                  $foreignObject->{'add'.$relation['classFrom']}($rowObjects[$index]); 
    479                 } 
     484 
     485                  $linkedRelationsCounter++; 
     486                } 
     487                break; 
     488 
     489              case self::RELATION_SELF: 
     490                throw new sfException('Self relations not yet implemented'); 
    480491                break; 
    481492            } 
     
    486497            } 
    487498          } 
     499 
     500          if (!$linkedRelationsCounter) 
     501          { 
     502            // this should not happen. An object which is not our main object has not been linked to any other 
     503            // fetched object. 
     504            throw new sfException('Orphan object fetched of type '.get_class($rowObjects[$index])); 
     505          } 
    488506        } 
    489507