Search...
Toggle theme

Modified Drupal Core

Considerations when using modified versions of Drupal that have altered files in core.

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 which may make it difficult to do the normal drop-in replacement of the HeroDevs Drupal NES.

These versions are often found as install profiles, custom forks, or altered versions that hosting providers use to include their own code to make it easier to integrate with their systems.

Git Based Install

Create an orphan branch to unzip Drupal NES

git checkout --orphan nes-drupal

Download the HeroDevs Drupal NES

Follow the download instructions found on the installation page to download Drupal 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 lives 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 NES into the Drupal folder

From your project root, where the zip file should live, 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 NES branch

At this point, you are ready to merge in the modified Drupal into Drupal NES so that any changes to core are kept after upgrading to HeroDevs Drupal NES. Because this is an orphan branch, it does not share history with your main branch so you will need to add the --allow-unrelated-histories flag in order 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. It is recommended to 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 patchfile of the changes to apply over modified core

Generally, it is not recommended to directly change core. For this reason, creating a patch to be applied over the modified version.

First, review the differences between the main branch and the Drupal 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

Checkout your main branch

git checkout [YOUR MAIN BRANCH]

And branch off of the main branch for testing.

git checkout -b test-nes-patch

Try to apply the patch.

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

or if using patch

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

Clear 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 NES.

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