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

Add support for PHP 8 #4475

Closed
paulgevers opened this issue Nov 25, 2021 · 12 comments
Closed

Add support for PHP 8 #4475

paulgevers opened this issue Nov 25, 2021 · 12 comments
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@paulgevers
Copy link
Contributor

Describe the bug

Debian is in the process of moving to PHP8.1 (it's currently available in experimental). The test suite of Cacti in Debian is failing because a lot of warning show up in the log.

To Reproduce

Steps to reproduce the behavior:

  1. Replace your php instance with php8.1. E.g. in a Debian unstable environment, install the following packages from experimental: php-cli, php-gd, php-json, php-gmp, php-ldap, php-mbstring, php-mysql, php-phpmyadmin-motranslator, php-phpseclib, php-snmp, php-twig, php-xml,

  2. Run tests/tools/check_all_pages.sh and tests/tools/check_cli_version.sh

  3. See how they fail

  4. See error (at the bottom)

Desktop (please complete the following information)

  • OS: Debian

  • Browser wget

  • Version 1.21.2

Errors

Original log: https://ci.debian.net/data/autopkgtest/unstable/amd64/c/cacti/16973612/log.gz

Filtered, sorted and unique:

CMDPHP PHP ERROR Backtrace:  (/automation_networks.php[52]:network_edit(), /automation_networks.php[478]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/automation_networks.php[58]:networks(), /automation_networks.php[1145]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/automation_networks.php[58]:networks(), /automation_networks.php[1148]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/automation_networks.php[58]:networks(), /automation_networks.php[1149]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (CactiShutdownHandler())
CMDPHP PHP ERROR Backtrace:  (/cdef.php[95]:cdef(), /cdef.php[912]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/cdef.php[95]:cdef(), /cdef.php[913]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/color.php[69]:color(), /color.php[729]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/color.php[69]:color(), /color.php[730]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/color_templates.php[53]:aggregate_color_template(), /color_templates.php[660]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/color_templates.php[53]:aggregate_color_template(), /color_templates.php[661]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/data_input.php[74]:data(), /data_input.php[976]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/data_input.php[74]:data(), /data_input.php[977]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/data_queries.php[100]:data_query_edit(), /data_queries.php[1155]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/data_queries.php[107]:data_query(), /data_queries.php[1436]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/data_queries.php[107]:data_query(), /data_queries.php[1437]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/data_source_profiles.php[99]:profile(), /data_source_profiles.php[1088]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/data_source_profiles.php[99]:profile(), /data_source_profiles.php[1092]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/data_source_profiles.php[99]:profile(), /data_source_profiles.php[1094]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/data_templates.php[74]:template(), /data_templates.php[1153]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/gprint_presets.php[53]:gprint_presets(), /gprint_presets.php[438]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/gprint_presets.php[53]:gprint_presets(), /gprint_presets.php[439]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/graph_templates.php[77]:template(), /graph_templates.php[855]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/host_templates.php[92]:template(), /host_templates.php[876]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/pollers.php[261]:pollers(), /pollers.php[1027]:round(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/pollers.php[261]:pollers(), /pollers.php[1043]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/pollers.php[261]:pollers(), /pollers.php[1044]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/pollers.php[261]:pollers(), /pollers.php[1045]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/pollers.php[261]:pollers(), /pollers.php[1046]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/sites.php[215]:sites(), /sites.php[587]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/user_admin.php[72]:user(), /user_admin.php[2349]:CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/utilities.php[80]:utilities_view_tech(), /utilities.php[316]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/utilities.php[80]:utilities_view_tech(), /utilities.php[321]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/utilities.php[80]:utilities_view_tech(), /utilities.php[573]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/utilities.php[80]:utilities_view_tech(), /utilities.php[594]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/utilities.php[80]:utilities_view_tech(), /utilities.php[647]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/utilities.php[80]:utilities_view_tech(), /utilities.php[648]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/utilities.php[80]:utilities_view_tech(), /utilities.php[649]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/utilities.php[80]:utilities_view_tech(), /utilities.php[650]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/vdef.php[87]:vdef(), /vdef.php[906]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
CMDPHP PHP ERROR Backtrace:  (/vdef.php[87]:vdef(), /vdef.php[907]:number_format_i18n(), /include/global_languages.php[717]:number_format(), CactiErrorHandler())
  done.
ERROR PHP DEPRECATED: Function strftime() is deprecated in file: /usr/share/cacti/site/user_admin.php  on line: 2349
ERROR PHP DEPRECATED: number_format(): Passing null to parameter #1 ($num) of type float is deprecated in file: /usr/share/cacti/site/include/global_languages.php  on line: 717
ERROR PHP DEPRECATED: number_format(): Passing null to parameter #2 ($decimals) of type int is deprecated in file: /usr/share/cacti/site/include/global_languages.php  on line: 717
ERROR PHP DEPRECATED: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in file: /usr/share/cacti/site/pollers.php  on line: 1027
ERROR PHP ERROR: Uncaught DivisionByZeroError: Division by zero in /usr/share/cacti/site/utilities.php:2229 Stack trace: #0 /usr/share/cacti/site/utilities.php(84): boost_display_run_status() #1 {main} thrown in file: /usr/share/cacti/site/utilities.php on line: 2229
ERROR PHP WARNING: fopen(/usr/share/cacti/site/include/vendor/csrf/csrf-secret.php): Failed to open stream: Permission denied in file: /usr/share/cacti/site/include/vendor/csrf/csrf-magic.php  on line: 490
PHP Deprecated:  str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /usr/share/cacti/site/include/global_languages.php on line 334
PHP Deprecated:  substr(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/share/cacti/site/include/global_languages.php on line 338
PHP Warning:  Trying to access array offset on value of type null in /usr/share/cacti/site/lib/functions.php on line 5410
@paulgevers paulgevers added bug Undesired behaviour unverified Some days we don't have a clue labels Nov 25, 2021
@netniV
Copy link
Member

netniV commented Nov 25, 2021

Thanks Paul, I think we should probably split each ERROR PHP line out (keeping the two number_formats together) as each has their own issue. One of the issues I think is already resolved for utilities.php as that was the issue you previously raised #4472

@paulgevers
Copy link
Contributor Author

One of the issues I think is already resolved for utilities.php as that was the issue you previously raised #4472

Yes, sorry about that. I only noticed after posting.

@TheWitness
Copy link
Member

TheWitness commented Nov 27, 2021

Wow, strftime() deprecated? Amazing

TheWitness added a commit that referenced this issue Nov 30, 2021
Running cacti with PHP8.1 shows lots of warnings in the log
@TheWitness
Copy link
Member

@paulgevers, please test again. Most should be resolved, but not sure all have. Let us know.

@TheWitness TheWitness removed the unverified Some days we don't have a clue label Nov 30, 2021
@TheWitness TheWitness added this to the v1.2.20 milestone Nov 30, 2021
@paulgevers
Copy link
Contributor Author

@TheWitness, I think it's clean now for the only one left:

2021-12-03 21:17:43 - ERROR PHP WARNING: fopen(/usr/share/cacti/site/include/vendor/csrf/csrf-secret.php): Failed to open stream: Permission denied in file: /usr/share/cacti/site/include/vendor/csrf/csrf-magic.php  on line: 490

I wouldn't be surprised if this is totally related to the Debian packaging and I vaguely recall from some earlier issue that I had still work to do. Can you teach me what's wrong here and how bad it is? /usr/share/cacti/site/include/vendor/csrf/csrf-secret.php doesn't exist. Judging from the name is should contain the csrf-secret. If that's true then the file would become a symlink to somewhere under /etc/cacti. Would that be OK and solve the problem? Would it be OK if the file was read only (for the http daemon)?

@netniV
Copy link
Member

netniV commented Dec 4, 2021

Yes, Paul that would. It's a value that is randomly generated to act as the base token for CSRF processing. Once the file is created and populated, it should not be written to again.

@paulgevers
Copy link
Contributor Author

paulgevers commented Dec 4, 2021

So, ignoring that Debian specific thing I get this in my log:

ERROR: Fail - Unexpected output in /usr/share/cacti/site/log/cacti.log:
2021-12-04 18:28:41 - ERROR PHP DEPRECATED: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in file: /usr/share/cacti/site/pollers.php  on line: 1027
2021-12-04 18:28:41 - CMDPHP PHP ERROR Backtrace:  (/pollers.php[261]:pollers(), /pollers.php[1027]:round(), CactiErrorHandler())

Note, only applied the patch from 86e0bce and 40ef3f5.

netniV added a commit that referenced this issue Dec 6, 2021
@netniV
Copy link
Member

netniV commented Dec 6, 2021

You can change the location of the CSRF secret too if I remember correctly. It would seem that pollers.php was missed and I have no corrected that.

@TheWitness
Copy link
Member

TheWitness commented Dec 7, 2021

I was going to comment on the relocation. Thought the path was in config.php. my guess for Debian would be /etc/cacti/csrf-secret.php

@TheWitness
Copy link
Member

TheWitness commented Dec 10, 2021

From config.php.dist

/*
 * Optional parameter to define the path of the csrf_secret.php path.  This
 * variable is for packagers who wish to specify an alternate location of
 * the CRSF secret file.
 */

//$path_csrf_secret = '/usr/share/cacti/resource/csrf-secret.php';

@TheWitness TheWitness added the resolved A fixed issue label Dec 10, 2021
@TheWitness
Copy link
Member

Okay @paulgevers, if you are satisfied, please close.

@paulgevers
Copy link
Contributor Author

Seems fine.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2022
@netniV netniV changed the title Running cacti with PHP8.1 shows lots of warnings in the log Add support for PHP 8 Apr 3, 2022
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