Can't upgrade to mautic 3.02 => 4.2 from command line

Your software
My Mautic version is: 3.02
My PHP version as given by Mautic is: 7.3.33
DB Server type: MariaDB
DB Server version: 10.2.32

Webserver: nginx/1.20.2
PHP version as given by phpMyAdmin: 7.4.28

I’m on Amazon Lightsail/Ubuntu/Plesk

Your problem
My problem is:
I can’t upgrade to mautic 4.2, even from the command line. The update:find command says that I have the latest version installed.

Steps I have tried to fix the problem:
I’ve tried updating to PHP 7.4.28, but update:find still says I have the latest version.

What is the work around for this?

Hi,

this is probably because of previous unsuccessful / partial updates. Try the following:

  • Backup source and database
  • Reinstall current version of mautic 3.0.2 (clone / copy core files from Mautic release) and then copy instance specific folders and files to this fresh clone

It is possible that you will have to revert app/config/local.php which is trickier since this is specific to your instance - but first try the above and lets see what issues you face then.

Thanks, I will give that a go. Could you clarify what are “instance specific folders”, please? Is that like a file I’ve written to handle a webhook?

These are folders in which mautic places uploads of any kind or some other files that are created on the fly and are of relevance to the user, those folders are:

  • media
  • themes
  • local*.php files in app/config

Hope it helps.

Mautic has

That was helpful, thanks mzagmajster.

So I did a new install of Mautic Ver 3.02, copied over my old local.php to the new install (nothing else), and updated all obvious references in local.php to point to the new install. I checked the new Mautic and all of the data appeared to display fine. Then I updated to php 7.4.28.

Finally, I did mautic:update:find (making sure to give the path to the new instance). But the results were the same, “Great! You are running the current version of Mautic.”

Did I miss something?

  1. Where did you download files for Mautic 3.0.2?
  2. What path did you give to update command, you should run this command inside mautic root directory.
  3. When you run php bin/console --version what does it say in the terminal?
  4. What does it say at the bottom of the page in the right corner? What version is shown there?

Thanks for your help, mzagmajster.
0. I downloaded the files from github: Release 3.0.2 · mautic/mautic · GitHub

  1. /var/www/vhosts/domain/originalmautic/clonemauticfiles/bin/console mautic:update:find
  2. Mautic 3.0.2 - app/prod (kernel: app, env: prod, debug: false)
  3. v3.0.2

Can you try to run find command like this:

cd /var/www/vhosts/domain/originalmautic/clonemauticfiles
php bin/console mautic:update:find

There are couple of possibilities:

Running update from the root directory gives the same result.

I confirm (with cut and paste) ‘system_update_url’ => ‘https://api.github.com/repos/mautic/mautic/releases’,

I mean there is always an option of updating manually:

  • download latest 3.x files
  • replace the files in current instance
  • run php bin/console mautic:update:apply
  • run php bin/console mautic:update:apply --finish

At this point you can try to use find & update command again to update to the latest 4.x version, if it still does not work you can repeat procedure with 4.x files

Thanks for your help so far…

I installed Mautic 3.3.4, replaced the files in the current directory and from its root directory executed update:apply. I get this error:

In ListModel.php line 78:
Type error: Argument 1 passed to Mautic\LeadBundle\Model\ListModel::__construct() mus
t be an instance of Mautic\CategoryBundle\Model\CategoryModel, instance of Mautic\Cor
eBundle\Helper\CoreParametersHelper given, called in /var/www/vhosts/domain/originalmautic/clonedmautic/var/cache/prod/Containe
r5xuxk9r/appProdProjectContainer.php on line 9240

I don’t think things look good at this point. Luckily, I can input the essential data I need with just a couple of hours work.

  • make sure you run the supported php version
  • rm -rf var/cache/dev/* var/cache/prod/*
  • php bin/console mautic:plugins:reload --env=prod

@vanguy765 Try do an incremental update using the command line where you install mautic from a zip file. Then run database migrations after each step. This will be tedious but it should get you to the latest version. Try not do a big jump in versions, as a lot changes and some file locations and or commands may not work.

remember to do each upgrade…incremental
Then database migrate
clear cache
next upgrade
etc

Hope this helps
M.

raramuridesign, I’m inputting the data by hand. But for the next person your suggestion for incremental upgrades is good as I did use the zip files. (My problem was the db was no longer “whole”.)

For the sake of completion, how do I do a database migration?

1 Like
  • backup database
  • run php bin/console doctrine:migrations:status
  • run php bin/console doctrine:migrations:migrate
1 Like

@vanguy765 glad it worked
You can see from @mzagmajster the suggestion to run the command line migrations of the database.
Was the upgrade now successful?

raramuridesign, mzagmajster No, the upgrade was not successful. I downloaded 3.1 from Github and copied the unzipped files into my current directory. When I tried to migrate the database I got the following error:

In AmazonTransport.php line 35:

Type error: Argument 4 passed to Mautic\EmailBundle\Swiftmailer\Transport\AmazonTransport::__construct() must be an instance of Mautic\EmailBundle\Swiftmailer\Amazon\AmazonCallback, instance of Mautic\CoreBundle\Translation\Translator given, called in /var/www/vhosts/domain/subdomain/clonemauticfiles/var/cache/prod/Container5xuxk9r/getMautic_Transport_AmazonService.php on line 8

I have ported the essential parts of my data. But, what did I miss to get that error?

(It was not that I did not clear my cache, was it?)

Run:

  • rm -rf /var/cache/prod/* var/cache/dev/*
  • php bin/console mautic:plugins:reload --env=prod

Also you cant just copy files to an existing mautic dir.

Create new mauitc dir and copy local.php & ,media files to the new dir

OK. I will have to try this later, just to check this works for a time when things go south on me. Thanks for your help.

(I feel like an idiot… The instructions to clear the cache and reload plugins is right there in your earlier post.

So, for the next guy, can you confirm the following as a general guide? If you have trouble upgrading your Mautic installation, do it manually one incremental update at a time using the following steps:

  • backup your database
  • Create new mauitc dir with incremental update files
  • copy local.php & ,media files to the new dir
  • rm -rf /var/cache/prod/* var/cache/dev/*
  • php bin/console mautic:plugins:reload --env=prod
  • try to upgrade through the command line
    • run php bin/console mautic:update:apply
    • run php bin/console mautic:update:apply --finish
  • OR (if that fails) migrate the DB
    • run php bin/console doctrine:migrations:status
    • run php bin/console doctrine:migrations:migrate

Remember, copying the new files to the old directory will not work, make a new directory and copy your local.php & media files to it.

A good reference for what happens during a regular upgrade is here (but dated) Upgrade steps | Mautic

Also, be aware that you may need to upgrade your PHP instance along the way to upgrading your Mautic. The php requirements for Mautic are here, Requirements

1 Like