Skip to content
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

Going to '/admin' while using storecodes in url and a different adminhtml url will throw exception #11140

Closed
koenner01 opened this issue Sep 29, 2017 · 7 comments
Assignees
Labels
Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@koenner01
Copy link
Contributor

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

  1. PHP7.0
  2. M2.1.9 CE (we also tested 2.1.7 CE and 2.2.0 CE)

Steps to reproduce

  1. use a different url than 'admin' for the adminhtml
  2. set 'Stores' > 'Configuration' > 'General' > 'Web' > 'Add Store Code to Urls' to 'Yes'
  3. go to '/admin' url

Expected result

  1. Page should go to the no-route or at least show 404

Actual result

  1. 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

@koenner01
Copy link
Contributor Author

This was already reported in #9947 but closed because of 'inability to reproduce'

@magento-engcom-team magento-engcom-team added Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Sep 29, 2017
@magento-engcom-team
Copy link
Contributor

@koenner01, thank you for your report.
We've created internal ticket(s) MAGETWO-80591 to track progress on the issue.

@sylvainraye
Copy link
Contributor

I'm working on it #SQUASHTOBERFEST

@okorshenko
Copy link
Contributor

The issue has been fixed and delivered to 2.2-develop branch. Will be available with 2.2.2 release

@okorshenko okorshenko added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Oct 18, 2017
@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-81995

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Jan 27, 2018
@magento-engcom-team
Copy link
Contributor

Hi @koenner01. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1289 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming patch release.

@sidolov
Copy link
Contributor

sidolov commented Jul 31, 2018

Hi @koenner01. Thank you for your report.
The issue has been fixed in #17243 by @mageprince in 2.1-develop branch
Related commit(s):

The fix will be available with the upcoming 2.1.15 release.

@sidolov sidolov added the Fixed in 2.1.x The issue has been fixed in 2.1 release line label Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

6 participants