Parse error upgrading from 2.6.5 to 2.7.2

I’m upgrading from 2.6.5 to 2.7.2 and each time I do, I get this parse error:

Parse error: syntax error, unexpected ‘{’ in /var/www/html/core-path-redacted/config.inc.php on line 91

Everything looks good right up until I hit “Install” (see image below):

I’ve deleted my core cache, made sure all my extras are up-to-date, and I’m running PHP 7.2.24.

I’ve been upgrading for years with no problems, so I’m really confused. I’ve also tried upgrading from 2.6.5 to 2.7.0, but had the same results (the same parse error).

I found this post:

And that does appear to be the same problem. However when I try to install the UpgradeMODX extra (which was the solution in this case), although it installs fine, the “Begin Upgrade” button does nothing. My core path is set properly in config.core.php, I’ve manually deleted the core cache, logged out, and I’ve tried a different browser. All with no effect.

Thanks in advance for your help!
Andrew

This has been a common problem, but the cause has never been clearly identified. Regardless, the solution is always the same. You need to restore your original config file which now contains incorrect value replacements and run setup from the beginning again. It will never work, using UpgradeMODX or just the regular upgrade process unless you restore your original config file which was overwritten with one containing invalid replacement values.

I intentionally don’t write over my config when copying over the files from the new version.

rsync -avP --exclude '*config.inc*' /root/modx-2.7.2-pl/core/ ./core/

Or do you mean it’s written over when the setup is run? Just in case, I diff’d a copy after running setup (and getting the parse error), but they’re identical.

diff -s config.core.php config.core.php.bak 
Files config.core.php and config.core.php.bak are identical

Or are you referring to another config?

No, your parse error reference above indicates the config file was written with the template values in place. They would be keys surrounded by braces as indicated by the parse error. The old config wouldn’t work if it had these variables surrounded by braces in them, so perhaps there is a miscommunication as to what the actual error being experienced here is.

Ah, you are right. Sorry I was looking at the config in my site root. But of course as you said, per my error message, the config having a problem is in the core directory.

So I found it, and diff’d the new config (after running setup) with a backup copy, and here’s the differences (I’ve altered some of these variables in case posting them some how presents a vulnerability.

[root@web config]# diff config.inc.php.bak config.inc.php.borked 
18c18
< $lastInstallTime = 1533935933;
---
> $lastInstallTime = 1573080021;
20c20
< $site_id = '...';
---
> $site_id = '...something else...';
23c23
< $uuid = '011c86a3-...-112faadd56c0';
---
> $uuid = 'f5a28e454-...-de013f97230fc';
91c91
<     $modx_cache_disabled= false;
---
>     $modx_cache_disabled= {cache_disabled};

After restoring the original the site is backup, but I am unable to login to MODX.

Actually the site isn’t up post setup. I thought it was, but that must have been a cached version. Also, I’ve tried deleting my core cache, as well as my browsers’ cache (and using another browser), and the site is still down.

After restoring my original config and then rerunning the setup, it just writes the bad one back over the top and I get the parse error again. How have you gotten around this?

It looks like your core/docs/config.inc.tpl is not the one from 2.7.2. There should be no $modx_cache_disabled variable any longer, and this is the source of the problem. Perhaps you did not successfully upload all of the files from 2.7.2 to your server.

1 Like

That was it! In my attempt to not overwrite my config, I was excluding some files that were needed. What’s weird is that it’s worked for a long time doing this.

Thank you very much for your help – I really appreciate it!