Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: Using Of Patch

Submitted by on February 15, 2012 – 10:09 amNo Comment

You can find this article helpful if you need to use a patch with various modifications. Here, I will tell you about two ways of using a patch.

Solutions:

Manual using of patch

Important: do not forget to create a backup copy of a file you want to modify!

Open patch file and find lines in the following format at the beginning of the file:

— Sites/drupal/sites/all/modules/filter_default/filter_default.module 2007-09-12 15:58:16.000000000 -0500
+++ sites/drupal6/sites/all/modules/filter_default/filter_default.module 2008-04-25 17:18:29.000000000 -0500

“—” means this is original file, and “+++” means this is resulting file. Thus if you use a patch to the original file (“—“), you should get the resulting file (“+++”).

Every piece with changes has the following format:

@@ -59,8 +66,8 @@ function theme_filter_default_admin_defa
for ($i = 1; $i < count($roles)+1; $i++) {
$row = array();
$row[] = $i;
– $row[] = drupal_render($form[‘role_’.$i]);
– $row[] = drupal_render($form[‘format_’.$i]);
+ $row[] = drupal_render($form[‘role_’. $i]);
+ $row[] = drupal_render($form[‘format_’. $i]);
$rows[] = $row;
}

How to read this code:

  • @@ -59,8 +66,8 @@ function theme_filter_default_admin_defa – means that lines 59-66 are changed
  • “-“ at the beginning of a line means that tha line have to be deleted
  • “+” at the beginning of a line – need to add this code
  • The rest of lines are context of changes

You should just make changes in the required file…

  • Using a patch

Unix and Linux

info about patch (Unix): man patch:

  • Copy patch files to a place where the file was created (the path is the first two lines of a patch ).
  • Apply patch command
    • from a folder with a file that is to be changed:

      patch -p0 < path/file.patch

    • from the site root:

      patch < file.patch

Cancel patch

If you have some problems with engine working after using a patch, you can use the following command to roll the changes back:

patch -p0 -R < path/file.patch

or

patch -R < file.patch

depending on a command you used for the patch originally. But it’s always better to restore file from the backup copy.

Windows

  • Download PATCH program: http://gnuwin32.sourceforge.net/packages/patch.htm
  • Install it (run Setup).
  • Open installation folder and find patch.exe in bin folder.
  • Copy patch.exe to a folder with patch and source files.
  • Run patch.exe – terminal window will open.
  • Click CTRL+C – you’ll see the console: C:\patch>
  • Run a command:

    patch.exe –binary -p0 < SA-CORE-2009-009-6.14.patch

    Enter name of a patch file instead of SA-CORE-2009-009-6.14.patch.

Summary: Manual using of a patch is the most complicated way but you can always use it. Using a patch is a quick method but it requires installing of additional programs in Windows.

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.