Skip to content

Conversation

@trasher
Copy link
Contributor

@trasher trasher commented Oct 15, 2025

Also fix Twig display
closes #21488

public static $itemtype = 'NetworkPort';
public static $items_id = 'networkports_id';
public $dohistory = false;
public static $mustBeAttached = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that a log can be attached to no NetworkPort. What is the use case ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no use case. I do not understand why existing this change is needed. CommonDBChild prevents adding log.

Copy link
Member

@cedric-anne cedric-anne Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably means that a add or update operation does correctly pass the items_id value. If this value does not correspond to a valid NetworkPort ID, then it will prevent it to be added.

Change proposed in #21524 may help. For instance, I had not yet tried to check if it is a bug or an expected message, but adding this message makes the following test fail:

1) tests\units\Glpi\Inventory\Asset\NetworkPortTest::testNetworkEquipmentsConnectionsConverted
Some messages has not been handled in tests\units\Glpi\Inventory\Asset\NetworkPortTest::GLPITestCase::tearDown:
Array
(
    [1] => Array
        (
            [0] => Parent item is invalid.
            [1] => Parent item is invalid.
        )

)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the $items_id property wrong? It is set as "networkports_id" but it should be linked by "networkports_id_source" and "networkports_id_destination".

NetworkPort_NetworkPort::storeConnectionLog tries adding an entry with this input:

$input = [
    'networkports_id_source'      => $netports_id,
    'networkports_id_destination' => $opposite_port,
    'connected'                   => ($action === 'add'),
    'date'                        => $_SESSION['glpi_currenttime'],
];

May be why there is a FIXME to change it to extend CommonDBRelation instead of CommonDBChild.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seem the incorrect field name is the reason of the initial issue, yes.
Changing class to a CommonDBRelation is probably out of the scope of a fix - I'm not sure we should do that kind of change in a bugfixes release.

About the remaining fails, I guess deletion should just be handled differently - the fix just reveals something that does not work.

@cedric-anne cedric-anne added this to the 11.0.2 milestone Oct 15, 2025
@trasher
Copy link
Contributor Author

trasher commented Oct 15, 2025

Tests are broken, I do not yet know why. Proposed fix is probably incorrect, I put back as draft.

@trasher trasher marked this pull request as draft October 15, 2025 10:29
@cconard96
Copy link
Contributor

Tests are broken, I do not yet know why.

The JS test for the dashboard joke failed :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port history is empty all the time

3 participants