Changeset 16097

Show
Ignore:
Timestamp:
04/15/08 16:30:23 (6 months ago)
Author:
rambo
Message:

forward port r16096

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.replicator/config/config.inc

    r16087 r16097  
    1 'queue_root_dir' => '/var/spool/midgard/replicator_queue/', 
     1'queue_root_dir' => '/var/spool/midgard/replicator_queue//', 
    22'log_filename'   => "{$GLOBALS['midcom_config']['log_filename']}.replicator", 
    33'exporter_staging2live_check_approvals_for' => array 
  • trunk/midcom/midcom.helper.replicator/exporter/mirror.php

    r15916 r16097  
    3131    function is_exportable_by_metadata(&$object) 
    3232    { 
    33         $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "is_exportable_by_metadata called"); 
     33        //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "is_exportable_by_metadata called"); 
     34        //TODO: Is there a more graceful way to do this ? (see also manager.php) 
     35        $check_exported = true; 
     36        if (   isset($GLOBALS['midcom_helper_replicator_exporter_retry_mode']) 
     37            && !empty($GLOBALS['midcom_helper_replicator_exporter_retry_mode'])) 
     38        { 
     39            $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "Retry mode, not checking metadata->exported"); 
     40            return true; 
     41        } 
    3442        if (   $object->metadata->deleted 
    3543            || (   isset($this->_serialize_rewrite_to_delete[$object->guid]) 
     
    7482        { 
    7583            // This has been exported already 
    76             $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "has alrady been exported ({$exported_unixtime} >= {$revised_unixtime}), returning false", MIDCOM_LOG_INFO); 
     84            $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "has alrady been exported", MIDCOM_LOG_INFO); 
    7785            return false; 
    7886        } 
  • trunk/midcom/midcom.helper.replicator/exporter/staging2live.php

    r16093 r16097  
    4747 
    4848    /** 
    49      * This is the main entry point of the exporter. Since we're mirroring 
    50      * all content this will always return true. 
     49     * This is the main entry point of the exporter, we'll do some approval and scheduling checks 
    5150     * 
    5251     * @param midgard_object &$object The Object to export parameters of 
     52     * @param boolean $check_exported check if the object has already been exported or not 
    5353     * @return boolean Whether the object may be exported with this exporter 
     54     * @todo log the debug messages to generic debug log and log only more informative reasons to object replication log 
    5455     */ 
    5556    function is_exportable(&$object, $check_exported = true) 
     
    8990        { 
    9091            // CAVEAT: may cause issues with multiple subscriptions 
    91             $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE is_exportable_by_metadata check: exportability = " . (int)$this->exportability[$object->guid]); 
     92            //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE is_exportable_by_metadata check: exportability = " . (int)$this->exportability[$object->guid]); 
    9293            $this->exportability[$object->guid] = parent::is_exportable_by_metadata(&$object); 
    93             $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER is_exportable_by_metadata check: exportability = " . (int)$this->exportability[$object->guid]); 
     94            //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER is_exportable_by_metadata check: exportability = " . (int)$this->exportability[$object->guid]); 
    9495        } 
    9596 
    9697        // Approvals checks 
    97         $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE approval check: exportability = " . (int)$this->exportability[$object->guid]); 
     98        //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE approval check: exportability = " . (int)$this->exportability[$object->guid]); 
    9899        $this->_check_approval($object); 
    99         $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER approval check: exportability = " . (int)$this->exportability[$object->guid]); 
     100        //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER approval check: exportability = " . (int)$this->exportability[$object->guid]); 
    100101 
    101102        /** 
     
    139140            } 
    140141        } 
    141         $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE schedule check: \$schedule_action = {$schedule_action}, exportability = " . (int)$this->exportability[$object->guid]); 
     142        //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE schedule check: \$schedule_action = {$schedule_action}, exportability = " . (int)$this->exportability[$object->guid]); 
    142143        switch ($schedule_action) 
    143144        { 
     
    179180                break; 
    180181        } 
    181         $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER schedule check: exportability = " . (int)$this->exportability[$object->guid]); 
    182  
    183         $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "is_exportable checks done, returning " . (int)$this->exportability[$object->guid]); 
     182        //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER schedule check: exportability = " . (int)$this->exportability[$object->guid]); 
     183 
     184        //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "is_exportable checks done, returning " . (int)$this->exportability[$object->guid]); 
    184185        $GLOBALS['midcom_helper_replicator_logger']->pop_prefix(); 
    185186        return $this->exportability[$object->guid]; 
     
    191192        debug_push_class(__CLASS__, __FUNCTION__); 
    192193        debug_add("Called for {$object->guid}"); 
    193         $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "_check_approval called"); 
     194        //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "_check_approval called"); 
    194195 
    195196        // Do not check approvals for deletes 
     
    200201            $msg = 'Object is deleted, do not check approvals, setting exportability explicitly to true'; 
    201202            $this->exportability[$object->guid] = true; 
    202             $GLOBALS['midcom_helper_replicator_logger']->log_object($object, $msg); 
     203            $GLOBALS['midcom_helper_replicator_logger']->log_object($object, $msg, MIDCOM_LOG_INFO); 
    203204            debug_add($msg); 
    204205            debug_pop(); 
     
    230231        { 
    231232            // Child articles don't currently have any approval UI, skip approval for them (but do check parent below) 
    232             $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Child article, not checking approval status'); 
     233            $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Reply article, not checking approval status', MIDCOM_LOG_INFO); 
    233234            $this->exportability[$object->guid] = true; 
    234235        } 
     
    237238            // FIXME: use metadata service (?) 
    238239            // Not approved since last update 
    239             $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Not approved, skipping'); 
     240            $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Object could not be exported for replication because it\'s not approved', MIDCOM_LOG_WARN); 
    240241            $this->exportability[$object->guid] = false; 
    241242        } 
     
    254255                if (!$this->exportability[$object->guid]) 
    255256                { 
    256                     $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Parent not approved, skipping'); 
     257                    //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Parent not approved, skipping'); 
    257258                    if (empty($parent_check_stack)) 
    258259                    { 
    259260                        // Empty stack means we're  not inside parent recursion, thus we can raise an UIMessage 
    260                         $_MIDCOM->load_library('midcom.helper.reflector'); 
    261261                        $ref = new midcom_helper_reflector($object); 
    262262                        $_MIDCOM->uimessages->add 
     
    271271                            'warning' 
    272272                        ); 
     273                        unset($ref); 
     274                        $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Object could not be exported for replication because one of its parents is not approved', MIDCOM_LOG_WARN); 
    273275                    } 
    274276                } 
  • trunk/midcom/midcom.helper.replicator/logger.php

    r14773 r16097  
    77* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License 
    88*/ 
     9 
     10$_MIDCOM->load_library('midcom.helper.reflector'); 
    911 
    1012/** 
     
    1820    } 
    1921 
    20     function _resolve_object_title($object
     22    function log_object(&$object, $action, $loglevel = MIDCOM_LOG_DEBUG
    2123    { 
    22         $vars = get_object_vars($object); 
    23          
    24         if (is_a($object, 'midgard_parameter')) 
    25         { 
    26             return "{$object->domain}/{$object->name}"; 
    27         } 
    28         elseif (is_a($object, 'midgard_topic')) 
    29         { 
    30             return $object->extra; 
    31         } 
    32         elseif (   array_key_exists('title', $vars) 
    33             && !empty($object->title)) 
    34         { 
    35             return $object->title; 
    36         }  
    37         elseif (   array_key_exists('name', $vars) 
    38                 && !empty($object->name))  
    39         { 
    40             return $object->name; 
    41         } 
    42         else 
    43         { 
    44             return "#{$object->id}"; 
    45         } 
    46     }   
    47      
    48     function log_object($object, $action, $loglevel = MIDCOM_LOG_DEBUG) 
    49     { 
     24        $ref = new midcom_helper_reflector($object); 
    5025        $message = $action; 
    5126        $message .= " {$object->guid}"; 
    52         $message .= ', ' . get_class($object); 
    53         $message .= ' "' . $this->_resolve_object_title($object) . '"'; 
     27        $message .= ', ' . $ref->get_class_label(); 
     28        $message .= ' "' . $ref->get_object_label($object) . '"'; 
     29        unset($ref); 
    5430         
    5531        $this->log($message, $loglevel); 
  • trunk/midcom/midcom.helper.replicator/manager.php

    r16081 r16097  
    454454        } 
    455455 
     456        if (isset($_POST['midcom_helper_replicator_requeue'])) 
     457        { 
     458            $qmanager =& midcom_helper_replicator_queuemanager::get(); 
     459            //TODO: Is there a more graceful way to do this ? (see also mirror.php) 
     460            $GLOBALS['midcom_helper_replicator_exporter_retry_mode'] = true; 
     461            if (!$qmanager->add_to_queue($data['object'])) 
     462            { 
     463                $_MIDCOM->uimessages->add 
     464                ( 
     465                    $this->_l10n->get('midcom.helper.replicator'), 
     466                    $this->_l10n->get('re-queuing failed'),  
     467                    'warning' 
     468                ); 
     469            } 
     470            unset($GLOBALS['midcom_helper_replicator_exporter_retry_mode']); 
     471        } 
    456472 
    457473        if ($bind_toolbar) 
     
    475491        ); 
    476492 
     493        $data['queue_root_dir'] = preg_replace('%/{2,}|/$%', '', $this->_local_config->get('queue_root_dir')); 
     494 
    477495        return true; 
    478496    } 
  • trunk/midcom/midcom.helper.replicator/queuemanager.php

    r16087 r16097  
    133133            } 
    134134            if (   !isset($this->file_counts[$subscription->guid]) 
    135                 || !is_array($this->file_counts[$subscription->guid])) 
    136             { 
    137                 $this->file_counts[$subscription->guid] = array()
     135                || !is_numeric($this->file_counts[$subscription->guid])) 
     136            { 
     137                $this->file_counts[$subscription->guid] = 1
    138138            } 
    139139            $i =& $this->file_counts[$subscription->guid]; 
     
    198198 
    199199                unset($key, $data); 
    200                 $i++
     200                ++$i
    201201            } 
    202202            unset($exporter_serializations); 
     
    243243    function _get_subscription_basedir(&$subscription) 
    244244    { 
    245         $global_base = $this->_config->get('queue_root_dir'); 
     245        // Normalize basedir, no trailing slash and no consecutive slashes 
     246        $global_base = preg_replace('%/{2,}|/$%', '', $this->_config->get('queue_root_dir')); 
    246247        if (!is_dir($global_base)) 
    247248        { 
  • trunk/midcom/midcom.helper.replicator/style/midcom-helper-replicator-object.php

    r5757 r16097  
    2929        <td>&(exported);</td> 
    3030    </tr> 
     31    <tr> 
     32        <td colspan=2> 
     33            <form method="post" class="midcom_helper_replicator_requeue_form"> 
     34                <input type="submit" class="button" name="midcom_helper_replicator_requeue" value="<?php echo $_MIDCOM->i18n->get_string('re-queue object', 'midcom.helper.replicator'); ?>" /> 
     35            </form> 
     36        </td> 
     37    </tr> 
    3138</table> 
    3239 
     
    3744exec("grep '{$data['object']->guid}' '{$GLOBALS['midcom_helper_replicator_logger']->_filename}'", $output); 
    3845 
     46$path_regex = "%{$data['queue_root_dir']}.*?/[0-9a-f]{32,80}(-quarantine)?/[0-9]+/%"; 
    3947echo "<ul class=\"midcom_helper_replicator_object\">\n"; 
    4048foreach ($output as $line) 
     
    5563    $component = str_replace('midcom_helper_replicator_importer', 'importer', str_replace('Queue Manager', 'queuemanager', $item_component)); 
    5664    $message = str_replace($data['object']->guid, "<abbr title=\"{$data['object']->guid}\">&lt;GUID&gt;</abbr>", $item_content); 
     65    $message = preg_replace($path_regex, '<abbr title="\\0">&lt;PATH&gt;</abbr>/', $message); 
    5766     
    5867    echo "<li class=\"{$item_class} {$component}\">";