Skip to content

Commit

Permalink
Fixed three error for PHP 8 when execute cli/upgrade_database.php (#5012
Browse files Browse the repository at this point in the history
)

* Fixed: get_rrdtool_version report str_replace error if rrdtool_version does not exist
Fixed: move global static $phperrors before other error-able function call
Fixed: file_exists report error if path_spine is not configured

* Fix PHP5.4 Error

Co-authored-by: TheWitness <thewitness@cacti.net>
  • Loading branch information
ddb4github and TheWitness authored Nov 20, 2022
1 parent 10895f4 commit 546d002
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
40 changes: 20 additions & 20 deletions include/global_arrays.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,25 @@
'ROLL'
);

$phperrors = array (
E_ERROR => 'ERROR',
E_WARNING => 'WARNING',
E_PARSE => 'PARSE',
E_NOTICE => 'NOTICE',
E_CORE_ERROR => 'CORE_ERROR',
E_CORE_WARNING => 'CORE_WARNING',
E_COMPILE_ERROR => 'COMPILE_ERROR',
E_COMPILE_WARNING => 'COMPILE_WARNING',
E_USER_ERROR => 'USER_ERROR',
E_USER_WARNING => 'USER_WARNING',
E_USER_NOTICE => 'USER_NOTICE',
E_STRICT => 'STRICT',
E_RECOVERABLE_ERROR => 'RECOVERABLE_ERROR',
E_DEPRECATED => 'DEPRECATED',
E_USER_DEPRECATED => 'USER_DEPRECATED',
E_ALL => 'ALL'
);

if (cacti_version_compare(get_rrdtool_version(), '1.8.0', '>=')) {
$cdef_functions[] = 'ROUND';
}
Expand Down Expand Up @@ -679,7 +698,7 @@
2 => 'spine'
);

if (!file_exists(read_config_option('path_spine')) || !is_executable(read_config_option('path_spine'))) {
if (read_config_option('path_spine') != '' && (!file_exists(read_config_option('path_spine')) || !is_executable(read_config_option('path_spine')))) {
unset($poller_options[2]);
}

Expand Down Expand Up @@ -1953,25 +1972,6 @@
3 => __('[Skipped]'),
);

$phperrors = array (
E_ERROR => 'ERROR',
E_WARNING => 'WARNING',
E_PARSE => 'PARSE',
E_NOTICE => 'NOTICE',
E_CORE_ERROR => 'CORE_ERROR',
E_CORE_WARNING => 'CORE_WARNING',
E_COMPILE_ERROR => 'COMPILE_ERROR',
E_COMPILE_WARNING => 'COMPILE_WARNING',
E_USER_ERROR => 'USER_ERROR',
E_USER_WARNING => 'USER_WARNING',
E_USER_NOTICE => 'USER_NOTICE',
E_STRICT => 'STRICT',
E_RECOVERABLE_ERROR => 'RECOVERABLE_ERROR',
E_DEPRECATED => 'DEPRECATED',
E_USER_DEPRECATED => 'USER_DEPRECATED',
E_ALL => 'ALL'
);

$navigation = array(
'auth_profile.php:' => array(
'title' => __('User Profile (Edit)'),
Expand Down
2 changes: 1 addition & 1 deletion lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6438,7 +6438,7 @@ function get_rrdtool_version() {
static $version = '';

if ($version == '') {
$version = str_replace('rrd-', '', str_replace('.x', '.0', read_config_option('rrdtool_version')));
$version = str_replace('rrd-', '', str_replace('.x', '.0', read_config_option('rrdtool_version') ?: read_default_config_option('rrdtool_version') ?: '1.4.0' ));
}

return $version;
Expand Down

0 comments on commit 546d002

Please sign in to comment.