3

What is the best way to do this? I also have a number of plugins that all need updating from the same time period. I don't think any of the breaking changes affect anything I've done, but I wonder/expect that some plugins may need to be updated to work with the new craft versions.

The PHP requirements changed twice during the various updates. I'm currently running PHP 7.2 but I know that Craft 3.6 needs 7.2.5 or later. I can make 7.4 available but do I change it before I start the updates or after.

I have already tried doing this once from the control panel, and Craft seemed to update and the control panel was available but all the plugins were disabled and when I tried to update any plugin it failed and I got an Internal server error page. The composer.json file hadn't been updated to show the new version of craft, I tried editing it and changing the PHP version in the config.platform but still couldn't update any plugin.

I can ssh into the server but my command line knowledge is very limited and potentially dangerous.

My server is already running composer 2.0.6

1
  • Is this a production environment, or a local/dev environment? In other words, how bad would it be if something were to go wrong?
    – Paul
    Commented Apr 8, 2021 at 20:31

1 Answer 1

2

This is how I would go about this (in a local or dev environment):

PHP

First, activate PHP 7.4 and check if the site still works as it should (frontend, backend). I don't know exactly if version 3.3.4.1 works with PHP 7.4, but it's easier to switch back to an older PHP-version than reverting a Craft upgrade.

Craft

After you've made sure that the site still works, you can start the upgrade to Craft 3.6.11.2. I would kindly but strongly suggest that you use Craft's command line commands for this. In our experience, this gives you more detailed error messages.

  • First, make a backup of both your files and database (create a server snapshot, or manually create a backup)
  • Now, open a terminal. Don't be scared, you'll love it. Or not, depending on the outcome of this experiment.
  • Navigate to your project's root folder.
  • Run ./craft update <-- This will run the craft script in the current folder (./) and then it tells Craft to run the update command. This command will only show you what needs to be updated, it will not update anything.
  • Now, you should see a list of updates of both Craft and plugins. I'd start by updating Craft itself. Baby steps, you know?
  • Run ./craft update craft <-- This tells Craft to update ... itself. In the background, composer.json will be changed and Composer will update Craft. If that fails, Craft will tell you why. If something goes wrong, Craft will ask you if you want the changes to composer.json reverted. If you choose to do this, you can then fix the problem and run the update again. If you don't revert the changes, you can fix the problem and run composer update. If you update Craft using Composer, you'd still have to run ./craft migrate/all to run any database migrations that come with newer versions.
  • If the update succeeds, you can then ./craft update all, to update all plugins. This, again, changes your composer.json file and runs Composer in the background.

Common pitfalls

File or folder permissions

Your vendor folder, your config/project folder ... Craft needs permission to change things in order to proceed with the update. Check your permissions and try again.

Composer mismatches

A failing update could be Composer throwing an error. For instance, if your composer.json file explicitly says "Use PHP 7.0", and Craft 3.6 requires PHP 7.2, you'd get an error. In this case, alter composer.json and try again.

Luck and common sense

Most of the times, Craft updates just work. If they don't, put on your smart hat and try to read the errors that Craft or Composer throws at you. Another great place to look for errors is Craft's log (storage/logs/web.log). It's much easier to come up with a solution if you know what the problem is. Good luck, and remember ... backup first!

6
  • Ideally I want to run this on the production site. As setting up a local copy is such a pain in the ****. I have tried MAMP, Local and Nitro and every one is time consuming to set up and then sometimes doesn't work, and then transferring to production adds another load of pain. I usually make a copy of the craft folder on the server and backup the database. Then if it all fails I can just reuse the copied folder and use the database backup to get back to where I was. It's a pain but less of a pain than setting up a local copy.
    – Paul Frost
    Commented Apr 9, 2021 at 9:06
  • I'll have another go today using your suggestions. The pain of updating is why I don't do it more frequently, even though more frequent updates would probably be less likely to fail.
    – Paul Frost
    Commented Apr 9, 2021 at 9:09
  • I've logged in via ssh and into the craft directory (which I've renamed basoc_craft) and I run ./craft update and nothing happens. I don't get a list of available updates.
    – Paul Frost
    Commented Apr 11, 2021 at 11:06
  • Does craft exist in that folder? You can try running php craft inside that folder and see what happens... Commented Apr 12, 2021 at 16:58
  • What DO you get when run either ./craft update or php craft update?
    – Paul
    Commented Apr 13, 2021 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.