Skip to content

Device Location drop down does not always populate correctly #5347

Closed
@adilinden

Description

@adilinden

Describe the bug

I am running Cacti 1.2.24.

The location table in the device form isn't populating with pre-defined values.

To Reproduce

Define different locations for different devices. Create a new device and the previously defined values won't show in the location drop down to select from.

Expected behavior

Have a choice of locations that have already been defined for other devices

Screenshots

image

Desktop (please complete the following information)

  • OS: Windows 11

  • Browser Edge

  • Version 113.0.1774.57 (Official build) (64-bit)

Smartphone (please complete the following information)

Additional context

I came across https://forums.cacti.net/viewtopic.php?t=60215 looking for a solution, it provided me some places to look for a solution. Here is what is have in the location column in my host table:

MariaDB [cacti]> SELECT location FROM host;
+---------------+
| location      |
+---------------+
|               |
| Core          |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Core          |
| Cellular Site |
| Cellular Site |
| Core          |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
| Cellular Site |
+---------------+
33 rows in set (0.000 sec)

Looking up the SQL query from the forum post it is in cacti/include/global_form.php around line 1199. It reads:

        'location' => array(
                'method' => 'drop_callback',
                'friendly_name' => __('Location'),
                'description' => __('The physical location of the Device.  This free form text can be a room, rack location, etc.'),
                'none_value' => __('None'),
                'sql' => 'SELECT DISTINCT location AS id, location AS name FROM host ORDER BY location',
                'action' => 'ajax_locations',
                'id' => '|arg1:location|',
                'value' => '|arg1:location|',
                ),

Running the SQL query on my Cacti install I get:

MariaDB [cacti]> SELECT DISTINCT location AS id, location AS name FROM host ORDER BY location;
+---------------+---------------+
| id            | name          |
+---------------+---------------+
|               |               |
| Cellular Site | Cellular Site |
| Core          | Core          |
+---------------+---------------+
3 rows in set (0.000 sec)

However the form in the UI with the modern theme does not populate with those values. Here is what I see when editing a device:

image

And this is what I see for a new device:

image

Looking at the HTML source of the page using the developer menu, I also only see the 'none' value predefine despite the SQL query returning two values in addition to the empty value.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourconfirmedBug is confirm by dev teamporting requiredRequires porting to developresolvedA fixed issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions