D7 PHP-8 Upgrade

Overview

  1. Update the site (dev, test, live) like normal. If it has been done recently do not worry about it.
  2. Create a multi-dev called php8
  3. Clone the site 
  4. In ubuntu execute the command git checkout php8
  5. In SFTP download the required version of the modules
  6. Commit and switch to Git and then pull locally
  7. Patch required Modules
  8. Create Pantheon.yml file
  9. Patch Drupalexp theme as required
  10. Push, updb, cc all, and then test php8 site
  11. Troubleshoot as required
  12. Merge to Dev
  13. Update spreadsheet and celebrate

Update the Sites

  1. Go to the site's dashboard
  2. Bring the live database and files back to dev
  3. Backup, backup, backup
  4. Update core
  5. Once done, move the site to SFTP
  6. In the site admin, update all modules
  7. Run update.php
  8. Clear the site's cache
  9. Verify all is well
  10. Commit the code changes
  11. Open your bash
  12. Pull down the changes

Begin PHP8 Upgrade

  1. Create a multi-dev and call it php8
  2. Clone the site
  3. In ubuntu execute the command git checkout php8
  4. ULI into the new multi-dev: terminus drush site-name.php8 -- uli
  5. Check the site for the modules in the Modules list below
  6. Swap to troublesome modules to dev and patch if necessary
    1. This can be done locally or through Terminus and Drush
    2. Locally is downloading, extracting and replacing
    3. Through Terminus and Drush can be done in a few steps
      1. Make sure the site is still in SFTP
      2. In your bash run this for each module
        1. terminus drush site-name.site-env -- dl module_name-module_version -y
        2. ex. terminus drush ofm-ofm.php-8 -- dl security_review-7.x-1.x-dev -y
      3. Once done with all modules, run a database update and cache clear
      4. Commit changes
      5. Put the site back into Git
      6. Do a Git Pull to Pull down the changes
  7. The terminus drush -- dl command will put the dl module into a modules>contrib folder if there is a contrib folder. Check to make sure you now do not have duplicated modules. If you have a module you just downloaded and patched in contrib make sure to delete the duplicate folder that is directly in the modules folder.
  8. Patch those troublesome modules
  9. Check for pantheon.yml in the site root
  10. if it's not present, make the file name it "pantheon.yml"
  11. Just add these 2 lines 

api_version: 1
php_version: 8.0

  1. Check to see if the website has drupalexp as a theme in the sites/all/themes folder. If it does go to the bottom of this page and apply the drupalexp patch. If not, or once complete with the patch, proceed to the next step. 
  2. Push the changes up
  3. Run these commands in bash
    1. terminus drush site-name.site-env -- cc all
    2. terminus drush site-name.site-env -- updb -y
  4. Verify that all is well
    1. If any other modules present deprecated code issues, the first place to look is the module's issue log
  5. Merge php8 into dev (make sure "Run update.php" is checked)
  6. Once dev is good, a simple code push, database update and cache clear should be all that's needed

Steps to Patch a Module

All the patches can be pulled from a repository that we manage. Those patches can be cloned with the bash command below. The folder can live outside the site root folder like so.

  • Root
    • site folder
      • site files
    • patches
      • list of patches

git clone git@gitlab.com:watech-web/d7-php8-patches.git patches

or

git clone https://gitlab.com/watech-web/d7-php8-patches.git patches

Every so often, CD into the patches folder and run a git pull.

  1. If not open, then open your bash
  2. cd into a site folder
  3. Determine what modules in the list below are used on the site
  4. Once done with all, cd into each module's folder
    1. cd sites/all/modules/module-name
  5. Copy the patch file from patches to the module folder
    1. cp -rf ../../../../../patches/patch-name.patch .
    2. Keep track of the ../ as you may be one folder deeper in modules like in contrib
  6. Verify the patch file exists
    1. ls
  7. Apply the patch
    1. patch -p1 < patch-name.patch
  8. Verify you see a success message
  9. Remove the patch file in the module folder
    1. rm -rf patch-name.patch
  10. Repeat for every module that needs to be patched

