Repository navigation
[2.2.0-rc3.0] Language switcher is broken when using multiple times #10908
Copy link
Copy link
Closed
Labels
Fixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 release
Description
Preconditions
- PHP 7.0.22
Steps to reproduce
- Install Magento CE 2.2.0-rc3.0 using composer
- Switch to developer mode
- In the backend, make sure you have 2 storeviews (in my example: Dutch & English)
- Reindex & flush caches
- Load the frontend
- Using the language switcher in the header, switch from the default storeview (Dutch in my example) to English, the url changes to:
https://example.com/?___store=en - Using the language switcher in the header, switch again from English to Dutch, the url changes to:
https://example.com/?___store=en?___store=nland the shop crashes
Expected result
- The url should be
https://example.com/?___store=nland the shop shouldn't crash
Actual result
- The url is
https://example.com/?___store=en?___store=nland the shop crashes with the message:
1 exception(s):
Exception #0 (Magento\Framework\Exception\NoSuchEntityException): Requested store is not found
Exception #0 (Magento\Framework\Exception\NoSuchEntityException): Requested store is not found
#0 vendor/magento/module-store/Model/StoreManager.php(168): Magento\Store\Model\StoreRepository->get('en?___store=nl')
#1 vendor/magento/module-store/App/Action/Plugin/Context.php(85): Magento\Store\Model\StoreManager->getStore('en?___store=nl')
#2 vendor/magento/framework/Interception/Interceptor.php(121): Magento\Store\App\Action\Plugin\Context->beforeDispatch(Object(Magento\Cms\Controller\Index\Index\Interceptor), Object(Magento\Framework\App\Request\Http))
#3 vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cms\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#4 generated/code/Magento/Cms/Controller/Index/Index/Interceptor.php(39): Magento\Cms\Controller\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#5 vendor/magento/framework/App/FrontController.php(55): Magento\Cms\Controller\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#6 vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#7 vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#8 vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#9 vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#10 vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#11 vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#12 vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#13 generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, NULL)
#14 vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#15 vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http->launch()
#16 pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#17 {main}
Discussion
This was only very recently broken, in commit: c3ea1f5, the changes in the file lib/internal/Magento/Framework/App/Request/Http.php cause this.
Also: please change this typo from removeRepitedSlashes to removeRepeatedSlashes, so this method has the same name as in Magento 2.1
Possible solution
If we change this line from:
$requestString = $this->_url->escape(ltrim($this->_request->getRequestString(), '/'));to:
$requestString = $this->_url->escape(ltrim($this->_request->getOriginalPathInfo(), '/'));It works again as expected, but I'm not sure yet if this is the correct solution.
Metadata
Metadata
Assignees
Labels
Fixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 release
Activity
magento-engcom-team commentedon Sep 19, 2017
@hostep thank you for your bug report.
We've created internal ticket MAGETWO-75448 to track progress on the issue.
vrootwoot commentedon Sep 26, 2017
Apparently the issue only occurs from the homepage, starting working on it.
BlackIkeEagle commentedon Sep 26, 2017
@vrootwoot you still working on this? I have this issue too while I'm working on some other issue in the store switcher
vrootwoot commentedon Sep 26, 2017
@BlackIkeEagle won't have the time to fix it.
Apparently correct way would be to add changes to getTargetStorePostData
in app/code/Magento/Store/Block/Switcher.php.
And also change the entry points in the Switcher Block as well.
LuisChaves commentedon Oct 8, 2017
In addition to changing the line of code suggested by hostep, to also remove "?___ store". Change line 228 "$store->getCurrentUrl(false)," to "$this->getUrl ('stores/store/switch' ), "from the file" module-store \ Block \ Switcher.php "
selusi commentedon Oct 13, 2017
However, the bug is much more complex, because if you change the language on page of the product details or on a category page the app give a not found page, because does not translate the urlrewrite.
In the previous version Magento 2.1.9 the switcher worked fine.
1 remaining item
hostep commentedon Oct 14, 2017
@selusi: just FYI, you've changed the code back to how it was before commit 508f1ef, in this commit, they fixed the storeswitcher when you work with multiple domain names since it used to store the wrong store code in a cookie which has as a result that we ended up in an endless redirect from one domain name to the other.
It might be worth to test if it still works when switching stores with multiple domain names if you revert that line back to
$this->getUrl('stores/store/switch'), but I have the feeling that the original problem will be back if you do this.(unrelated, but this page might be worth checking out for formatting your comments on github a bit better: https://guides.github.com/features/mastering-markdown/, please check the 'code' tab in the Examples 😉)
selusi commentedon Oct 14, 2017
@hostep Thank you for the clarification. I apologize, because I did not read the commit 508f1ef you rightly mentioned.
So everything is again in question, because your code solve only a part of issue.
thiagolima-bm commentedon Oct 26, 2017
@okobchenko PR #11337
okorshenko commentedon Oct 31, 2017
the issue has been fixed and delivered to 2.2-develop branch. WIll be available with 2.2.2 release
magento-engcom-team commentedon Jan 30, 2018
Hi @hostep. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1285 by @magento-engcom-team in 2.3-develop branch
Related commit(s):
The fix will be available with the upcoming patch release.
mariamghalleb commentedon Apr 12, 2018
@magento-engcom-team the link doesn't work ..
MrDaar commentedon Apr 25, 2018
It's not good code, and it's not thoroughly tested, but here's a temp fix if you're currently experiencing this issue:
Let me know if it works for you.
⏫ Forwardport of magento#11337 to 2.3-develop branch
Merge forwardport of magento#11337 to 2.3-develop branch
🔃 [EngCom] Public Pull Requests - 2.3-develop