modxcms / revolution

MODX Revolution - Content Management Framework
https://modx.com/
GNU General Public License v2.0
1.36k stars 528 forks source link

[Bug] name field for modContext missing, crashes upgrade from 2.2.x to 2.4.x+ #12935

Closed exside closed 3 years ago

exside commented 8 years ago

Summary

Just ran into that on an older site (2.2.16) I'm finally upgrading to 2.4.x... (actually 2.5.0-rc1) The issue was already described here: https://github.com/modxcms/revolution/issues/12764 but that was closed, so I'll create a new issue because I think this should be fixed and not just be "hotfixed" by manually adding the missing name field via phpmyadmin as suggested by @bertoost (thanks for the fix btw)...

Step to reproduce

After pressing the "Install" button, the setup fails immediately with the following error:

Fatal error: Call to a member function checkPolicy() on null in /path/to/core/model/modx/modx.class.php on line 1880

No way to proceed or solve the problem except doing what was suggested in the closed issue referenced above...

The install log gives the following very helpful hint:

[2016-03-14 14:46:37] (ERROR @ /path/to/core/xpdo/om/xpdoobject.class.php : 240) Error 42S22 executing statement: 
Array
(
    [0] => 42S22
    [1] => 1054
    [2] => Unknown column 'modContext.name' in 'field list'
)

[2016-03-14 14:46:37] (ERROR @ /path/to/core/model/modx/modx.class.php : 2322) Could not prepare context: mgr

I'm not so familiar with the table updating process during the setup/upgrade of MODX, but I think this is should be fixed, no?

UPDATE: Wanted to apply the hotfix suggested (e.g. add the name column manually to the modx_context table) but the name column was already there, so I just tried to run the setup again and it ran trough without major issues (so far)...but still, this should be fixed or handled in a better way =)...

Observed behavior

Setup crashes, no upgrade possible from 2.2.x to 2.4.x or higher...

Expected behavior

Upgrade works...

Environment

Doesn't really matter I guess...but was 2.2.16 to 2.5.0-rc in my case...

goldsky commented 8 years ago

You need to upgrade it step by step, 2.2.x > 2.3.x > 2.4.x > 2.5.x Each version updates database.

jaygilmore commented 8 years ago

@goldsky the need to upgrade to minor versions at a time is a bug, IMO. It shoudl be possible to upgrade from 2.0 to 2.5 without issue.

OptimusCrime commented 8 years ago

Is that really necessary?

jaygilmore commented 8 years ago

@OptimusCrime you mean is it necessary to be able to move directly from 2.x to 2.x without intermediate steps? I say it should be possible to go from 2.0.x to 2.X.current. at any time. 2.x to 3 may be a different story.

opengeek commented 8 years ago

This definitely should not be happening. Are others able to reproduce this consistently when going from 2.2.x to 2.4.x?

jaygilmore commented 8 years ago

@exside what extras were installed at the time of upgrade?

pixelchutes commented 8 years ago

Could it be an issue with 2.5.0-rc1? Just looking for another angle...

OptimusCrime commented 8 years ago

@jaygilmore Sorry, I was asking @goldsky. I've always upgraded between minor and major without the immediate steps.

goldsky commented 8 years ago

I'll try to reproduce, my own site had that problem, but I forgot from which version.

ckburnett commented 8 years ago

@opengeek I can confirm this happening, but, not consistently. Of two tries on two sites, one worked, the other failed as described in the issue.

@pixelchutes Happening in 2.4.3.

Things in common: Same hosting provider MySQL 5.5.42-37.1-log Upgrade from 2.2.15 (advanced) -> 2.4.3 (advanced) Successfully upgraded those extras (via package mgmt.) with newer versions on old MODX version prior to MODX upgrade

Things different: Site with successful upgrade: PHP 5.6.17 Site with failed upgrade: 5.4.43

@jaygilmore Here are the extras Site with successful upgrade: ClientConfig, CodeMirror, Formit, getResources, GoogleSiteMap, TinyMCE, Wayfinder

Site with failed upgrade: Formit, getResources, GoogleSiteMap, SimpleSearch, spiefeed, TinyMCE, Wayfinder

ckburnett commented 8 years ago

Note: Forums have had intermittent discussion about name field not being added to the context table on upgrades. Problem appears to go back a few versions.

From the setup code, seems that the field was (supposed to be) added in 2.3.0.

From a quick search, here are two threads referencing that missing DB field:

http://forums.modx.com/thread/?thread=96925 https://forums.modx.com/thread/?thread=92393&page=2

iLexN commented 8 years ago

my company website is using MODX Revolution 2.2.5-pl (traditional)

i backup the website and try to update the MODX version.

First time , i update the version to 2.4.3 , when install it , it cause the error and stop running (i forgot what kind of error) , than i press back and install it again , this time success. and tested most of the webpage / manager , it seem working fine. Cause there have error when install , so i am not sure MODX everything is good to go live. Than i use the backup and try again.

Second time , i update the version from 2.2.5 to 2.3.16 , than from 2.3.16 to 2.4.3 , this time , the installation seem better, only have some "Duplicate column name" in the log.

finally , i still have not upload to live yet.

what is the best way to do the upgrade from 2.2.x to 2.4.x ?

please advice.

jpdevries commented 8 years ago

If it is just a few errors in the log I would clear the error log and test the site front end and back end. Then check the error log again. It's fairly common for their to be warnings, so don't let the error log frighten you too much. 

If you have access to the command line you can ensure a smooth migration process by using MODX teleport to create a complete snapshot to serve as a backup before the update. If things go wrong you install 2.2.5 from scratch with a fresh database and then infect the complete snapshot into it. 

OptimusCrime commented 6 years ago

Can we close this? Did anything happen to this?

jaygilmore commented 6 years ago

Please don't close this. This is a real issue. Even though the versions are old and the longer we wait the less of an issue it is, this should be corrected. It causes a significant amount of unnecessary pain. There should be no reason with SemVer that you need to do incremental upgrades. It is not the intent of how MODX has worked since it's first release.

ghost commented 6 years ago

Hi all,

I'm commenting on this as it's a real issue and one that is going to affect a number of people, myself included when trying to patch to the latest versions of MODX.

As Jay said, there is no reason why anyone should have to upgrade through all major point releases to get to the top. That's a nightmare in a production environment as you need to upgrade more than once.

Given that many much older sites are at the moment more likely to be upgraded due to the latest critical vulnerabilities (a good thing in the long run) this is going to cause problems.

David.

Mark-H commented 6 years ago

If anyone has any leads as to why this is happening, that would be useful in correcting it. The relevant code that creates the modContext.name field for 2.3.0 is in https://github.com/modxcms/revolution/blob/2.x/setup/includes/upgrades/mysql/2.3.0-rc1.php#L60-L68

alroniks commented 3 years ago

I guess in 2021 it lost its actuality. Feel free to reopen.