Changeset 6030

Show
Ignore:
Timestamp:
05/22/07 17:07:41 (2 years ago)
Author:
rambo
Message:

avoid loading tons of objects unneccessarily

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/midcom.helper.replicator/cron/queuenondba.php

    r5742 r6030  
    1515{ 
    1616    var $_qm = false; 
     17    var $skip_classes = array 
     18    ( 
     19        'midcom_helper_replicator_subscription', 
     20        'midcom_services_at_entry', 
     21    ); 
    1722 
    1823    function _on_initialize() 
     
    2631    function _on_execute() 
    2732    { 
     33        // TODO: Figure out a better way to handle these 
     34        ini_set('max_execution_time', 0); 
     35        ini_set('memory_limit', -1); 
    2836        debug_push_class(__CLASS__, __FUNCTION__); 
    2937        debug_add('_on_execute called'); 
     
    3846            return; 
    3947        } 
     48        if (!$this->_qm->can_add_to_queue()) 
     49        { 
     50            debug_add("We don't have any usable subscriptions, lets not waste resources any further", MIDCOM_LOG_INFO); 
     51            debug_pop(); 
     52            return; 
     53        } 
    4054 
    4155        foreach($_MIDGARD['schema']['types'] as $mgdschema_class => $dummy) 
     
    4357            if (empty($mgdschema_class)) 
    4458            { 
     59                // safety 
    4560                continue; 
    4661            } 
     62            if (in_array($mgdschema_class, $this->skip_classes)) 
     63            { 
     64                continue; 
     65            } 
     66 
    4767            $this->queue_type($mgdschema_class); 
    4868        } 
  • trunk/src/midcom.helper.replicator/queuemanager.php

    r6013 r6030  
    4747        return true; 
    4848    } 
    49      
     49 
     50    /** 
     51     * Check if we have any valid queues to add data to 
     52     * 
     53     * @return boolean indicating state 
     54     */ 
     55    function can_add_to_queue() 
     56    { 
     57        $qb = midcom_helper_replicator_subscription_dba::new_query_builder(); 
     58        $qb->add_constraint('status', '=', MIDCOM_REPLICATOR_AUTOMATIC); 
     59        $qb->set_limit(1); 
     60        $count = $qb->count(); 
     61        if ($count) 
     62        { 
     63            return true; 
     64        } 
     65        return false; 
     66    } 
     67 
    5068    /** 
    5169     * This method will check exporters of each subscription whether they are interested 
     
    6179        debug_push_class(__CLASS__, __FUNCTION__); 
    6280        $qb = midcom_helper_replicator_subscription_dba::new_query_builder(); 
     81        // NOTE: if this constraint is changed see can_add_to_queue() 
    6382        $qb->add_constraint('status', '=', MIDCOM_REPLICATOR_AUTOMATIC); 
    6483        $subscriptions = $qb->execute();