Skip to content

Fix #39770 The store that was requested wasn't found #39771

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core_config_data:

select * from core_config_data where path='web/url/use_store';
+-----------+---------+----------+-------------------+-------+---------------------+
| config_id | scope   | scope_id | path              | value | updated_at          |
+-----------+---------+----------+-------------------+-------+---------------------+
|       523 | default |        0 | web/url/use_store | 1     | 2024-08-29 20:49:29 |
+-----------+---------+----------+-------------------+-------+---------------------+

For the method:

public function getValidStoreCode(Http $request, string $pathInfo = '') : ?strin

Appended additional verification for the case:

$storeCode === Area::AREA_GRAPHQL

The reason:

To exclude the NoSuchEntityException:

Magento\Framework\Exception\NoSuchEntityException: The store that was requested wasn't found. Verify the store and try again.  in vendor/magento/module-store/Model/StoreRepository.php on line 75

Call Stack:
    0.0001     507288   1. {main}() pub/index.php:0
    0.0110    2907496   2. Magento\Framework\App\Bootstrap->run($application = class Magento\Framework\App\Http { ... }) pub/index.php:35
    0.0111    2919104   3. Magento\Framework\App\Http->launch() vendor/magento/framework/App/Bootstrap.php:264
    0.0111    2919104   4. Magento\Framework\App\Request\Http->getFrontName() vendor/magento/framework/App/Http.php:111
    0.0111    2919104   5. Magento\Framework\App\Request\Http->getPathInfo() vendor/magento/framework/App/Request/Http.php:219
    0.0111    2919104   6. Magento\Framework\App\Request\Http->getOriginalPathInfo() vendor/magento/framework/App/Request/Http.php:169
    0.0111    2919144   7. Magento\Backend\App\Request\PathInfoProcessor\Proxy->process($request = class Magento\Framework\App\Request\Http { ... }, $pathInfo = '/graphql') vendor/magento/framework/App/Request/Http.php:154
    0.0121    2927000   8. Magento\Backend\App\Request\PathInfoProcessor->process($request = class Magento\Framework\App\Request\Http { ... }, $pathInfo = '/graphql') generated/code/Magento/Backend/App/Request/PathInfoProcessor/Proxy.php:105
    0.0140    3653080   9. Magento\Store\App\Request\PathInfoProcessor->process($request = class Magento\Framework\App\Request\Http { ... }, $pathInfo = '/graphql') vendor/magento/module-backend/App/Request/PathInfoProcessor.php:55
    0.0140    3653080  10. Magento\Store\App\Request\StorePathInfoValidator->getValidStoreCode($request = class Magento\Framework\App\Request\Http { ... }, $pathInfo = '/graphql') vendor/magento/module-store/App/Request/PathInfoProcessor.php:42
    0.0143    3818928  11. Magento\Store\Model\StoreRepository->getActiveStoreByCode($code = 'graphql') vendor/magento/module-store/App/Request/StorePathInfoValidator.php:99
    0.0143    3818928  12. Magento\Store\Model\StoreRepository->get($code = 'graphql') vendor/magento/module-store/Model/StoreRepository.php:89


Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Magento\Framework\App\Request\PathInfo;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Framework\App\Area;
use Magento\Store\Api\StoreRepositoryInterface;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreIsInactiveException;
Expand Down Expand Up @@ -87,7 +88,12 @@ public function getValidStoreCode(Http $request, string $pathInfo = '') : ?strin
}
$storeCode = $this->getStoreCode($pathInfo);

if (empty($storeCode) || $storeCode === Store::ADMIN_CODE || !$this->storeCodeValidator->isValid($storeCode)) {
if (
empty($storeCode)
|| $storeCode === Area::AREA_GRAPHQL
|| $storeCode === Store::ADMIN_CODE
|| !$this->storeCodeValidator->isValid($storeCode)
) {
return null;
}

Expand Down