xmacan / plugin_snver

Small Cacti plugin - try find serial numbers, versions and important information about devices
GNU Lesser General Public License v2.1
2 stars 0 forks source link

PHP ERROR #3

Closed Fabrice35 closed 2 years ago

Fabrice35 commented 2 years ago

Hi,

Thanks for this plugin, it is useful. It's ok in the equipment menu, but the "Snver" tab crashes: Fatal error: Call to undefined function array_column() in /usr/share/cacti-1.2.21/plugins/snver/functions.php on line 42

The plugin is then automatically disabled: 2022-07-06 10:51:49 - PHP ERROR ERROR in Plugin 'snver': Call to undefined function array_column() in file: /usr/share/cacti-1.2.21/plugins/snver/functions.php on line: 42 2022-07-06 10:51:49 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler()) 2022-07-06 10:51:49 - CMDPHP ERRORS DETECTED - DISABLING PLUGIN 'snver'

Do you have any idea of the problem?

cacti version: 1.2.21 BB

Fabrice35 commented 2 years ago

I think I found the answer by myself ;)

# php --version
PHP 5.4.16 (cli) (built: Apr 1 2020 04:07:17) 

https://www.tutorialspoint.com/php/php_function_array_column.htm This function was first introduced in PHP 5.5.0.

BB

xmacan commented 2 years ago

It is easy fix, but I don't want to do this. Cacti requires PHP 7.2.5+ now. Your php version is unsupported more than 6 years. We must move forward, not backward, please update your PHP.

Easy fix for you - you can add this code to the beginning of file functions.php: if (!function_exists('array_column')) { function array_column($array,$column_name) { return array_map(function($element) use($column_name) { return $element[$column_name]; }, $array); } }

Fabrice35 commented 2 years ago

ok, thanks So the requirements are not up to date... https://docs.cacti.net/Requirements.md

BB

xmacan commented 2 years ago

thanks for the heads up. We will check it

xmacan commented 2 years ago

hmm, php 5.4 is still supported for official releases. Reopening, I will prepare fix

xmacan commented 2 years ago

Fixed