0

Applying patch to v2.2.4 for Github issue 14968, but I keep getting hunk fails error.

After looking Looking here: SUPEE-9767 - Hunk #1 FAILED at 225. 1 out of 1 hunk FAILED I believe the problem is that the hunk lines do not match.

composer -v install && composer update --lock


Gathering patches for root package.
Removing package magento/module-email so that it can be re-installed and re-patched.
  - Removing magento/module-email (100.2.2)
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Dependency resolution completed in 0.015 seconds
Analyzed 631 packages to resolve dependencies
Analyzed 4077 rules to resolve dependencies
Package operations: 1 install, 0 updates, 0 removals
Installs: magento/module-email:100.2.2
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
Found 1 patches for magento/module-product-video.
Found 1 patches for magento/module-email.
  - Installing magento/module-email (100.2.2): Loading from cache
 Extracting archive  - Applying patches for magento/module-email
    patches/composer/github-issues-14968.diff (ENGCOM-1516: fix: do not set forced area in template)
patch '-p1' --no-backup-if-mismatch -d '/home/www/projects/magento2/house-uk/src/vendor/magento/module-email' < '/home/www/projects/magento2/house-uk/src/patches/composer/github-issues-14968.diff'
can't find file to patch at input line 5

Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php
|index fa9d28074bf8..81e993fad76d 100644
|--- a/app/code/Magento/Email/Model/AbstractTemplate.php
|+++ b/app/code/Magento/Email/Model/AbstractTemplate.php
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.

1 out of 1 hunk ignored

patch '-p0' --no-backup-if-mismatch -d '/home/www/projects/magento2/house-uk/src/vendor/magento/module-email' < '/home/www/projects/magento2/house-uk/src/patches/composer/github-issues-14968.diff'
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php
|index fa9d28074bf8..81e993fad76d 100644
|--- a/app/code/Magento/Email/Model/AbstractTemplate.php
|+++ b/app/code/Magento/Email/Model/AbstractTemplate.php
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
1 out of 1 hunk ignored

patch '-p2' --no-backup-if-mismatch -d '/home/www/projects/magento2/house-uk/src/vendor/magento/module-email' < '/home/www/projects/magento2/house-uk/src/patches/composer/github-issues-14968.diff'
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php
|index fa9d28074bf8..81e993fad76d 100644
|--- a/app/code/Magento/Email/Model/AbstractTemplate.php
|+++ b/app/code/Magento/Email/Model/AbstractTemplate.php
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.

1 out of 1 hunk ignored

patch '-p4' --no-backup-if-mismatch -d '/home/www/projects/magento2/house-uk/src/vendor/magento/module-email' < '/home/www/projects/magento2/house-uk/src/patches/composer/github-issues-14968.diff'
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php
|index fa9d28074bf8..81e993fad76d 100644
|--- a/app/code/Magento/Email/Model/AbstractTemplate.php
|+++ b/app/code/Magento/Email/Model/AbstractTemplate.php
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.

1 out of 1 hunk ignored

   Could not apply patch! Skipping. The error was: Cannot apply patch patches/composer/github-issues-14968.diff

I have 3 options:

  1. Modify the composer patch.
  2. Use Magento Patch (required upgrade 2.2.4 > 2.2.5) before apply.
  3. Create a plugin around / overwrite app/code/Magento/Email/Model/AbstractTemplate in custom module.

Not sure the best route to take here.

1 Answer 1

3

In the case of this issue vs my install. Problem was composer based install of the site so the answer was to modify patch for me:

Problem

diff --git a/vendor/magento/module-email/Model/AbstractTemplate.php b/vendor/magento/module-email/Model/AbstractTemplate.php
index fa9d28074bf8..81e993fad76d 100644
--- a/app/code/Magento/Email/Model/AbstractTemplate.php
+++ b/app/code/Magento/Email/Model/AbstractTemplate.php
@@ -534,10 +534,9 @@ protected function cancelDesignConfig()
     */
    public function setForcedArea($templateId)
    {
-        if ($this->area) {
-            throw new \LogicException(__('Area is already set'));
+        if (!isset($this->area)) {
+            $this->area = $this->emailConfig->getTemplateArea($templateId);
        }
-        $this->area = $this->emailConfig->getTemplateArea($templateId);
        return $this;
    }

Solution

Replace:

app/code/Magento/Email/Model/AbstractTemplate.php

With the correct path to composer install

vendor/magento/module-email/Model/AbstractTemplate.php

Then, remove the “git --diff” and “index” lines:

diff --git a/vendor/magento/module-email/Model/AbstractTemplate.php b/vendor/magento/module-email/Model/AbstractTemplate.php
index fa9d28074bf8..81e993fad76d 100644

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.