[Issue] Magento_Backend store switcher: Use nowdoc instead of heredoc #32262
Labels
Component: Backend
Issue: Confirmed
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed
Priority: P2
A defect with this priority could have functionality issues which are not to expectations.
Progress: done
Reported on 2.4.x
Indicates original Magento version for the Issue report.
Reproduced on 2.4.x
The issue has been reproduced on latest 2.4-develop branch
Severity: S2
Major restrictions or short-term circumventions are required until a fix is available.
Projects
This issue is automatically created based on existing pull request: #32249: Magento_Backend store switcher: Use nowdoc instead of heredoc
Description (*)
The heredoc in Magento/Backend/view/adminhtml/templates/store/switcher.phtml#L203-L216 is not valid, because the embedded JavaScript contains
$this
, which happens to be a valid variable name in PHP, too. Consequently, PHP tries to replace its occurrences by the current class object which results in an error. This can be avoided by using nowdoc instead of heredoc, which is the aim of this PR.In Magento core, the
is*using_iframe
flag is never set. As a consequence, the else-branch in [Magento/Backend/view/adminhtml/templates/store/switcher.phtml#L203-L216](https://github.com/magento/magento2/blob/896f0d6/app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml#L203-L216] is never called, so the error does not occur in a standard environment. However, we use Amasty's [_Improved Layered Navigation*|https://amasty.com/improved-layered-navigation-for-magento-2.html), which sets this flag to true for one of their backend configurations. The resulting error (in developer mode) looks as follows:Related Pull Requests
Two years ago, there was #20656 to replace all heredoc by nowdoc, but it was closed.
Fixed Issues (if relevant)
No separate issue created.
Preconditions (*)
Magento 2.4-develop
Steps to reproduce (*)
For reproducing this error, it is not necessary to install Magento or the referenced Amasty extension at all. Simply paste the snippet into a fresh PHP file
test.php
:Expected Result
No errors appear in the Admin panel. The Scope can be changed.
The text was updated successfully, but these errors were encountered: