How to Apply and Revert Magento Patches

Table of Contents

Overview

This article discusses how to apply and revert Magento patches provided to you by Magento Support. The article assumes you already have the patch; if not, contact Magento Support.

Note: This article assumes your patch file name ends in .sh. If your patch file name ends in .patch or something else, contact Magento Support before proceeding.

How to Get Magento Patches

Magento Support provides some patches for Magento CE and EE on magentocommerce.com. This section discusses how to get those patches.

If Magento Support provided a patch to you, skip this section and continue with How to Apply a Magento Patch.

See one of the following sections for specific information about Magento CE or EE:

Getting Magento CE Patches

To get patches for Magento CE:

  1. Log in to magentocommerce.com/download.
    (Click My Account in the upper right corner of the page.)
    If you don't have an account, you can register for one; the account is free.
  2. In the Magento Community Edition Patches section, locate the patch to install.
  3. From the list next to the patch, choose your CE version.
  4. Click Download.
  5. After the patch downloads, continue with How to Apply a Magento Patch.

Getting Magento EE Patches

To get patches for Magento EE:

  1. Log in to magentocommerce.com.
    (Click My Account in the upper right corner of the page.)
  2. Click Downloads in the left pane.
  3. Click Magento Enterprise Edition in the right pane.
    The following figure shows an example.
  4. Click Support Patches.
  5. Locate the patch to download.
  6. Click Download corresponding to the patch for the version of EE you're using.
  7. After the download completes, continue with the next section.

How to Apply a Magento Patch

To apply a Magento patch:

  1. Transfer the patch .sh file to your Magento installation root directory.

    Note: This article assumes your patch file name ends in .sh. If your patch file name ends in .patch or something else, contact Magento Support before proceeding.

    For example, /var/www/html/magento.
  2. Enter the following command as a user with sufficient privileges to write to Magento files (typically, the web server user or root):
    sh patch-file-name.sh

    A message such as the following displays to confirm the patch installed successfully:
    Patch was applied/reverted successfully.
  3. To reapply ownership to the files changed by the patch:
    1. Find the web server user: ps -o "user group command" -C httpd,apache2
      The value in the USER column is the web server user name.
      Typically, the Apache web server user on CentOS is apache and the Apache web server user on Ubuntu is www-data.
    2. As a user with root privileges, enter the following command from the Magento installation directory:
      chown -R web-server-user-name .
      For example, on Ubuntu where Apache usually runs as www-data, enter
      chown -R www-data .
  4. Perform any other tasks as instructed by Magento Support.
    (For example, some patches require you to stop external services, such as the Solr search engine.)

Reverting the Patch

If applying the patch results in errors, contact Magento Support. If you are instructed to do so, revert the patch:

  1. Change to your Magento installation directory.
  2. Enter the following command as a user with sufficient privileges to write to Magento files (typically, the web server user or root):
    sh patch-file-name.sh -R

Troubleshooting

If you get an error when you run the patch, use the following suggestions:

  • Verify the patch is located in your Magento installation root directory.
    Ubuntu example: /var/www/magento
    CentOS example: /var/www/html/magento
  • Verify you're running the patch with sufficient privileges.
    Typically, this means running it as the web server user or as a user with root privileges.
  • Try running the patch again.
    If problems persist, contact Magento Support.

Discussion:

Explore the Knowledge Base