Alert Rules and Selecting Mail Transport Error

When selecting a Mail Transport for an alert rule, I can add a single Mail Transport and then Save.

When I go back to any rule and try and change the Mail Transport, I delete the old one, select the new one. Only the new one is visible. Click Save.

When I go back to that same alert rule, the old and the new mail transports are both visible.

I can repeat the process and add a third mail transport and then when I go back, all three are there. etc. etc.

I took a look at the alert_transport_map in the DB, and it just appends a new ID with the rule_id so it just keeps appending rather then pruning/modifying the table.

====================================

Component Version
LibreNMS 1.42.01-58-g29d51f4
DB Schema 259
PHP 7.2.4
MySQL 5.5.56-MariaDB
RRDTool 1.4.8
SNMP NET-SNMP 5.7.2

====================================

[OK] Composer Version: 1.7.2
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct

MariaDB [librenms]> select * from alert_transport_map;
±—±--------±----------------------±------------+
| id | rule_id | transport_or_group_id | target_type |
±—±--------±----------------------±------------+
| 1 | 16 | 2 | single |
| 2 | 1 | 1 | single |
| 3 | 6 | 3 | single |
| 4 | 5 | 3 | single |
| 5 | 7 | 4 | single |
| 6 | 8 | 4 | single |
| 7 | 6 | 5 | single |
| 8 | 6 | 2 | single |
| 9 | 13 | 3 | single |
| 10 | 13 | 5 | single |
±—±--------±----------------------±------------+

I added

set_debug(true);

in ajax_form.php and opened up the edit for the rule, deleted two mail transports, then clicked saved.

Pastebin:

https://pastebin.com/411xWqPq

Please, test https://github.com/librenms/librenms/pull/9075