Skip to content

[2.2.0-rc3.0] Language switcher is broken when using multiple times #10908

Closed
@hostep

Description

@hostep

Preconditions

  1. PHP 7.0.22

Steps to reproduce

  1. Install Magento CE 2.2.0-rc3.0 using composer
  2. Switch to developer mode
  3. In the backend, make sure you have 2 storeviews (in my example: Dutch & English)
  4. Reindex & flush caches
  5. Load the frontend
  6. 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
  7. Using the language switcher in the header, switch again from English to Dutch, the url changes to: https://example.com/?___store=en?___store=nl and the shop crashes

Expected result

  1. The url should be https://example.com/?___store=nl and the shop shouldn't crash

Actual result

  1. The url is https://example.com/?___store=en?___store=nl and 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

No one assigned

    Labels

    Fixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions