Important
You are browsing the documentation for version 4.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.
See our Release Process documentation for more information on the currently supported and upcoming releases.
How to Apply Patches¶
Apply Patches During Deployment¶
To unify the process of applying patches during application deployment, the maintenance agent is configured to do it once the code is deployed and the composer install is completed.
1deployment:
2 after_composer_install_commands:
3 - bash -c 'if [[ -d patch ]]; then ls patch | grep ".patch$" | xargs -I{} bash -c "patch -p0 < patch/{}"; fi'
If you need to apply patches to the application, create a patch directory in the root repository location and insert in it appropriate files with the “.patch”. extension
Keep in mind that if your application supports patch application on its own (for example via a specific bundle), you need to make sure there are no conflicts between these approaches and the same patch is not applied twice.
Note: Use the following command to make sure that the patch is correct and can be applied before deploying it into the production:
1patch -p0 < patch/file.patch
Apply Patches to a Deployed Application¶
In order to unify the process of applying patches during application deployment, the maintenance agent has the functionality for applying/reverting patches.
Use the following commands to work with patches:
patch:list - shows the list of applied patches to the current application deployment
1➤ Executing task patch:list
2+---------------------+----------------------------------+------------+
3| DATE | HASH (md5) | PATCH |
4+---------------------+----------------------------------+------------+
5| 2018-10-16 17:18:29 | b3d1e7ea5c476f0dba0b7588a8a93b70 | test.patch |
6+---------------------+----------------------------------+------------+
Note
Please note that the value in the HASH (md5)
column is used for the patch:revert and patch:view commands as an argument.
patch:view - shows the content of the specified patch, requires the patch HASH as an argument.
1[ ~]$ orocloud-cli patch:view b3d1e7ea5c476f0dba0b7588a8a93b70
2➤ Executing task patch:view
3[localhost]
4Index: web/app.php
5IDEA additional info:
6Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
7<+>UTF-8
8===================================================================
9--- web/app.php (date 1536073001000)
10+++ web/app.php (date 1539170812000)
11@@ -1,5 +1,9 @@
12 <?php
13
14+echo 'testing patches';
15+die();
16+
17+
18 use Symfony\Component\ClassLoader\ApcClassLoader;
19 use Symfony\Component\HttpFoundation\Request;
20✔ Ok
patch:apply - applies a patch. Requires the full path to the patch file as an argument (/mnt/maint-data is suggested), by default the command runs in DRY-RUN mode, which means that changes will not be applied, only validated. Passing the –force option causes the specified patch to be physically applied against your codebase.
patch:revert - reverts a patch, requires the patch HASH and|or the full path to the patch file as an argument (/mnt/maint-data is suggested), by default the command runs in DRY-RUN mode, which means that changes will not be applied, only validated. Passing the –force option causes the specified patch to be physically reverted against your codebase.
Usage examples:
Revert by a patch hash, dry-run mode (only shows what will be done):
1orocloud-cli patch:revert b3d1e7ea5c476f0dba0b7588a8a93b70
Revert by a patch hash, force mode (patch will be physically reverted against your codebase):
1orocloud-cli patch:revert b3d1e7ea5c476f0dba0b7588a8a93b70 --force
Revert by a patch file, the case when patch file content is not available (the full path specified with the -f option)
1orocloud-cli patch:revert b3d1e7ea5c476f0dba0b7588a8a93b70 -f ~/test.patch
Revert by a patch, the case when patch hash is not shown in the patch:list (was applied with an old version of the agent or via deployment.after_composer_install_commands)
1orocloud-cli patch:revert - -f ~/test.patch