Apply Magento2 Patch manually using GIT
The best easy way is to simulate the directory path, so lets assume you will need to fix the comparison page after you upgrade to Magento 2.3.5-p2
Filename: vendor/magento/module-catalog/Helper/Output.php
we need to replace this line
- if (preg_match($pattern, $attributeHtml)) {
with this line
+ if (preg_match($pattern, (string) $attributeHtml)) {
Now create those directories vendor/magento/module-catalog/Helper
copy the file Output.php to that directory
create a copy from Output.php and rename it to OutputModified.php
do your changes (in our case it is only replace the above line) by this command
diff -u vendor/magento/module-catalog/Helper/Output.php vendor/magento/module-catalog/Helper/OutputModified.php > m2-hotfixes/your-fix.patch
after execute this command you will have the file your-fix.patch,
now open the patch and rename OutputModified.php with Output.php
and that's it now you can execute this to apply the patch
git apply m2-hotfixes/your-fix.patch
Note: you might need to open the patch and add "/" to the first of the paths
also you can ready here