Skip to content
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

Closed
jab60 opened this issue Sep 10, 2023 · 4 comments
Closed

Viewing Data Query Cache can cause errors to be logged #5485

jab60 opened this issue Sep 10, 2023 · 4 comments
Labels
bug Undesired behaviour confirmed Bug is confirm by dev team resolved A fixed issue

Comments

@jab60
Copy link
Contributor

jab60 commented Sep 10, 2023

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:

  1. Go to System utilities>>View Data Query Cache>>

  2. 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.

@jab60 jab60 added bug Undesired behaviour unverified Some days we don't have a clue labels Sep 10, 2023
@TheWitness
Copy link
Member

I can not reproduce this in my development environment.

@TheWitness TheWitness added the unable to reproduce We don't have a clue label Sep 22, 2023
@jab60
Copy link
Contributor Author

jab60 commented Sep 22, 2023

Thanks for looking.
Not sure how to comment without closing?

Even if you can not reproduce the error the call to db_fetch_assoc_prepared requires a property item in the SQL statement which is the question mark character, for the dynamically replaceable variables.
In latest development branch the code line for this is now 655 and the filter clause is still missing in the SQL statement.

Please add
WHERE hsc.host_id = ?
at line 661

@TheWitness
Copy link
Member

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?

@TheWitness
Copy link
Member

I think our CI/CD would have caught this, but wget appears to have been crippled. Does not walk all paths like it used to.

TheWitness added a commit that referenced this issue Sep 23, 2023
Selecting a host device in System Utilities - View Data Query Cache raises error in cacti log
@TheWitness TheWitness added resolved A fixed issue confirmed Bug is confirm by dev team and removed unable to reproduce We don't have a clue unverified Some days we don't have a clue labels Sep 23, 2023
TheWitness added a commit that referenced this issue Sep 23, 2023
Selecting a host device in System Utilities - View Data Query Cache raises error in cacti log
@netniV netniV changed the title Selecting a host device in System Utilities - View Data Query Cache raises error in cacti log View Data Query Cache can cause errors to be logged Dec 16, 2023
@netniV netniV changed the title View Data Query Cache can cause errors to be logged Viewing Data Query Cache can cause errors to be logged Dec 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour confirmed Bug is confirm by dev team resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

2 participants