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

Under CentOS packages, upgrade_database.php script uses incorrect location for DB upgrade scripts #2938

Closed
netniV opened this issue Sep 12, 2019 · 4 comments
Labels
3rd Party Bug 3rd party bug bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@netniV
Copy link
Member

netniV commented Sep 12, 2019

Describe the bug
When using the upgrade_database.php script, a single line may be seen showing that an upgrade of the database from version x.x.x is ,underway. No further updates are seen and the database version is updated in the database to y.y.y (the updated version).

However, aside from the database version, zero updates are performed. This may be related to #2780 when a change was made to set the database version at the end of the script regardless of whether an update has been performed.

It turns out that the reason for this failure to update the database was highlighted in #2931, specifically this post where the include locations were diagnosed as being under the cli folder, not the cacti web root.

Expected behavior
Use $config['base_path'] rather than a relative include due to packaging method.

Additional context
Tagging @mortenstevens here so that he is aware of the situation and will be notified when a forth coming patch is applied to 1.2.7 correcting the situation. This may also apply to ubuntu (@paulgevers) but that hasn't been tested at this time.

@netniV netniV added 3rd Party Bug 3rd party bug bug Undesired behaviour labels Sep 12, 2019
@netniV netniV added this to the v1.2.7 milestone Sep 12, 2019
@netniV
Copy link
Member Author

netniV commented Sep 12, 2019

For reference, any upgrade that is applied will list the current DB version plus the new version being upgraded to. The following is the patch I will apply tomorrow that should correct things:

diff --git a/cli/upgrade_database.php b/cli/upgrade_database2.php
index be021dc..a95723d 100644
--- a/cli/upgrade_database.php
+++ b/cli/upgrade_database2.php
@@ -115,7 +115,7 @@ foreach ($cacti_version_codes as $cacti_upgrade_version => $hash_code)  {
        }
 
        // construct version upgrade include path
-       $upgrade_file = dirname(__FILE__) . '/../install/upgrades/' . str_replace('.', '_', $cacti_upgrade_version)
+       $upgrade_file = $config['base_path'] . '/install/upgrades/' . str_replace('.', '_', $cacti_upgrade_version)
        $upgrade_function = 'upgrade_to_' . str_replace('.', '_', $cacti_upgrade_version);
 
        // check for upgrade version file, then include, check for function and execute

@mortenstevens
Copy link
Contributor

@netniV
Thank you for the report. But I'm not able to reproduce this? I have upgraded some cacti installations (RHEL 8, Fedora 30, Fedora 31) from 1.2.5 to 1.2.6 without any issue.

@netniV
Copy link
Member Author

netniV commented Sep 15, 2019

When the upgrade runs. Do you see the individual upgrade versions being reported ? Or just the one line ?

@netniV
Copy link
Member Author

netniV commented Sep 15, 2019

This has been corrected in 21f0446

@netniV netniV closed this as completed Sep 15, 2019
@netniV netniV added the resolved A fixed issue label Sep 15, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3rd Party Bug 3rd party bug bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

2 participants