Modified Drupal Core

Handling Drupal installations with modified core files

What is Modified Drupal Core?

When a version of Drupal has been altered from the original open source version, there are often changes to core files that may make it difficult to do the normal drop-in replacement of the HeroDevs Drupal 7 NES.

These versions are often found as install profiles, custom forks, or altered versions used by hosting providers. They include proprietary code to facilitate integration with their systems.

Git-Based Install

Create an orphan branch to unzip Drupal 7 NES

git checkout --orphan nes-drupal

Download the HeroDevs Drupal 7 NES

Follow the download instructions found on the installation page to download Drupal 7 NES.

Remove the modified version of Drupal from the docroot folder

Delete the contents of the folder where your version of Drupal lives. In some cases, this may be the root folder of your codebase; however, in many cases it will be at /web or /docroot. This folder will contain index.php and install.php in addition to other files.

Assuming your installation is at /web, from your project root, run:

cd web
rm -rf *

If your project root is the same as your docroot, delete all files and folders EXCEPT .git.

Unzip Drupal 7 NES into the Drupal folder

From your project root, where the zip file should be located, run:

unzip nes-d7.zip -d <your-drupal-folder>

Commit the unzipped files to your branch

git add ./
git commit -m "your-commit-message>"

Merge your main branch into the NES branch

At this point, you are ready to merge the modified Drupal into Drupal 7 NES so that any changes to core are kept after upgrading to HeroDevs Drupal 7 NES. Because this is an orphan branch, it does not share history with your main branch. You will need to add the --allow-unrelated-histories flag for the merge to work.

git merge main --allow-unrelated-histories

It is not uncommon to have merge errors at this point. Common files with merge errors will be CHANGELOG.txt and bootstrap.inc, however, there may be more depending on how modified your version of Drupal is. You will need to manually fix any merge errors and keep changes from either the main branch, nes-drupal branch, or both.

While resolving merge conflicts, compare the conflicting changes between the modified and NES versions of Drupal 7. Retain custom modifications that are essential for the modified install profile and not present in the NES version. Accept changes from the NES version if they provide necessary updates or fixes. If both sets of changes are needed, merge them carefully. We recommend that you document each decision made during this process for future reference.

Once merge errors are fixed, add the files to the commit:

git add <file-with-fixed-merge-conflict>

Then commit the result:

git commit

Create a patch file

Generally, it is not recommended to directly change core. For this reason, create a patch that contains all your changes.

First, review the differences between the main branch and the Drupal 7 NES branch:

git diff main

After verifying your changes, create the patch:

git diff main --binary > nes-drupal.patch

This file can be kept in version control as a reference of changes to core files that have been made. It is recommended that you keep patch files together in a /patches folder in the top level folder of your project.

Create a new branch off of Main and test the patch

Check out your main branch:

git checkout <your-main-branch>

And branch off of the main branch for testing:

git checkout -b test-nes-patch

Apply the patch:

git apply /path/to/patch/nes-drupal.patch

or if using patch:

patch < /path/to/patch/nes-drupal.patch

Clear the cache and test your site's functionality

Clear caches with:

drush cc all

Verify your site is working locally or in a development environment before committing and releasing to production.

Once site functionality is verified, commit the patch and changed files to version control.

git add <changed-files>
git commit

At this point, you should have a working Drupal 7 site with modified core files and the protection of HeroDevs Drupal 7 NES.

If you require further assistance, reach out to support@herodevs.com.