Closed
Description
Preconditions (*)
When customer opens url with trailing slash and query string like http://magento-host.com/some-url-key/?foo=bar, Magento redirects to url without trailing slash and truncates query string, so customer is redirected to http://magento-host.com/some-url-key.
- Magento version 2.2.5 or 2.2.6
- No customizations for the store, Luma + Sample Data
Steps to reproduce (*)
- Open any product or category page.
- Manually add
/?foo=bar&bar=baz
to the url and open this link
Expected result (*)
- After the page has been loaded, query string remain in url
Actual result (*)
- Query string is removed from url
Additional information
- The issue is not reproduced when we avoid using url rewrites, e.g. http://magento-host.com/catalog/product/view/id/{product-id}/?foo=bar&bar=baz, and actually there is no redirect in this case.
- The issue seems to be happen in \Magento\UrlRewrite\Model\Storage\DbStorage::doFindOneByData
$data[UrlRewrite::REQUEST_PATH] = [
rtrim($requestPath, '/'),
rtrim($requestPath, '/') . '/',
];
We are looking for both urls (with trailing slash and without it), but when verifying the result from database we do not check it.
// If request path matches the DB value or it's redirect - we can return result from DB
$canReturnResultFromDb = ($resultFromDb[UrlRewrite::REQUEST_PATH] === $requestPath || in_array((int)$resultFromDb[UrlRewrite::REDIRECT_TYPE], $redirectTypes, true));
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.4-develop branchGate 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.2 releaseThe issue has been reproduced on latest 2.3 release