How I upgraded Drupal 6 to be hosted on Docker, PHP 8, Mysql 8
Drupal 6 is over a decade old this year and I decided to see if it still capable of running on a modern tech. Or rather if modern tech can be used to host Drupal.
First things first - the project is quite old and is being heavily used by partners, so I can’t just rewrite everything in Drupal 7/8/9 and ask everyone to please switch their ways and get to learn how to use the system again. (Although I might as well just do that if things go badly and Drupal 6 chokes up in smokes).
Second, I’m going to try using something called Drupal 6 LTS - forks of Drupal 6 core and modules for Drupal 6 Long-Term Support. Sounds promising.
So my goal is to use
- Drupal 6
- Docker Compose
- PHP 8
- MySql 8
Step 1. Upgrade the core.
There is nothing hard here, just pull the latest from 6.x branch.
Step 2. Upgrade modules.
This is the most tedious part. Every module has a different level of compatibility with my target version of PHP. Most of the time you get a white screen or an error message saying that
argument #1 is of type array or much more common:
Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in
PhpStorm eases this burden a bit - if you set the target PHP version for you project, then its “Problems” panel shows you what issues you have in each file of your project and you can fix them without going back and forth between the IDE and a browser.
Many modules have been upgraded by the folks in Drupal 6 LTS, use them.
This is the longest and the hardest part. Some modules might not have the “LTS” version, you’ll have to fix them manually.
Luckyly, with the tool like PHPStorm this task seems manageable.