Description
Describe the bug
When editing properties of remote pollers the query for detecting duplicate poller hostnames and database hostnames is missing critical brackets
To Reproduce
Deploy Cacti with a remote poller, try to edit any property of that remote poller. I receive an error to "Please enter a non-duplicate hostname" as well as "Please enter a non-duplicate database hostname".
Expected behavior
The remote poller gets renamed.
Initial analysis
The query building that starts here:
https://github.com/Cacti/cacti/blob/1.2.x/pollers.php#L386
Ends with a query being written like this:
SELECT id FROM poller WHERE id != 2 AND dbhost IN ('192.168.1.2') OR ((dbhost = 'cacti-poller-01' OR dbhost LIKE 'cacti-poller-01%' OR dbhost = 'cacti-poller-01.example.com'))
When the poller already exists in the database with the id of 2 it is returned in this query because of the 'OR' expression not being bracketed together with the dbhost part of the clause.
I believe the query should be written as follows:
SELECT id FROM poller WHERE id != 2 AND (dbhost IN ('192.168.1.2') OR ((dbhost = 'cacti-poller-01' OR dbhost LIKE 'cacti-poller-01%' OR dbhost = 'cacti-poller-01.example.com')))
Note the extra brackets that begin after the 'AND'