Cacti / cacti

Cacti ™
http://www.cacti.net
GNU General Public License v2.0
1.63k stars 403 forks source link

Sorting plugins by version can lead to unexpected ordering #2905

Closed ddb4github closed 5 years ago

ddb4github commented 5 years ago

Describe the bug Console --> Plugins sort by version fail if version is two digit number: 1.5.1 < 10.2 < 2.3

To Reproduce Steps to reproduce the behavior:

  1. Change maint plugin version from 1.2 to 10.2
  2. Access Console --> Plugins
  3. Order by version column
  4. See error

Expected behavior 10.2 should bigger than 4.4

Screenshots image

netniV commented 5 years ago

That is because the version is stored as a text field within the database. There is a calculation that gets used in 1.3 to have better version comparision. We could potentially store that calculated result to ensure fields are sorted as expected but that would be a full enhancement rather than a bug fix.

ddb4github commented 5 years ago

Just test, 'ORDER BY INET_ATON(version)' is workable

mysql>SELECT id, directory, name, version FROM plugin_config ORDER BY INET_ATON(version);
+----+---------------+--------------------------------+---------+
| id | directory     | name                           | version |
+----+---------------+--------------------------------+---------+
| 13 | webseer       | Web Service Monitor            | 0.3.0.0 |
|  2 | audit         | Audit Plugin for Cacti         | 1.0     |
| 42 | wmi           | WMI Information Collector      | 1.0     |
| 35 | reportit      | Reporting tool for Cacti       | 1.1.3   |
|  6 | thold         | Thresholds                     | 1.3.2   |
|  5 | gexport       | Graph Export Package for Cacti | 1.4.2   |
| 12 | routerconfigs | Router Configs                 | 1.5.1   |
| 10 | mikrotik      | MikroTik Switch Tool           | 2.3     |
| 38 | syslog        | Syslog Monitoring              | 2.4     |
| 14 | monitor       | Device Monitoring              | 2.3.6   |
|  4 | flowview      | FlowView                       | 3.0.0   |
|  8 | hmib          | Host MIB Tool                  | 3.1     |
|  1 | cycle         | Cycle Graphs                   | 4.2     |
|  3 | mactrack      | Device Tracking                | 4.4     |
| 43 | maint         | Maintenance Scheduler          | 10.2    |
+----+---------------+--------------------------------+---------+
TheWitness commented 5 years ago

Well Jing, you've been playing. ;)

netniV commented 5 years ago

I like that! A new one to me but it appears to work, presumably because it's converting it like an IP address.

netniV commented 5 years ago

This should now be resolved, thanks @ddb4github