Development

Changeset 24583

You must first sign up to be able to contribute.

Changeset 24583

Show
Ignore:
Timestamp:
11/30/09 17:36:16 (3 years ago)
Author:
mtorres
Message:

Changes made - November 30th

  • If a column (with a change made) does not exist anymore, the plugin won't throw an exception as it used to.
  • Tables without 'created_at' field will work as well.
  • Replaced 'getId' with 'getPrimaryKey' in ncPropelChangeLogBehavior line 148
  • If a related table has multiple columns pointing to the object that is beign inspected, all of them will be look for changes. (getNNRelatedChangeLog)
  • Fix for error while looking for changes in related objects without the 'changelog' behavior
  • Fix for error while looking for changes in objects without the 'toString' method.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/ncPropelChangeLogBehaviorPlugin/lib/adapter/ncChangeLogUpdateChange.class.php

    r23721 r24583  
    6060    { 
    6161      $tableMap = call_user_func(array($peerClassName , 'getTableMap')); 
    62       if (!is_null($tableMap)
     62      if (!is_null($tableMap) && ($tableMap !== false) && ($tableMap->containsColumn($this->getFieldName()))
    6363      { 
    6464        $column = $tableMap->getColumn($this->getFieldName()); 
  • plugins/ncPropelChangeLogBehaviorPlugin/lib/ncPropelChangeLogBehavior.class.php

    r23659 r24583  
    8181    if (!$entry) 
    8282    { 
    83       $entry = ncChangeLogEntryQueue::getInstance()->selectivePop(get_class($object), ncChangeLogEntryOperation::NC_CHANGE_LOG_ENTRY_OPERATION_INSERTION, null, $object->getCreatedAt(null)); 
     83      $entry = ncChangeLogEntryQueue::getInstance()->selectivePop(get_class($object), ncChangeLogEntryOperation::NC_CHANGE_LOG_ENTRY_OPERATION_INSERTION, null, method_exists($object, 'getCreatedAt')? $object->getCreatedAt(null) : null); 
    8484    } 
    8585 
     
    145145    } 
    146146    $criteria->add(ncChangeLogEntryPeer::CLASS_NAME, get_class($object)); 
    147     $criteria->add(ncChangeLogEntryPeer::OBJECT_PK, $object->getId()); 
     147    $criteria->add(ncChangeLogEntryPeer::OBJECT_PK, $object->getPrimaryKey()); 
    148148 
    149149    $results = array(); 
     
    255255              if ($relatedClass == get_class($object)) 
    256256              { 
    257                 #FIXME: PONER UN 'OR' 
    258                 $criteria->add(constant($class.'::'.$c->getName()), $object->getPrimaryKey()); 
    259                 break; 
     257                $criterion = $criteria->getNewCriterion(constant($class.'::'.$c->getName()), $object->getPrimaryKey()); 
     258                $criteria->addOr($criterion); 
    260259              } 
    261260            } 
     
    273272        foreach ($objects as $o) 
    274273        { 
    275           try 
     274          $criteria = new Criteria(); 
     275          if (!is_null($from_date)) 
     276            $criteria->add(ncChangeLogEntryPeer::CREATED_AT, $from_date, Criteria::GREATER_THAN); 
     277          if (sfMixer::getCallable('Base'.get_class($o).':getChangeLog') && count($changes = $o->getChangeLog($criteria)) > 0) 
    276278          { 
    277             //$relatedChangeLog[$tableName][strval($o)] = $o->getChangeLog(); 
    278             if (count($changes = $o->getChangeLog()) > 0) 
     279            if (method_exists($o, '__toString')) 
    279280              $relatedChangeLog[$tableName][strval($o)] = $changes; 
    280           } catch (Exception $e) { 
    281             null
     281            else 
     282              $relatedChangeLog[$tableName][$o->getPrimaryKey()] = $changes
    282283          } 
    283284        }