Changeset 26440


Ignore:
Timestamp:
06/22/10 22:21:24 (7 years ago)
Author:
flack
Message:

Added new dba proxy class which helps us avoid slow serialize/deserialize operations
(and the id bug) in memcache that happen with regular dba objects. Also, change the code so that in the
default configuration, m.h.nav & f.p.navigation don't need topic objects to work

refs #359

Location:
branches/developers/flack/acltuning
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/developers/flack/acltuning/fi.protie.navigation/main.php

    r26394 r26440  
    216216
    217217    /**
     218     * Should the object's status be added to list item ul class names
     219     * Since this is mainly useful for admins/editors (and forces us to load the entire object),
     220     * it's off by default
     221     *
     222     * @access public
     223     * @var boolean
     224     */
     225    var $object_status_to_class = false;
     226
     227    /**
    218228     * CSS class for has children
    219229     *
     
    613623
    614624        // Add information about the object's status
    615         if (   isset($item[MIDCOM_NAV_OBJECT])
     625        if (   $this->object_status_to_class
     626            && isset($item[MIDCOM_NAV_OBJECT])
    616627            && $css_status_class = $_MIDCOM->metadata->get_object_classes($item[MIDCOM_NAV_OBJECT]))
    617628        {
  • branches/developers/flack/acltuning/midcom.core/midcom/baseclasses/components/navigation.php

    r25325 r26440  
    173173     * @return boolean Indicating success.
    174174     */
    175     public function set_object(midcom_baseclasses_database_topic $topic)
     175    public function set_object($topic)
    176176    {
    177177        $this->_topic = $topic;
  • branches/developers/flack/acltuning/midcom.core/midcom/helper/_basicnav.php

    r26427 r26440  
    475475    private function _get_node_from_database($topic_id, $up = null)
    476476    {
    477         $topic = midcom_db_topic::get_cached($topic_id);
     477        $topic = new midcom_core_dbaproxy($topic_id, 'midcom_db_topic');
    478478
    479479        if (   !$topic
     
    492492            && !empty($urltopic->symlink))
    493493        {
    494             $topic = midcom_db_topic::get_cached($urltopic->symlink);
     494            $topic = new midcom_core_dbaproxy($urltopic->symlink, 'midcom_db_topic');
     495
    495496            if (!$topic || !$topic->guid)
    496497            {
     
    976977
    977978        // Use the midgard_query_builder to get the subnodes
    978         $mc = midcom_db_topic::new_collector('up', self::$_nodes[$parent_node][MIDCOM_NAV_OBJECT]->id);
     979        $mc = midcom_db_topic::new_collector('up', self::$_nodes[$parent_node][MIDCOM_NAV_ID]);
    979980        $mc->add_value_property('id');
    980981
     
    10061007        $node = (int) $parent_node;
    10071008
    1008         if ($up || $node != self::$_nodes[$parent_node][MIDCOM_NAV_OBJECT]->id)
     1009        if ($up || $node != self::$_nodes[$parent_node][MIDCOM_NAV_ID])
    10091010        {
    10101011            $up = $this->_nodeid($node, $up);
     
    13221323
    13231324        return self::$_nodes[$node_id][MIDCOM_NAV_NODEID];
     1325    }
     1326
     1327    /**
     1328     * Helper function to read a parameter without loading the corresponding object.
     1329     * This is primarily for improving performance, so the function does not check
     1330     * for privileges.
     1331     *
     1332     * @param string $objectguid The object's GUID
     1333     * @param string $name The parameter to look for
     1334     */
     1335    public static function get_parameter($objectguid, $name)
     1336    {
     1337        static $parameter_cache = array();
     1338
     1339        if (!isset($parameter_cache[$objectguid]))
     1340        {
     1341            $parameter_cache[$objectguid] = array();
     1342        }
     1343
     1344        if (isset($parameter_cache[$objectguid][$name]))
     1345        {
     1346            return $parameter_cache[$objectguid][$name];
     1347        }
     1348
     1349        $mc = midgard_parameter::new_collector('parentguid', $objectguid);
     1350        $mc->set_key_property('value');
     1351        $mc->add_constraint('name', '=', $name);
     1352        $mc->add_constraint('domain', '=', 'midcom.helper.nav');
     1353        $mc->set_limit(1);
     1354        $mc->execute();
     1355        $parameters = $mc->list_keys();
     1356
     1357        if (count($parameters) == 0)
     1358        {
     1359            $parameter_cache[$objectguid][$name] = null;
     1360            return $parameter_cache[$objectguid][$name];
     1361        }
     1362
     1363        $parameter_cache[$objectguid][$name] = key($parameters);
     1364
     1365        unset($mc);
     1366
     1367        return $parameter_cache[$objectguid][$name];
    13241368    }
    13251369
  • branches/developers/flack/acltuning/midcom.core/midcom/helper/nav.php

    r25326 r26440  
    238238        }
    239239
    240         $navorder = (int) $parent_node[MIDCOM_NAV_OBJECT]->get_parameter('midcom.helper.nav', 'navorder');
     240        $navorder = (int) $this->_basicnav->get_parameter($parent_node[MIDCOM_NAV_GUID], 'navorder');
    241241
    242242        switch ($navorder)
  • branches/developers/flack/acltuning/midcom.core/midcom/services/cache/module/nap.php

    r26422 r26440  
    167167        }
    168168
    169         // Objects seem to lose their IDs sometimes when restoring form cache, so make sure they are set correctly
    170         $data = $this->_cache->get("NAP-{$key}");
    171 
    172         if (   $data
    173             && isset($data[MIDCOM_NAV_OBJECT])
    174             && is_object($data[MIDCOM_NAV_OBJECT])
    175             && $data[MIDCOM_NAV_OBJECT]->id == 0)
    176         {
    177             $data[MIDCOM_NAV_OBJECT]->id = (int) $data[MIDCOM_NAV_ID];
    178         }
    179 
    180         return $data;
     169        return $this->_cache->get("NAP-{$key}");
    181170    }
    182171
  • branches/developers/flack/acltuning/midcom.core/midcom/services/dbclassloader.php

    r26217 r26440  
    935935        if (is_object($object))
    936936        {
    937             return is_a($object, 'midcom_core_dbaobject');
     937            return (is_a($object, 'midcom_core_dbaobject') || is_a($object, 'midcom_core_dbaproxy'));
    938938        }
    939939        else if (   is_string($object)
Note: See TracChangeset for help on using the changeset viewer.