Skip to content

Whilst upgrading, errors in upgrade scripts prevent properly execution #4284

@mchorsley

Description

@mchorsley

Describe the bug

When upgrading database to 1.2.17, upgrade script 1_2_17.php fails due to 3 parameters passed to array_key_exists function.

To Reproduce

$ php cli/upgrade_database.php --debug

+++PHP Fatal error:  Uncaught ArgumentCountError: array_key_exists() expects exactly 2 arguments, 3 given in /usr/share/cacti/install/upgrades/1_2_17.php:176
Stack trace:
#0 /usr/share/cacti/install/upgrades/1_2_17.php(176): array_key_exists('aggregate_graph...', Array, true)
#1 /usr/share/cacti/install/upgrades/1_2_17.php(54): database_fix_mediumint_columns()
#2 /var/lib/cacti/cli/upgrade_database.php(129): upgrade_to_1_2_17()
#3 {main}
  thrown in /usr/share/cacti/install/upgrades/1_2_17.php on line 176

Expected behavior

Database upgrade completes without error.

Fix

Update: install/upgrades/1_2_17.php:176
From:
if (!array_key_exists($table, $tables, true)) {
To:
if (!array_key_exists($table, $tables)) {

Update: install/upgrades/1_2_17.php:183
From:
if (array_key_exists($field, $known_columns, true)) {
To:
if (array_key_exists($field, $known_columns)) {

Additional Context

-PHP Version: 8.0.6
-OS: CentOS 8.3.2011

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourinstallerInstallation issueresolvedA fixed issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions