-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Use per-store or per-website skin if available in the error application #35095
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
base: 2.4-develop
Are you sure you want to change the base?
Conversation
Hi @fredden. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review. For more details, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run static tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
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.
I do suggest another approach the approach taken now should do as well.
@@ -186,6 +186,15 @@ public function __construct( | |||
$this->_root = is_dir($this->_indexDir . 'app'); | |||
|
|||
$this->_prepareConfig(); | |||
|
|||
if (isset($_ENV['MAGE_RUN_CODE'])) { |
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.
if (isset($_ENV['MAGE_RUN_CODE'])) { | |
if (isset($_ENV['MAGE_RUN_CODE'])) { | |
$skin = isset($_ENV['MAGE_RUN_TYPE']) ? $ENV_['MAGE_RUN_TYPE'] . '-' . $_ENV['MAGE_RUN_CODE'] : $_ENV['MAGE_RUN_CODE']; | |
$this->_setSkin($skin); | |
} |
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 way you prevent a second request of the same method _setSkin()
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.
Calling _setSkin()
multiple times (and in this order) is intentional. The _setSkin()
method includes some name validation and (importantly) an is_dir()
check. With the current implementation, a developer can create a per-website theme, even if there is a store code in the web server configuration. With the proposed implementation, a per-website theme is ignored / unusable when a store code is specified in web server configuration.
Edit: I've clearly forgotten how the code actually works; it's been a long time since I opened this pull request. The double-call allows developers to differentiate between a store-hats
and website-hats
(or store-hats
and hats
) while keeping the simple case simple with just hats
when the same theme is used in both scopes. Like with other places in Magento, the most specific option will be used.
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.
@leonhelmus would it help if I add a code comment to explain why we're calling _setSkin()
multiple times?
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
Description (*)
When Magento is unable or unwilling to process a request (eg, because maintenance mode has been enabled) the request is forwarded to the application within
pub/errors/
. This uses a different set of theme files to the main website (intentionally), but is not flexible when dealing with multi-store or multi-website configurations.This is not necessarily a problem when all the stores/website share a common theme and language. (For example, British & American & Australian stores with the same brand but different currencies / localisation will all be fine using a shared skin/theme in English for
pub/errors/
.) However, when there are multiple distinct brands being served from a single Magento instance or when different languages are being used, a single skin forpub/errors/
is not suitable.We have implemented a similar approach to what is being proposed here on websites for our merchants with good results. Here we are using the
MAGE_RUN_TYPE
andMAGE_RUN_CODE
environment variables to determine which skin / theme to use in error pages.Calling
_setSkin()
multiple times is safe. If there is no suitable skin matching the name of the store/website, then these lines have no impact, falling back to other skin-setting mechanisms like$_GET['skin']
orpub/errors/local.xml
orpub/errors/design.xml
.Related Pull Requests
Fixed Issues
None. Please feel free to create an issue if you feel this is appropriate.
Manual testing scenarios (*)
bin/magento maintenance:enable
pub/errors/
.pub/errors/local.xml.sample
topub/errors/local.xml
, andpub/errors/default/
topub/errors/custom/
, and setting<skin>custom</skin>
inpub/errors/local.xml
.pub/errors/
.pub/errors/custom/
topub/errors/es/
and translate/theme this appropriately.Questions or comments
None
Contribution checklist (*)