r2312 - forward-porting to trunk
authorDenis Ovsienko <infrastation@yandex.ru>
Fri, 19 Dec 2008 14:24:59 +0000 (14:24 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Fri, 19 Dec 2008 14:24:59 +0000 (14:24 +0000)
ChangeLog
inc/database.php

index 3f1f8bc0561d62f4c7f354d81c2640aeb9f3ffa0..29893d49dc881fdb2a7d25549a04547c4eb0c094 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 0.17.0
        new feature: file attachments (by Aaron)
 0.17.0
        new feature: file attachments (by Aaron)
+       new feature: IPv4 tree expand/collapse switch
        update: display row name when listing objects. closes ticket 16 (by Aaron)
        update: ability to manage rows from the Rackspace page in addition to the Dictionary (by Aaron)
        update: IPv4 calculations were optimized for better speed
        update: display row name when listing objects. closes ticket 16 (by Aaron)
        update: ability to manage rows from the Rackspace page in addition to the Dictionary (by Aaron)
        update: IPv4 calculations were optimized for better speed
@@ -7,10 +8,10 @@
        update: add network security chapter and dictionary entries.  closes ticket 148 (by Aaron)
        update: add HP and Juniper dictionary entries.  closes tickets 145 and 165 (by Aaron)
        update: combined two forms on object properties page into one.  closes tickets 36 and 87 (by Aaron)
        update: add network security chapter and dictionary entries.  closes ticket 148 (by Aaron)
        update: add HP and Juniper dictionary entries.  closes tickets 145 and 165 (by Aaron)
        update: combined two forms on object properties page into one.  closes tickets 36 and 87 (by Aaron)
+       update: resolved performance issue for systems with many L2 ports
+       update: enable username handling in Cisco switch connector
        bugfix: show error message if snmp module isn't loaded.  closes ticket 43 (by Aaron)
        bugfix: show error message for duplicate IPv4 network record
        bugfix: show error message if snmp module isn't loaded.  closes ticket 43 (by Aaron)
        bugfix: show error message for duplicate IPv4 network record
-       update: enable username handling in Cisco switch connector
-       new feature: IPv4 tree expand/collapse switch
 0.16.4 2008-11-04
        bugfix: display VS/RS config block in RS pool view
        bugfix: resolve tabindex issues in many forms
 0.16.4 2008-11-04
        bugfix: display VS/RS config block in RS pool view
        bugfix: resolve tabindex issues in many forms
index c44e3d6ad05a4c00d8301054100dc5fd2e182ab0..0a2894c2a74cc6679c1878c89145d8e0a7f6ea57 100644 (file)
@@ -311,56 +311,60 @@ function getObjectPortsAndLinks ($object_id = 0)
                showError ('Invalid object_id', __FUNCTION__);
                return;
        }
                showError ('Invalid object_id', __FUNCTION__);
                return;
        }
-       $query =
-               "select Port.id as Port_id, ".
-               "Port.name as Port_name, ".
-               "Port.label as Port_label, ".
-               "Port.l2address as Port_l2address, ".
-               "Port.type as Port_type, ".
-               "Port.reservation_comment as Port_reservation_comment, " .
-               "dict_value as PortType_name, ".
-               "RemotePort.id as RemotePort_id, ".
-               "RemotePort.name as RemotePort_name, ".
-               "RemotePort.object_id as RemotePort_object_id, ".
-               "RackObject.name as RackObject_name ".
-               "from (".
-                       "(".
-                               "(".
-                                       "Port inner join Dictionary on Port.type = dict_key natural join Chapter".
-                               ") ".
-                               "left join Link on Port.id=Link.porta or Port.id=Link.portb ".
-                       ") ".
-                       "left join Port as RemotePort on Link.portb=RemotePort.id or Link.porta=RemotePort.id ".
-               ") ".
-               "left join RackObject on RemotePort.object_id=RackObject.id ".
-               "where chapter_name = 'PortType' and Port.object_id=${object_id} ".
-               "and (Port.id != RemotePort.id or RemotePort.id is null) ".
-               "order by Port_name";
+       // prepare decoder
+       $ptd = readChapter ('PortType');
+       $query = "select id, name, label, l2address, type as type_id, reservation_comment from Port where object_id = ${object_id}";
+       // list and decode all ports of the current object
        $result = useSelectBlade ($query, __FUNCTION__);
        $ret=array();
        $result = useSelectBlade ($query, __FUNCTION__);
        $ret=array();
