Patching Drupal core

Every once in a blue moon, you'll run into a problem with your Drupal site where the solution involves patching core. Start by making sure that you have a safe place to apply your patch. This would be a 'dev' copy of the website, either running locally on your own computer, or in a development environment on the same server (or one that's identical) to your live site. *Never* apply patches directly to your live website - *especially* core patches!!!

  1. Start from the root of your Drupal site.
    [.../drupal-7] 
    
  2. Download the patch file from drupal.org
    [.../drupal-7]  wget http://drupal.org/files/606598-core7-port-imagestyles-175.patch
    

    OR, If you don't have wget on your computer (with a mac you will need to install Xcode) then you can do the same thing with curl, as follows

    [.../drupal-7]  curl -O http://drupal.org/files/606598-core7-port-imagestyles-175.patch
    

    OR, If curl doesn't work, you can also visit the URL for the patch in your browser, and do a file -> save to download the file to your computer.

  3. apply the patch
    [.../drupal-7]  patch -p1 

    If everything goes well, you'll see the files that are patched:

    [.../drupal-7/sites/all/modules/contrib/panels]  patching file modules/image/image.admin.inc
    [.../drupal-7]  patching file modules/image/image.api.php
    [.../drupal-7]  patching file modules/image/image.install
    [.../drupal-7]  Hunk #2 succeeded at 454 (offset -1 lines).
    [.../drupal-7]  patching file modules/image/image.module
    [.../drupal-7]  Hunk #1 succeeded at 347 (offset 5 lines).
    ... etc
    [.../drupal-7]  patching file modules/image/image.test
    [.../drupal-7]  Hunk #2 succeeded at 462 (offset 56 lines).
    ... etc
    
  4. Clear your caches, and go test your new fix/feature!
© 2024 Jeneration Web Development