-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not forcefully set area in template if it is already set, fixes #14968, fixes #13530 #15137
Conversation
…\Unit\Model\Design\Config\Validator
@@ -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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can $this->area
be empty and not null
? Looks like simple if (!$this->area)
is sufficient here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I knew, it is either set or null
according to the class where it is set in the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then simplify condition please. Commit amend is preferable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty and isset check are different, what should I change here? It can just be null or set and isset checks for it already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielRuf I meant that there is no reason to change if ($this->area) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isset is more strict and still correct so I think we can keep it like this.
@@ -534,10 +534,9 @@ protected function cancelDesignConfig() | |||
*/ | |||
public function setForcedArea($templateId) | |||
{ | |||
if ($this->area) { | |||
throw new \LogicException(__('Area is already set')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there any logic in this exception before? Any idea why it was introduced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was still the original code from 3 years ago which was untouched. The annotations and exception class are not correct imo but should be solved in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the blame view of the file in the original repo and you see that the code was never really touched ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielRuf Is there any patch available for temporary. I need to fix this in my Magento v.2.2.4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hitesh-wagento simply add .patch
to the pull/number URL and you get https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/15137.patch
Hi @DanielRuf. Thank you for your contribution. |
Hi guys, a small module to fix it without touching the core: https://github.com/pfortin-expertime/MageFix-Misc Enjoy ;) |
A composer patch would be better ;-) |
@DanielRuf Can you please explain in short how to apply this patch using composer-patches? I have the following in my {
"config": {
"preferred-install": "source"
},
"extra": {
"patches": {
"magento/product-community-edition": {
"Fix force switch theme": "https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/15137.patch"
}
}
}
} But I get the following errors: composer update magento/product-community-edition -vvv
- Applying patches for magento/product-community-edition
https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/15137.patch (Fix force switch theme)
Downloading https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/15137.patch
patch '-p1' --no-backup-if-mismatch -d '' < '/var/folders/n1/0cl9jxm90lg1r5qkrqnwf3580000gn/T/5b2ce62c2819b.patch'
Executing command (CWD): patch '-p1' --no-backup-if-mismatch -d '' < '/var/folders/n1/0cl9jxm90lg1r5qkrqnwf3580000gn/T/5b2ce62c2819b.patch'
patch: **** Can't change to directory : No such file or directory
patch '-p0' --no-backup-if-mismatch -d '' < '/var/folders/n1/0cl9jxm90lg1r5qkrqnwf3580000gn/T/5b2ce62c2819b.patch'
Executing command (CWD): patch '-p0' --no-backup-if-mismatch -d '' < '/var/folders/n1/0cl9jxm90lg1r5qkrqnwf3580000gn/T/5b2ce62c2819b.patch'
patch: **** Can't change to directory : No such file or directory
patch '-p2' --no-backup-if-mismatch -d '' < '/var/folders/n1/0cl9jxm90lg1r5qkrqnwf3580000gn/T/5b2ce62c2819b.patch'
Executing command (CWD): patch '-p2' --no-backup-if-mismatch -d '' < '/var/folders/n1/0cl9jxm90lg1r5qkrqnwf3580000gn/T/5b2ce62c2819b.patch'
patch: **** Can't change to directory : No such file or directory
patch '-p4' --no-backup-if-mismatch -d '' < '/var/folders/n1/0cl9jxm90lg1r5qkrqnwf3580000gn/T/5b2ce62c2819b.patch'
Executing command (CWD): patch '-p4' --no-backup-if-mismatch -d '' < '/var/folders/n1/0cl9jxm90lg1r5qkrqnwf3580000gn/T/5b2ce62c2819b.patch'
patch: **** Can't change to directory : No such file or directory
Could not apply patch! Skipping. The error was: Cannot apply patch https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/15137.patch
[ErrorException]
file_put_contents(/PATCHES.txt): failed to open stream: Permission denied |
Looks like some chown / rights issues. |
@1x0: a patch won't just work from Github, since the file paths in the patch won't match the composer installation ( You can find information about how to create, edit and apply patches using this recently introduced Knowledge Base article from Magento: https://support.magento.com/hc/en-us/articles/360005484154 |
Ah right forgot that the Git repo and composer based installs are different but we can still use app/code to overwrite the original files. Changing the file paths in the patch file should be sufficient. |
Simply forgot this one =) |
Squashed commit of the following: commit db9fa53cce1c8042caf24c855cfc18d1d948a6b8 Author: Daniel Ruf <daniel@daniel-ruf.de> Date: Thu May 10 19:18:37 2018 +0200 fix: change unit test back to test for the setForcedArea method commit af6d5c137ff57b13fbd8d6c9e097f7455f67cf7e Author: Daniel Ruf <daniel@daniel-ruf.de> Date: Thu May 10 19:10:11 2018 +0200 fix: just set the area if it is not set commit 2fd7e5d84abcdea5306f2bd81dd44b86aaa970d7 Author: Daniel Ruf <daniel@daniel-ruf.de> Date: Thu May 10 16:55:35 2018 +0200 fix: do not expect setForcedArea in unit tests for Magento\Theme\Test\Unit\Model\Design\Config\Validator commit a1bf00c10d5fc01e5e592f38472b820141a47133 Author: Daniel Ruf <daniel@daniel-ruf.de> Date: Thu May 10 16:46:04 2018 +0200 fix: do not set forced area in template, fixes magento#14968
FYI I created squashed commit that can used for composer patches: |
@ihor-sviziev : @sidolov also already did that on 16 May, you can view his commit if you scroll up a bit, see: 7019a0a And it's available on here as well: https://magento.com/tech-resources/download (MAGETWO-93036), don't know if this got communicated or something, because I only found out about that by accident. But thanks anyways! :) |
Hi @hostep, |
There should be just one file changed. Do you use Magento 2.2.5? |
Only |
@DanielRuf sure, just take a look at https://github.com/magento/magento2/commit/7019a0a1392095185505ff3ca7b97dd3e9cb4ef2.patch - it contains all changes form all commits - adds changes to magneto theme, removes changed files in magento theme and adds changes to magneto email. |
Try https://github.com/magento/magento2/pull/15137.diff if the other one is problematic. |
Also the other should be problematic, the result should be the same (in general). |
Description
This reverts the addition of the enforced area in d3aef7c which caused #14968 and introduced this regression
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist