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

Undefined variable errors may occur when creating a new datasource #3903

Closed
paulgevers opened this issue Nov 5, 2020 · 8 comments
Closed
Assignees
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@paulgevers
Copy link
Contributor

Describe the bug

As you probably remember, I am running a web crawl in the Debian test framework for the Cacti package. I uploaded Cacti to Debian unstable yesterday, but the test framework shows regressions for all architectures the test is run on: https://qa.debian.org/excuses.php?package=cacti

To Reproduce

Steps to reproduce the behavior:

  1. Install a fresh cacti instance

  2. Go to 'http://localhost/cacti/data_queries.php?action=edit'

  3. Look into the cacti.log file

  4. See

2020/11/04 21:19:19 - ERROR PHP NOTICE: Undefined variable: snmp_query in file: /usr/share/cacti/site/data_queries.php  on line: 1194
2020/11/04 21:19:19 - CMDPHP PHP ERROR NOTICE Backtrace:  (/data_queries.php[100]:data_query_edit(), /data_queries.php[1194]:CactiErrorHandler())
2020/11/04 21:19:19 - ERROR PHP NOTICE: Trying to access array offset on value of type null in file: /usr/share/cacti/site/data_queries.php  on line: 1194
2020/11/04 21:19:19 - CMDPHP PHP ERROR NOTICE Backtrace:  (/data_queries.php[100]:data_query_edit(), /data_queries.php[1194]:CactiErrorHandler())
2020/11/04 21:19:19 - ERROR PHP NOTICE: Undefined variable: snmp_query_graph in file: /usr/share/cacti/site/data_queries.php  on line: 1195
2020/11/04 21:19:19 - CMDPHP PHP ERROR NOTICE Backtrace:  (/data_queries.php[100]:data_query_edit(), /data_queries.php[1195]:CactiErrorHandler())
2020/11/04 21:19:19 - ERROR PHP NOTICE: Trying to access array offset on value of type null in file: /usr/share/cacti/site/data_queries.php  on line: 1195
2020/11/04 21:19:19 - CMDPHP PHP ERROR NOTICE Backtrace:  (/data_queries.php[100]:data_query_edit(), /data_queries.php[1195]:CactiErrorHandler())
2020/11/04 21:19:19 - ERROR PHP NOTICE: Undefined variable: snmp_query in file: /usr/share/cacti/site/data_queries.php  on line: 1198
2020/11/04 21:19:19 - CMDPHP PHP ERROR NOTICE Backtrace:  (/data_queries.php[100]:data_query_edit(), /data_queries.php[1198]:CactiErrorHandler())
2020/11/04 21:19:19 - ERROR PHP NOTICE: Trying to access array offset on value of type null in file: /usr/share/cacti/site/data_queries.php  on line: 1198
2020/11/04 21:19:19 - CMDPHP PHP ERROR NOTICE Backtrace:  (/data_queries.php[100]:data_query_edit(), /data_queries.php[1198]:CactiErrorHandler())

Expected behavior

No new errors with respect to previous Cacti versions when recursively crawling the full Cacti website.

Desktop (please complete the following information)

  • OS: Linux

  • Browser: wget and Firefox-esr

Additional context

https://ci.debian.net/data/autopkgtest/testing/amd64/c/cacti/7954737/log.gz

@paulgevers paulgevers added bug Undesired behaviour unverified Some days we don't have a clue labels Nov 5, 2020
@netniV
Copy link
Member

netniV commented Nov 5, 2020

Just to confirm, that is definitely against the 1.2.x branch correct ?

@netniV netniV self-assigned this Nov 5, 2020
@paulgevers
Copy link
Contributor Author

paulgevers commented Nov 5, 2020

This is the released 1.2.15 tar ball.

@netniV
Copy link
Member

netniV commented Nov 5, 2020

OK, thanks I'll have a look shortly.

@netniV
Copy link
Member

netniV commented Nov 5, 2020

So this appears to be when creating a new data query, and it hasn't been saved yet. My simple fix would be to add

$snmp_query = array('id' => 0);

in the first if statement's else section but I am not sure yet if that would cause another issue.

@netniV
Copy link
Member

netniV commented Nov 5, 2020

diff --git a/data_queries.php b/data_queries.php
index 9d04e09eb..f584d5af5 100644
--- a/data_queries.php
+++ b/data_queries.php
@@ -1074,6 +1074,7 @@ function data_query_edit() {
                $header_label = __esc('Data Queries [edit: %s]', $snmp_query['name']);
        } else {
                $header_label = __('Data Queries [new]');
+               $snmp_query = array('id' => 0);
        }

        form_start('data_queries.php', 'data_queries');

This would be the diff, but I'm not sure it's the final solution yet

@TheWitness TheWitness changed the title [1.2.15] Debian test shows new PHP errors in log Debian test shows new PHP errors in log Nov 6, 2020
TheWitness added a commit that referenced this issue Nov 6, 2020
Debian test shows new PHP errors in log
@TheWitness
Copy link
Member

I've reviewed the bug and have resolved it. Thanks for being there @paulgevers!

@TheWitness TheWitness added resolved A fixed issue and removed unverified Some days we don't have a clue labels Nov 6, 2020
@paulgevers
Copy link
Contributor Author

@TheWitness thanks. Confirming the fix also fixes the issue in the Debian package.

@TheWitness
Copy link
Member

Great! Thanks for the heads up @paulgevers.

@netniV netniV changed the title Debian test shows new PHP errors in log Undefined variables errors may occur when creating a new datasource Nov 6, 2020
@netniV netniV changed the title Undefined variables errors may occur when creating a new datasource Undefined variable errors may occur when creating a new datasource Nov 6, 2020
@TheWitness TheWitness added this to the v1.2.16 milestone Nov 10, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Feb 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

3 participants