-
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
On separate admin domain, reviews are not saved with correct store ID #17510
Comments
Hi @CNanninga. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
where @CNanninga do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
Hello @CNanninga, thank you for your report. I cannot reproduce this issue. |
@CNanninga, we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue. |
@engcom-backlog-nickolas: can you please test this again, by not using a subdomain for the admin domain, but an actually different domain? Subdomains inherit the cookies from the main domain, so in this case the bug probably won't trigger. (I'm not saying the bug exists, I'm just saying you didn't follow the exact steps to reproduce, because in the example of @CNanninga he didn't use a subdomain) |
@engcom-backlog-nickolas - I'd also point out that it would be helpful if your demonstration could also include explicitly checking the value of the "store" cookie. If it's "admin" when you are editing the review in the admin, I believe the bug will occur. (We actually did use a sub-domain for admin, but our Nginx configuration is set to explicitly set a Magento run code for the admin store on that sub-domain, so we do end up with a different cookie value, specifically associated with the admin.site.com domain.) Haven't yet had a chance to do all the local setup required (including the aforementioned Nginx configuration) to verify this on a vanilla install. And I don't think getting an auto-deployed instance via the Git comment would help, as I assume there wouldn't be a way to set it up with a separate admin domain. |
@CNanninga, we cannot reproduce the issue by the steps you provided. |
@engcom-backlog-pb - Thanks for the demo. Clearly in your reproduction steps, the value of your store cookie is still "default" even though you're browsing the separate admin domain. How do you have your server configuration configured to accomplish this? We have Nginx configuration for the admin-specific domain that sets the environment variable MAGE_RUN_TYPE to "store" and MAGE_RUN_CODE to "admin." This results in the cookie value being "admin." (And I'd add that it doesn't seem like having a store cookie with the value "admin" when browsing the admin should be considered an invalid state.) |
@CNanninga, I'm using Apache, not nginx, and I cannot help you with nginx configuration. Anyway, the problem with nginx is not a Magento 2 core issue, so I believe this ticket should be closed. |
@engcom-backlog-pb - You don't need to give me Nginx-specific instructions. I would still very much appreciate you elaborating on how you are setting up the separate admin domain to resolve to the admin. Are you setting MAGE_RUN_TYPE and MAGE_RUN_CODE environment variables to the admin store, or using some other mechanism? |
@CNanninga, I have made no specific settings for admin store. Only changed ServerName for VirtualHost. |
@engcom-backlog-pb - Then there are some additional reproduction steps. We are not just pointing two different domains to the same install and just browsing to /backend on one but not the other. We are locking down the admin domain so that it will always (and only) load the admin. For full reproduction steps, please make sure you have configuration like the following in the array in env.php:
… and set the value of MAGE_RUN_TYPE to "store" and the value of MAGE_RUN_CODE to "admin" via server configuration (it doesn't matter whether it's Nginx or Apache). |
@CNanninga, thank you for update. |
Hi @engcom-Kilo. Thank you for working on this issue.
|
✅ Confirmed by @engcom-Bravo Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself. |
Preconditions
Steps to reproduce
Expected result
Actual result
Additional information
Under the hood, this is a result of the user's "store" cookie being used (incorrectly) to derive the appropriate store context in many areas of the admin.
In \Magento\Review\Block\Adminhtml\Edit\Form::prepareForm, a check is made for whether there is only a single store on the Magento install. If not, a visible stores multi-select is added to the form, and this issue does not occur. If it _is a single store install, only a hidden input with the store ID is added to the form.
The value given to this hidden input is not derived from the store actually associated with the review. It is derived from \Magento\Store\Model\StoreManager::getStore (with no store ID passed in), which in turn gets the store ID from \Magento\Store\Model\StoreResolver::getCurrentStoreId. This method gets the store ID from a request param if it exists (it doesn't in this case), or else gets it from the "store" cookie.
If the admin is on the same domain as the front-end (e.g., www.example.com/backend), this ends up working. If the admin is on a different domain and therefore the Magento run code has been directly set to the admin store code, this cookie has the ID 0.
The text was updated successfully, but these errors were encountered: