0

Hello dear Civi experts,

I am new to CiviCRM world and have a task at hand to upgrade CiviCRM 5.40 which integrated to Drupal 7.82 into 5.42.

Then lift whole CiviCRM side and integrate to new Drupal 9 system, which is getting built at the moment.

Is it something possible to do? What are the thoughts or considerations in doing above practices?

Thanks in advance.

4
  • can def. be done. some hints here: civicrm.stackexchange.com/questions/39734/…
    – petednz - fuzion
    Dec 10, 2021 at 4:00
  • Is it Drupal to Drupal or Wordpress to Drupal? i thought i read wordpress somewhere, but can't see that now.
    – salah-1
    Dec 10, 2021 at 15:25
  • the Q says they are upgrading from D7 to D9
    – petednz - fuzion
    Dec 10, 2021 at 20:03
  • Thanks @petednz-fuzion, will definitely check the link you shared.
    – Tony
    Dec 12, 2021 at 22:17

2 Answers 2

9

For the Drupal 7 to Drupal 9 part of the upgrade you are best to look for help with the Drupal Community. But sounds like you have this in hand.

The CiviCRM specific part of the D7 -> D9 the things you'll want to think about are:

Drupal users If you are migrating drupal users and preserving Drupal User Ids, and drupal roles and user role mappings then you can just copy the civicm_uf_match table. If not then you will want to truncate/update the civicrm_uf_match table each time you bring the civicrm database across - and populate it appropriately.

CiviCRM <-> Drupal Modules

CiviCRM Webform Integration - do you have many CiviCRM webforms? How complicated are they? It is possible to migrate CiviCRM webforms using the Drupal webform_migrate module - however you do need to patch it. However any complicated webforms you might be better rebuilding from scratch. And if you only have a couple you are probably quicker to build them from scratch in D9

CiviCRM Views - I've not seem any good solutions to automagically migrate views yet. You'll need to rebuild all of these.

CiviCRM Entity - There is a D9 version of CiviCRM Entity - however I'm not aware of any migrations for this.

CiviCRM Version and extensions To minimise the chance of problems you are best to keep your CiviCRM version and extension versions in sync between your Drupal 7 and Drupal 9 site. (I'm assuming you will have a period of time where you are testing CiviCRM on a copy of the Drupal 9 site.)

However as you will only ever be copying the CiviCRM database from Drupal 7 site to Drupal 9 site (at the very least once to get it working to test on and another time during the go live for the Drupal 9 site) you can have more recent versions for your extensions and CiviCRM core on the Drupal 9 site than the Drupal 7 site - but it doesn't work the other way around. Just remember to run the upgrade after you import the database each time and I'd only recommend doing this if you are only jumping a few minor versions of CiviCRM core.

Installing CiviCRM on Drupal 9

In terms of the process of installing CiviCRM on a Drupal 9 site:

The following should be all you need if you are installing the latest version of CiviCRM on a site created from drupal/core-recommended - if you were installing older versions there might be additional configuration required.

composer config extra.enable-patching true
composer require civicrm/civicrm-{core,packages,drupal-8}:'~5.42'

More details instructions here https://docs.civicrm.org/installation/en/latest/drupal8/

Note this includes ->

composer config minimum-stability dev

which is no longer required - and you are probably best avoiding.

Make sure you have the correct server requirements - especially php extensions. https://docs.civicrm.org/installation/en/latest/general/requirements/

Things to think about

Ideally I'd recommend using drupal/core-recommended to set up the Drupal 9 project. While CiviCRM might work with other set ups if you can use drupal/core-recommended as a starting point you are eliminating some sources of problems and this is what CiviCRM is tested with so you are less likely to hit problems.

If you are not starting from drupal/core-recommended I'd recommend setting up a copy of the site your building and attempting to install CiviCRM as soon as possible. With a goal of proving the install will work. At a minimum test an angular page like the System Status Check page (Admin -> Admin Console -> System Status) renders properly, but if you have a lot of extensions you probably want to check they work too.

If someone is building the Drupal 9 site that is not familiar with CiviCRM you'll want to discuss with them theming requirements for any CiviCRM native pages (i.e. Events/Contribution Pages) if this is something you will want to use.

Additionally if you are using CiviCRM + webforms especially for contributions you will want to consider this as well.

You might want to have them working on a site with CiviCRM enabled but not a copy of your database just so their styles work for these pages.

Run sheet

The addition of CiviCRM to a D7 to D9 upgrade adds complexity and some additional steps. Make sure you have a good run sheet and testing is your friend.

You can copy your CiviCRM install from your live Drupal 7 to your Drupal 9 by copying the relevant database tables.

Before you go live you will want to test with a copy of your live CiviCRM database installed on your Drupal 9 site. Assuming you have a copy of the CiviCRM codebase (with a version greater than or equal to your D7 site) and the same for any extensions then all you will require is to:

Dump all your CiviCRM tables from your D7 site. These should all be prefixed with civicrm_ (So something like - assuming you have pv installed if not remove that from the pipeline)

 mysqldump --single-transaction --skip-triggers database-name $(mysql -BN -e "select table_name from information_schema.tables where table_schema = 'database-name' and (table_name like 'civicrm_%' or table_name like 'civicrm_log_%' )  | pv | perl -p -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g' | gzip > dumpfile.sql.gz

Where the mysqldump command dumps the database taking the database name and a list of tables returned from the mysql command - which you should test first. The pv command is optional - just shows you a progress bar. The perl command strips out various things you don't need in the dump that can cause errors - see Why do I get "Access denied; you need (at least one of) the SUPER privilege(s) for this operation" when importing a SQL dump to CiviCRM? for more information. the gzip command is optional if you are copying between servers you'll want to compress the output.

There is at least one CiviCRM extension which uses a non standard prefix (not civicrm) - so if you get missing table errors double check that you don't have an extension using a table that isn't prefixed correctly.

Assuming you have already installed a blank CiviCRM for testing on this site drop all the CiviCRM tables (or database if you have the CiviCRM tables in a different database).

If you haven't note you can't just copy the civicrm.settings.php file from the D7 install over - there are some differences in paths between the two systems which will probably show as any CiviCRM CSS/JS resources failing to load in the browser.

Then load the dump file into database you are using for the Drupal 9 site either into the Drupal Database (easy) or a different database (slightly more difficult).

If the path to your extension directory is different between d7 and d9 which is likely make sure that is set correctly - the easiest way to use the commented setting in civicrm.settings.php. Visit a CiviCRM admin page and ensure you don't get missing extension warnings. if you do you'll need to force a refresh either in the UI via the manage extensions page or using cv.

Set your outbound mail off and put into staging mode to prevent a cron job from triggering any payments. (Assuming you haven't overridden this in your schedule jobs page - which would be rare, in which case disable the job there).

Files - you'll also want to copy across any files that CiviCRM manages. If you check your Admin - System Settings -> Directories it will give you a path to look for these in. It might be that you don't have anything to copy. And you might be okay to just do the initial copy and the final copy and leave this step out of any intermediate copies during/for testing.

If your D7 site CiviCRM version is behind your D9 CiviCRM version run the CiviCRM upgrade.

Go live

You'll need to plan in as part of the migration the time taken to switch your CiviCRM database over - and you want to either:

  • have the Drupal 7 site in maintenance mode for this period, or
  • have a plan to manually copy any updates made in CiviCRM (i.e. unsubscribes, subscribes, payments etc) after you dump the tables to the time you switch over.

If the people managing your Drupal upgrade are not familiar with CiviCRM you'll want to flag this with them as they will need to build this into their plans.

If the new D9 site will live on a different server then you will need to think about the DNS propagation time too, decrease your TTL in good time to minimise this. You can potentially set up a reverse proxy on one of the servers to eliminate this lag to minimise time in maintenance mode - however if you are okay with more downtime that is an easier solution.

If possible I'd recommend running a practice of copying your CiviCRM install across immediately before you go live, and after a freeze on any changes to the Drupal site. Build in an additional round of testing. That gives you a chance to get a good time estimate to help with your cut over planning and will hopefully pick up any last minute errors that happen.

Final Notes

If you have any custom extensions test them. If you take payments test your payment processor if possible with a live $1 transaction.

Then enjoy your shiny new Drupal 9 site. And share anything you found about the process here/with the community. With Drupal 7 end of live November 2022, and Drupal 7 still having a plurality of installs by CMS there will be a few people treading this upgrade path this year.

9
  • Hello Luke, looks amazing and details you've shared with is a lot. This definitely will help me a lot going forward. Will update this once I go through things. :)
    – Tony
    Dec 12, 2021 at 22:19
  • I'm pretty sure there will be stuff missing here - but hopefully we can add to this or other answers as we go to get a definitive list. Dec 12, 2021 at 23:02
  • 1
    once there is feedback from Tony then this should probably get added to civi documentation
    – petednz - fuzion
    Dec 13, 2021 at 20:49
  • Wow, @LukeStewart this is really wonderful. We need to port lots of this to CiviCRM documentation.
    – Joe Murray
    Dec 16, 2021 at 15:56
  • @Tony have you had a chance to try the above yet - is there any big gaps! Would love some feedback on this from others who have gone through the process before we look at moving it into the documentation. Jan 18 at 20:59
1

I have setup CiviCRM with drupal 8 and 9 few times and here is how i would do it.

Prep

1- Check your machine supports at-least the minimum PHP and MySQL versions https://docs.civicrm.org/installation/en/latest/general/requirements/

2-First Install Drupal 9 and have it working 100%.

3-Then use the cv command line tool (my preference) to install civi, specially if you want to install civi in separate database than the Drupal one and check this link for other requirements. https://docs.civicrm.org/installation/en/latest/drupal8/

4 - move over your modules or other dependency stuff such as composer

5- Fix whatever issues that popup etc

For: Drupal 9:

1- Note that Drupal 9 has higher PHP, Apache and MySQL requirement, so check below link to meet those. My personal preference is since Drupal 10 isn't too far and it will require PHP 8, to just go straight to PHP 8 (supported by latest Civi and Drupal 9).

https://www.drupal.org/docs/understanding-drupal/how-drupal-9-was-made-and-what-is-included/environment-requirements-of-drupal-9

https://www.drupal.org/docs/system-requirements/php-requirements

2 - Other steps will be similar to above one. You would install Drupal first and get it working, then copy your modules that support Drupal 9 and fix comparability issues.

3 - Then you would install Civi 5.4.2 or latest version that supports Drupal 9.

4 - Consult with below links if the official install links for Drupal 9 don't work for Civi.

What is the status of CiviCRM working with Drupal 9?

Can't install civiCRM with drupal 9.2.7

  • my recommendation is if your final destination is Drupal 9, just go straight to that and save time, unless you have other requirements that need Drupal 7.8.2

Good luck.

3
  • I don't think this answers the problem. as i read it Tony has civi on d7 and wants to move it to d9
    – petednz - fuzion
    Dec 10, 2021 at 20:04
  • Updated the answer!
    – salah-1
    Dec 10, 2021 at 20:21
  • i think your answer is missing the main point. i may be wrong. but if you already have civicrm on d7, and you build a d9 site, and then you want to move the civicrm from the d7 site to the d9 site, what steps do you need to take eg are they 1/ update civi to latest on d7 2/ install same version via composer on d9 site, 3/ copy civi db to the new drupal db (delete triggers or not?), 4/ make following changes to civicrm.settings.php (if any are required
    – petednz - fuzion
    Dec 11, 2021 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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