Fixed Trac#465: incorrect logic when resetting the 'ConnectedToInterface'

SVN:trunk[1529]
This commit is contained in:
Denis Flaven
2011-08-29 11:55:13 +00:00
parent 5d9d44dc5e
commit 6be497ee7d

View File

@@ -1116,13 +1116,29 @@ class NetworkInterface extends ConnectableCI
protected function UpdateConnectedInterface()
{
$iPrevTargetIf = $this->m_aOrigValues['connected_if']; // The interface this interface was connected to
if ($iPrevTargetIf != 0)
{
// The interface was previosuly connected to another interface. Make sure that we reset this 'previously connected interface'
$oPrevConnectedIf = MetaModel::GetObject('NetworkInterface', $iPrevTargetIf, false);
if (!is_null($oPrevConnectedIf))
{
$oPrevConnectedIf->Set('connected_if', 0);
// Need to backup the current change, because it is reset when DBUpdateTracked is complete
$oCurrChange = self::$m_oCurrChange;
$oPrevConnectedIf->DBUpdateTracked($oCurrChange);
self::$m_oCurrChange = $oCurrChange;
}
}
$oConnIf = MetaModel::GetObject('NetworkInterface', $this->Get('connected_if'), false /* no exception if not found */);
if (!is_null($oConnIf))
{
$sLink = $this->Get('link_type');
$sConnLink = ($sLink == 'uplink') ? 'downlink' : 'uplink';
if (($oConnIf->Get('connected_if') != $this->GetKey()) || ($sConnLink != $oConnIf->Get('link_type')))
if (($oConnIf->Get('connected_if') != $this->GetKey()) || ($sConnLink != $oConnIf->Get('link_type')))
{
// Something has to be changed on the connected interface...
if ($oConnIf->Get('connected_if') != $this->GetKey())