Changeset 16296

Show
Ignore:
Timestamp:
05/02/08 17:29:01 (5 months ago)
Author:
rambo
Message:

forward port r16295

Files:

Legend:

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

    r16099 r16296  
    512512    /** 
    513513     * Helper for process_queue, gets items for given queue directory pointer 
    514      */ 
    515     function _process_queue_get_items(&$dp_queue, &$queue_path, &$subscription) 
     514     * @todo use list_path_items ?? 
     515     */ 
     516    function _process_queue_get_items(&$queue_path, &$subscription) 
    516517    { 
    517518        // Start crunching each file into key => XML array 
     
    521522        $items_sort = array(); 
    522523        $GLOBALS['_process_queue_get_items__items_sort'] =& $items_sort; 
    523         while (($queue_item = readdir($dp_queue)) !== false) 
    524         { 
    525             if (   $queue_item == '.' 
    526                 || $queue_item == '..' 
    527                 || $queue_item == 'quarantine') 
    528             { 
    529                 // Skip the . and .. entries (which are always present) & old style quarantine dir 
    530                 continue; 
    531             } 
    532             $item_path = "{$queue_path}/{$queue_item}"; 
     524        $files = $this->list_path_items($queue_path); 
     525        foreach ($files as $item_path) 
     526        { 
     527            $queue_item = basename($item_path); 
    533528            if (   !is_readable($item_path) 
    534529                || !is_file($item_path)) 
     
    605600        $queue_path = "{$subscription_path}/{$queue_name}"; 
    606601 
    607         // Open handle 
    608         $dp_queue = opendir($queue_path); 
    609         if (!$dp_queue) 
    610         { 
    611             debug_add("Cannot open queue path '{$queue_path}' for reading", MIDCOM_LOG_ERROR); 
    612             debug_pop(); 
    613             return; 
    614         } 
    615  
    616602        // Get us the transporter 
    617603        $transporter = midcom_helper_replicator_transporter::create($subscription); 
     
    626612         * TODO: Read only X items to memory at a time ? 
    627613         */ 
    628         $items_ret = $this->_process_queue_get_items($dp_queue, $queue_path, $subscription); 
     614        $items_ret = $this->_process_queue_get_items($queue_path, $subscription); 
    629615        if ($items_ret === false) 
    630616        { 
    631             closedir($dp_queue); 
    632617            debug_add("Fatal error while reading items in {$queue_name}", MIDCOM_LOG_ERROR); 
    633618            debug_pop(); 
     
    636621        $items =& $items_ret[0]; 
    637622        $items_paths =& $items_ret[1]; 
    638  
    639         closedir($dp_queue); 
    640623 
    641624        if (!$transporter->process($items))