Changeset 16787

Show
Ignore:
Timestamp:
07/07/08 10:51:33 (5 months ago)
Author:
rambo
Message:

forward port r16786

Files:

Legend:

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

    r16097 r16787  
    8282        { 
    8383            // This has been exported already 
    84             $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "has alrady been exported", MIDCOM_LOG_INFO); 
     84            $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "has already been exported", MIDCOM_LOG_INFO); 
    8585            return false; 
    8686        } 
  • trunk/midcom/midcom.helper.replicator/helpers.php

    r16782 r16787  
    1414 * it (otherwise properly) inside MidCOM application 
    1515 * 
    16  * For now also works around bug #259 if applicaple 
     16 * For now also works around bug #259 if applicaple and checks the serialization against bug #244 
    1717 * 
    1818 * @package midcom.helper.replicator 
     
    3030    { 
    3131        // Non-ML or not in langx does not trigger the bug 
    32         return midgard_replicator::serialize($object); 
     32        $stat = midgard_replicator::serialize($object); 
     33        return midcom_helper_replicator_serialize_check_bug244($stat, $object); 
    3334    } 
    3435    $current_language = (int)$_MIDGARD['lang']; 
     
    5960    mgd_set_errno($errno); 
    6061    unset($object_class, $object_lang0, $current_language, $current_default_language, $errno); 
    61     return $stat; 
     62    return midcom_helper_replicator_serialize_check_bug244($stat, $object); 
     63
     64 
     65/** 
     66 * Checks if serialization would trigger bug #244, if so returns failure 
     67 * and raises UI message. 
     68 * 
     69 * @param string $serialized reference to serialized object 
     70 * @return string $serialized or false if triggers bug #244 
     71 */ 
     72function midcom_helper_replicator_serialize_check_bug244(&$serialized, &$object) 
     73
     74    //debug_push_class('function', __FUNCTION__); 
     75    if (!preg_match_all('%<.+?lang=.+?>%', $serialized, $matches)) 
     76    { 
     77        // not ML or no extra languages present. 
     78        /* 
     79        debug_add('no lang matches'); 
     80        debug_pop(); 
     81        */ 
     82        return $serialized; 
     83    } 
     84    //debug_print_r('$matches: ', $matches); 
     85    $langs = count($matches[0]); 
     86    unset($matches); 
     87    if ($langs <= 1) 
     88    { 
     89        // master + 1 does not trigger bug #244 
     90        /* 
     91        debug_add("\$langs <= 1, does not trigger bug #244"); 
     92        debug_pop(); 
     93        */ 
     94        unset($langs); 
     95        return $serialized; 
     96    } 
     97    if ($langs % 2 == 0) 
     98    { 
     99        //debug_add("\$langs={$langs}, triggers bug #244"); 
     100        $total_langs = $langs+1; 
     101        $class = get_class($object); 
     102        $object_url = $_MIDCOM->get_host_prefix() . "__mfa/asgard/object/view/{$object->guid}/"; 
     103        $msg = "Object <a target='_blank' href='{$object_url}'>{$class} #{$object->id}</a> has {$total_langs} languages, this triggers <a target='_blank' href='http://trac.midgard-project.org/ticket/244'>bug #244</a>."; 
     104        $msg .= " Object will not be replicated, please go add one more language to the object in <a target='_blank' href='{$object_url}'>Asgard</a>."; 
     105        $_MIDCOM->uimessages->add('midcom.helper.replicator', $msg, 'error'); 
     106        $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "has {$total_langs} languages, this triggers bug #244, preventing export.", MIDCOM_LOG_ERROR); 
     107        unset($class, $object_url, $msg, $total_langs, $langs); 
     108        //debug_pop(); 
     109        return false; 
     110    } 
     111    /* 
     112    debug_add("\$langs % 2 != 0, does not trigger bug #244"); 
     113    debug_pop(); 
     114    */ 
     115    unset($langs); 
     116    return $serialized; 
    62117} 
    63118 
  • trunk/midcom/midcom.helper.replicator/style/midcom-helper-replicator-object.php

    r16097 r16787  
    4646$path_regex = "%{$data['queue_root_dir']}.*?/[0-9a-f]{32,80}(-quarantine)?/[0-9]+/%"; 
    4747echo "<ul class=\"midcom_helper_replicator_object\">\n"; 
     48$output = array_reverse($output); 
    4849foreach ($output as $line) 
    4950{