Module List

The following modules have issues with PHP 8. Some are fixed in dev releases and the rest need to have the dev release patched. There's a good possibility the dev release could be fixed soon. Each module below has the download link for the code, the issue link and the patch link. Check the issue link to see if it has been marked 'fixed.' If so, just download the dev release.

Download Dev Only

Context

Date

Feeds (fixed in dev as of 11/3/2022)

SMTP

  • Terminus download: terminus drush site-name.env -- dl smtp-7.x-1.x-dev -y

Needs Dev and Patch

CKEditor Link

Entity Reference Autocomplete

Features Extra

Hierarchical Select

Location

Multiupload Filefield Widget

Oauth

Path Breadcrumbs

Security Review

Workbench Moderation

Steps to Update Drupalexp Theme

  1. cd sites/all/themes/drupalexp
  2. run wget https://gitlab.com/watech-web/drupalexp-php-8/-/raw/main/drupalexp-lessc-curly-fix.patch
  3. If it does not work email Sam to get a copy of the patch and copy it into drupalexp folder.
  4. In bash run
    1. find . -type f -print0 | xargs -0 dos2unix
  5. Now run
    1. patch -p1 -l < drupalexp-lessc-curly-fix.patch
  6. Remove the patch file (and patch identifier) from the drupalexp folder.
    1. rm -rf drupalexp-lessc-curly-fix.patch
    2. rm -rf drupalexp-lessc-curly-fix.patch\:Zone.Identifier
  7. CD back to the root of the site
  8. Send the changes up

If the find command (4) does not work you may need to install dos2unix. sudo apt-get install dos2unix

Notes:

DB Mega - D7

Not a standard patch, but a clone. 

https://gitlab.com/watech-web/db-mega-d7

  1. cd sites/all/modules
    1. Could be in contrib too
  2. rm -rf db_megamenu
  3. git clone git@gitlab.com:watech-web/db-mega-d7.git db_megamenu
    • or git clone https://gitlab.com/watech-web/db-mega-d7.git db_megamenu
  4. rm -rf .git
  5. cd back to root
  6. send the changes up

TB MegaMenu

  1. cd sites/all/modules
    1. could be in contrib
  2. rm -rf tb_megamenu
  3. git clone https://git.drupalcode.org/project/tb_megamenu.git 
  4. cd tb_megamenu
  5. git checkout 7.x-1.x
  6. rm -rf .git
  7. cd back to root
  8. send up
  9. updb and cc all
  10. test

If there is still an issue:

"Warning: Trying to access array offset on value of type null in tb_megamenu_sync_config() (line 370 of /code/sites/all/modules/tb_megamenu/tb_megamenu.functions.inc)."

You can look at Issues for tb_megamenu and find this patch. 

https://www.drupal.org/files/issues/2023-03-04/tb_megamenu-php_notice_fixes-3211791-9.patch

To apply this complicated patch following this instructions. 

https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupal/working-with-patches/applying-a-patch-in-a-feature-branch

SAML Library (php-saml)

There is an error that the older version of the library throws. It is: 

Deprecated function: Function libxml_disable_entity_loader() is deprecated in OneLogin\Saml2\Utils::validateXML() (line 146 of /code/sites/all/libraries/php-saml/src/Saml2/Utils.php).

It does not currently appear to hinder someone's ability to login using the active directory, but it is a php error. To fix that we need to replace the current directory with the 3x-dev branch. To do this follow these steps starting in the website's folder.

  1. cd sites/all/libraries
  2. rm -rf php-saml
  3. git clone https://github.com/SAML-Toolkits/php-saml.git php-saml
  4. cd php-saml
  5. git checkout 3.x-dev
  6. rm -rf .git
  7. cd back to root
  8. send the changes up

IP Geolocation

https://www.drupal.org/project/ip_geoloc/issues/3177202
 

Picture

https://www.drupal.org/project/picture/issues/3263235

Nodeformcols

https://www.drupal.org/project/nodeformcols/issues/3225090