Cacti / plugin_reportit

ReportIt Plugin for Cacti
GNU General Public License v2.0
7 stars 9 forks source link

MAX_DISPLAY_PAGES constant error #2

Closed smiles1969 closed 6 years ago

smiles1969 commented 7 years ago

Apache error log:

[Fri Jun 30 12:59:55.977133 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP Notice: Constant MAX_DISPLAY_PAGES already defined in /var/www/html/cacti/plugins/reportit/lib_int/const_view.php on line 25, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:55.977201 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP Stack trace:, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:55.977229 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP 1. {main}() /var/www/html/cacti/plugins/reportit/cc_view.php:0, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:55.977269 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP 2. include_once() /var/www/html/cacti/plugins/reportit/cc_view.php:36, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:55.977279 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP 3. define() /var/www/html/cacti/plugins/reportit/lib_int/const_view.php:25, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:56.115634 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP Notice: Undefined variable: rows in /var/www/html/cacti/plugins/reportit/cc_view.php on line 244, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:56.115700 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP Stack trace:, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:56.115735 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP 1. {main}() /var/www/html/cacti/plugins/reportit/cc_view.php:0, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:56.115747 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP 2. standard() /var/www/html/cacti/plugins/reportit/cc_view.php:68, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:56.117793 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP Warning: Division by zero in /var/www/html/cacti/lib/html_utility.php on line 888, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:56.117838 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP Stack trace:, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:56.117878 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP 1. {main}() /var/www/html/cacti/plugins/reportit/cc_view.php:0, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:56.117897 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP 2. standard() /var/www/html/cacti/plugins/reportit/cc_view.php:68, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:56.117913 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP 3. html_nav_bar() /var/www/html/cacti/plugins/reportit/cc_view.php:244, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit [Fri Jun 30 12:59:56.117927 2017] [:error] [pid 28492] [client 192.168.11.140:63178] PHP 4. get_page_list() /var/www/html/cacti/lib/html.php:332, referer: http://192.168.11.15/cacti/plugins/reportit/cc_reports.php?action=edit

smiles1969 commented 7 years ago

This is breaking other plugins that reference the same constant.

To remove this error I have changed const_view.php line 25 to:

if(!defined('MAX_DISPLAY_PAGES')) define("MAX_DISPLAY_PAGES", 21);

not sure the intent on redefining a global constant, so I figured this was the safest workaround short of removing it completely.

netniV commented 6 years ago

I've added a fix for this by suppressing the message. This can occur if the const_items.php is included multiple times. A better fix would be to use an include_once() instead of standard include() for the file but this will work for now.