-       $count=0;
        while ($row = $result->fetch (PDO::FETCH_ASSOC))
        {
        while ($row = $result->fetch (PDO::FETCH_ASSOC))
        {
-               $ret[$count]['id'] = $row['Port_id'];
-               $ret[$count]['name'] = $row['Port_name'];
-               $ret[$count]['l2address'] = l2addressFromDatabase ($row['Port_l2address']);
-               $ret[$count]['label'] = $row['Port_label'];
-               $ret[$count]['type_id'] = $row['Port_type'];
-               $ret[$count]['type'] = $row['PortType_name'];
-               $ret[$count]['reservation_comment'] = $row['Port_reservation_comment'];
-               $ret[$count]['remote_id'] = $row['RemotePort_id'];
-               $ret[$count]['remote_name'] = htmlentities ($row['RemotePort_name'], ENT_QUOTES);
-               $ret[$count]['remote_object_id'] = $row['RemotePort_object_id'];
-               $ret[$count]['remote_object_name'] = $row['RackObject_name'];
-               // Save on displayedName() calls.
-               if (empty ($row['RackObject_name']) and !empty ($row['RemotePort_object_id']))
+               $row['type'] = $ptd[$row['type_id']];
+               $row['l2address'] = l2addressFromDatabase ($row['l2address']);
+               $row['remote_id'] = NULL;
+               $row['remote_name'] = NULL;
+               $row['remote_object_id'] = NULL;
+               $row['remote_object_name'] = NULL;
+               $ret[] = $row;
+       }
+       unset ($result);
+       // now find and decode remote ends for all locally terminated connections
+       foreach (array_keys ($ret) as $tmpkey)
+       {
+               $portid = $ret[$tmpkey]['id'];
+               $remote_id = NULL;
+               $query = "select porta, portb from Link where porta = {$portid} or portb = ${portid}";
+               $result = useSelectBlade ($query, __FUNCTION__);
+               if ($row = $result->fetch (PDO::FETCH_ASSOC))
                {
                {
-                       $oi = getObjectInfo ($row['RemotePort_object_id']);
-                       $ret[$count]['remote_object_name'] = displayedName ($oi);
+                       if ($portid != $row['porta'])
+                               $remote_id = $row['porta'];
+                       elseif ($portid != $row['portb'])
+                               $remote_id = $row['portb'];
+               }
+               unset ($result);
+               if ($remote_id) // there's a remote end here
+               {
+                       $query = "select Port.name as port_name, Port.type as port_type, object_id, RackObject.name as object_name " .
+                               "from Port left join RackObject on Port.object_id = RackObject.id " .
+                               "where Port.id = ${remote_id}";
+                       $result = useSelectBlade ($query, __FUNCTION__);
+                       if ($row = $result->fetch (PDO::FETCH_ASSOC))
+                       {
+                               $ret[$tmpkey]['remote_name'] = $row['port_name'];
+                               $ret[$tmpkey]['remote_object_id'] = $row['object_id'];
+                               $ret[$tmpkey]['remote_object_name'] = $row['object_name'];
+                       }
+                       $ret[$tmpkey]['remote_id'] = $remote_id;
+                       unset ($result);
+                       // only call displayedName() when necessary
+                       if (empty ($ret[$tmpkey]['remote_object_name']) and !empty ($ret[$tmpkey]['remote_object_id']))
+                       {
+                               $oi = getObjectInfo ($ret[$tmpkey]['remote_object_id']);
+                               $ret[$tmpkey]['remote_object_name'] = displayedName ($oi);
+                       }
                }
                }
-               $count++;
        }
        }
-       $result->closeCursor();
        return $ret;
 }
 
        return $ret;
 }