Database Error using the UpgradeMODX Package

Running into difficulties using this package. On MODx 2.7.1 trying to update to 2.8.0 as suggested, have PHP 7.4 installed.

Updated all my packages, logged out all users
Logged back in
Used the Dashboard widget to install v 2.8
get “Database connection failed”.
Continued, got lots of errors
Can’t login to the dashboard again

Rolled the site to an earlier version and carefully tried the steps again. Same error, same problems.

Any suggestions?

You are saying, when you restore your site to 2.7.1 everything is working again?
At which step starts it to work nomore?
Directly after upgrading MODX or after upgrading some Extras?

Hi Bruno.

Yes, when I restore from a backup I can log back into the site. At no time does the front end go down.

The problem occurs when I use UpgradeMODX Package and select to continue. As soon as it runs the checks and can’t connect to the database that’s where problems start to occur.

sounds like the download is working, but the MODX setup can’t find the correct database settings, which are usually stored in /core/config/config.inc.php

Does this file exist and are the settings correct?

Thanks for getting back to me! The details look correct. The frontend of the site is fine, if it weren’t ok it wouldnt be loading right?

I think it’s unlikely that the problem is in UpgradeMODX, since all it does is download the files and launch setup. Once setup is launched UGM is no longer running.

I wonder if you have a plugin that doesn’t play nice with newer versions of MODX, though I can’t think of one that would affect DB access.

Disabling all plugins and manually deleting all files in the core/cache directory before running UGM, would be something to try.

@bobray I don’t think, this could be caused by a plugin, since the issue happens while running the setup process. Sounds, like the setup can’t connect to the db, but I have no idea, how this could be the case, while the frontend seems to work fine.

Maybe a moved core or renamed config - file or something else customized?

Would it be worth trying to update to, say, 2.7.3-pl in the first instance - instead of going straight to 2.8.0-pl?

maybe worth a try, but I can’t think, why this should make a difference.

@bruno17 There used to be MODX events that fired during setup. Plugins attached to them could definitely crash setup. I remember this because one of my extras would crash setup if its plugin was enabled. I fixed the plugin, but this still might be true of other extras, unless setup has been rewritten to avoid it.

1 Like

Setup runs OnMODXInit, OnInitCulture, and a few others that happen automatically when loading MODX externally.

As of MODX 3.0.2, it no longer does that, and also doesn’t run the new bootstrap.php namespace initialisation.

Good news. My memory on this is hazy, but I remember that a plugin of mine executed during setup. The event that fired occurred before $modx->user existed and my plugin referenced that nonexistent object. IIRC, it was a fatal error for setup. I filed an issue on it at the time, but also added a sanity check to the plugin (that should have been there to begin with).

Thanks for all the suggestions! Working my way through them! I was on v 2.7.0

@bobray noticed some errors installing the Upgrade MODx package in the first place. Im using PHP 7.4 as recommended for the MODx version.
Could these give a hint to the problem?

Console running...
Attempting to install package with signature: upgrademodx-2.3.3-pl
PHP warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
PHP deprecated: Array and string offset access syntax with curly braces is deprecated
Package found...now preparing to install.
PHP warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
PHP warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
Grabbing package workspace...
Workspace environment initiated, now installing package...
PHP deprecated: Array and string offset access syntax with curly braces is deprecated
Resource URI nyheter/2017/10/04// already exists for resource id = 76; skipping duplicate resource URI for resource id = 79
Successfully installed package upgrademodx-2.3.3-pl`Preformatted text`

@dejaya Tried uploading just to the next minor version which did work but with a little notification.

Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/terasakico/public_html/setup/includes/parser/modinstallsmarty.class.php on line 75

There after I just worked my way up. the minor versions and they seemed to all install ok! Thanks very much for your help.

1 Like

Glad you got it sorted!

I only wish I could explain why that worked and going straight to 2.8 didn’t!

1 Like

I think those errors are just cases of the older versions of MODX using code that’s deprecated in your version of PHP. Since they’re all warnings or deprecation notices, not real errors, they almost certainly wouldn’t have affected MODX operations, and they were caught and fixed in later MODX versions.