New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Viewing Data Query Cache can cause errors to be logged #5485
Comments
I can not reproduce this in my development environment. |
Thanks for looking. Even if you can not reproduce the error the call to Please add |
Okay, I guess if I had opened the Cacti log, it would have stuck out. Bad Larry! Fixing it now. Have you considered opening pull requests? |
I think our CI/CD would have caught this, but |
Selecting a host device in System Utilities - View Data Query Cache raises error in cacti log
Selecting a host device in System Utilities - View Data Query Cache raises error in cacti log
Describe the bug
An ERROR message in the cacti log file as below followed by SQL Backtrace message (Log level is LOW)
09-09-2023 21:11:27 - CMDPHP SQL Backtrace: (/utilities.php[51]:utilities_view_snmp_cache(), /utilities.php[1751]:db_fetch_assoc_prepared(), /lib/database.php[704]:db_execute_prepared())
09-09-2023 21:11:27 - CMDPHP ERROR: A DB Row Failed!, Error: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
To Reproduce
Steps to reproduce the behavior:
Go to System utilities>>View Data Query Cache>>
Select a device from the device drop down box
See error message in cacti log file
Expected behavior
No error should be logged
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information)
OS: Windows 10 22H2
Browser Chrome Version 116.0.5845.180 (Official Build) (64-bit)
Additional context
I reviewed the code in utilities.php at line 1751 as indicated in error message
It looks like the query command is missing its WHERE clause
After adding the clause error is no longer produced
Full query is now
$snmp_queries = db_fetch_assoc_prepared("SELECT DISTINCT sq.id, sq.name
FROM host_snmp_cache AS hsc
INNER JOIN snmp_query AS sq
ON hsc.snmp_query_id=sq.id
INNER JOIN host AS h
ON hsc.host_id=h.id
WHERE hsc.host_id = ?
ORDER by sq.name", array(get_request_var('host_id')));
I first noticed this in V1.2.24, but as 1.2.25 has just been released I upgraded and same error was present.
The text was updated successfully, but these errors were encountered: