Closed
Description
If you are using an adminhtml url that is different from 'admin' and set the 'Add Store Code to Urls' to 'Yes', going to '/admin' will throw an exception
Preconditions
- PHP7.0
- M2.1.9 CE (we also tested 2.1.7 CE and 2.2.0 CE)
Steps to reproduce
- use a different url than 'admin' for the adminhtml
- set 'Stores' > 'Configuration' > 'General' > 'Web' > 'Add Store Code to Urls' to 'Yes'
- go to '/admin' url
Expected result
- Page should go to the no-route or at least show 404
Actual result
- Page tries to go to the homepage with the current store set to 'admin'
We did some debugging already and found that in \Magento\Store\App\Request\PathInfoProcessor the current store is being set to 'admin'.
public function process(\Magento\Framework\App\RequestInterface $request, $pathInfo)
{
$pathParts = explode('/', ltrim($pathInfo, '/'), 2);
$storeCode = $pathParts[0];
try {
/** @var \Magento\Store\Api\Data\StoreInterface $store */
$store = $this->storeManager->getStore($storeCode);
} catch (NoSuchEntityException $e) {
return $pathInfo;
}
if ($store->isUseStoreInUrl()) {
if (!$request->isDirectAccessFrontendName($storeCode)) {
$this->storeManager->setCurrentStore($storeCode);
$pathInfo = '/' . (isset($pathParts[1]) ? $pathParts[1] : '');
return $pathInfo;
} elseif (!empty($storeCode)) {
$request->setActionName('noroute');
return $pathInfo;
}
return $pathInfo;
}
return $pathInfo;
}
'admin' will be treated as a valid storecode because the store table in the database contains this value for the store with id 0
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.1 release lineThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.3 release lineGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.3 release