fix: display linked socket in network ports list - #25223
Open
iPaulis wants to merge 1 commit into
Open
Conversation
The socket search option (id 9) was gated behind a check on a sockets_id field that does not exist on the networkports table, so the column was never offered in the list/display preferences. Always provide the option with a child join on glpi_sockets.networkports_id and render the linked socket in the ports table. Fixes glpi-project#11258
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11258
Problem
Since GLPI 10, the Network sockets column no longer appears in the network ports list and in the tab shown on asset pages (Computer, NetworkEquipment, Phone, ...). In 9.5 the socket of each port was visible in this list; from 10.0 onward the column vanished entirely even though ports can still be linked to a socket (the socket model moved to
glpi_sockets, linked throughglpi_sockets.networkports_id). I can reproduce it on a current 11.0.x instance: a port that has a socket linked shows nothing about it in the ports table, and the socket option is not even offered in the "Select default items to show" display preferences.This is the regression reported in #11258 (closed without a fix).
Root cause
In
NetworkPort::rawSearchOptions()the socket search option (id 9) is declared behind this guard:isField()checks the columns ofglpi_networkports, andglpi_networkportshas never had asockets_idcolumn. In 9.5 the equivalent option was guarded bynetpoints_idand the socket lived on the main table; in 10 the data model moved the link toglpi_sockets.networkports_id, but the guard was ported over as-is and always evaluates to false. The option therefore never makes it into the list, and even when the port does have a socket attached nothing is rendered.Change
src/NetworkPort.php:glpi_sockets.networkports_id(same join pattern the instantiation search options already use for sockets).case 9inNetworkPort::showPort()so the linked socket name is rendered in the table when the column is selected. Ports without a linked socket simply show an empty cell.tests/functional/NetworkPortTest.php:testShowForItemDisplaysLinkedSocket: creates a computer, an Ethernet port, a socket, links the socket to the port, enables display preference 9, and checks that both the column header and the socket value are rendered byshowForItem()/displayTabContentForItem().Verification
php -lclean on both files.Network socketcolumn is available in the display preferences picker, appears in the ports tab, and shows the linked socket. Verified through bothshowForItem()anddisplayTabContentForItem().