Changeset 17649

Show
Ignore:
Timestamp:
09/22/08 13:43:15 (2 months ago)
Author:
rambo
Message:

not exporting children for deleted objects check should be done in mirror handler, added reflector based child handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/midcom.helper.replicator/exporter/mirror.php

    r16786 r17649  
    2323    function midcom_helper_replicator_exporter_mirror($subscription) 
    2424    { 
     25        $_MIDCOM->load_library('midcom.helper.reflector'); 
    2526        parent::midcom_helper_replicator_exporter($subscription); 
    2627    } 
     
    177178    { 
    178179        $serializations = array(); 
    179          
     180 
     181        if (   $object->metadata->deleted 
     182            || (   isset($this->_serialize_rewrite_to_delete[$object->guid]) 
     183                && $this->_serialize_rewrite_to_delete[$object->guid])) 
     184        { 
     185            // Object is deleted (either for real or just simulated), return early 
     186            debug_push_class(__CLASS__, __FUNCTION__); 
     187            $object_class = get_class($object); 
     188            debug_add("Object {$object_class} {$object->guid} is deleted, skipping child export", MIDCOM_LOG_INFO); 
     189            $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "object is deleted, do not try to find child objects, setting exportability explicitly to true", MIDCOM_LOG_INFO); 
     190            $this->exportability[$object->guid] = true; 
     191            debug_pop(); 
     192            return $serializations; 
     193        } 
     194 
    180195        // In case of a topic we have to check for possible extra dependencies 
    181196        if (is_a($object, 'midgard_topic')) 
     
    185200            unset($dependency_serializations); 
    186201        } 
    187          
     202 
     203        // Then use reflector to check for normally linked children 
     204        $children = midcom_helper_reflector_tree::get_child_objects($object); 
     205        if (is_array($children)) 
     206        { 
     207            foreach ($children as $child_class => $child_objects) 
     208            { 
     209                debug_push_class(__CLASS__, __FUNCTION__); 
     210                debug_add('Serializing ' . count($child_objects) . " {$child_class} objects"); 
     211                debug_pop(); 
     212                foreach ($child_objects as $k => $child_object) 
     213                { 
     214                    $child_serializations = $this->serialize(&$child_object); 
     215                    if ($child_serializations == false) 
     216                    { 
     217                        debug_push_class(__CLASS__, __FUNCTION__); 
     218                        debug_add("Failed to serialize child {$child_object->guid}", MIDCOM_LOG_WARN); 
     219                        debug_pop(); 
     220                    } 
     221                    else 
     222                    { 
     223                        $serializations = array_merge($serializations, $child_serializations); 
     224                    } 
     225                    unset($child_serializations, $child_objects[$k], $child_object); 
     226                } 
     227                unset($child_objects, $children[$child_class]); 
     228            } 
     229        } 
     230        unset($children); 
     231 
    188232        return $serializations; 
    189233    } 
  • branches/MidCOM_2_8/midcom.helper.replicator/exporter/staging2live.php

    r16788 r17649  
    326326    } 
    327327 
    328  
    329     /** 
    330      * Export some children of the object 
    331      * 
    332      * @param midgard_object $object The Object to export parameters of 
    333      * @return array Array of exported objects as XML indexed by GUID 
    334      * @todo rethink child/parent handling 
    335      */ 
    336     function serialize_children(&$object) 
    337     { 
    338         //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "serialize_children called"); 
    339         $serializations = array(); 
    340         if (   $object->metadata->deleted 
    341             || (   isset($this->_serialize_rewrite_to_delete[$object->guid]) 
    342                 && $this->_serialize_rewrite_to_delete[$object->guid])) 
    343         { 
    344             // Object is deleted (either for real or just simulated), return early 
    345             debug_push_class(__CLASS__, __FUNCTION__); 
    346             $object_class = get_class($object); 
    347             debug_add("Object {$object_class} {$object->guid} is deleted, skipping child export", MIDCOM_LOG_INFO); 
    348             $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "object is deleted, do not try to find child objects, setting exportability explicitly to true", MIDCOM_LOG_INFO); 
    349             $this->exportability[$object->guid] = true; 
    350             debug_pop(); 
    351             return $serializations; 
    352         } 
    353  
    354         // In case of a topic we have to check for possible extra dependencies 
    355         if (is_a($object, 'midgard_topic')) 
    356         { 
    357             $dependency_serializations = $this->serialize_component_dependencies(&$object); 
    358             $serializations = array_merge($serializations, $dependency_serializations); 
    359             unset($dependency_serializations); 
    360         } 
    361          
    362         return $serializations; 
    363     } 
    364328} 
    365329?>