Skip to content

[FIXES] #20309: URL Rewrites redirect loop #25848

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

Conversation

mautz-et-tong
Copy link
Contributor

Description (*)

This adds a meaningful exception if request path equals target path on url rewrite edit page in admin

Fixed Issues (if relevant)

  1. URL Rewrites redirect loop #20309: URL Rewrites redirect loop

Manual testing scenarios (*)

  1. Go To Admin -> Marketing -> Url Rewrites.
  2. Create a new Url Rewrite with request-path: foo and target_path foo with 301 or 302 redirect.
  3. Click Save
  4. An error message should appear with "The request path and the target path should differ to prevent an infinite redirecion loop."

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

This adds a meaningful exception if request path equals target path on url rewrite edit page in admin
@mautz-et-tong mautz-et-tong requested a review from kokoc as a code owner November 29, 2019 13:54
@m2-assistant
Copy link

m2-assistant bot commented Nov 29, 2019

Hi @mautz-et-tong. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@ihor-sviziev ihor-sviziev added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Nov 29, 2019
Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

Hi @mautz-et-tong,
Your changes looks good to me.

Could you cover your changes with some tests?

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

Actually I remembered that such PR we already had in #20313 (review).

With this solution we have few issues:

  1. If such URL rewrite was created before these changes introduced - issue will be persisted. In order to fix that we have two options (or both?)
  • create data patch that will find & delete all such incorrect URL rewrites
  • adjust logic to do NOT perform redirect in case of target path equal to request path
  1. URL rewrites could be created not only Magento admin, but also through custom modules, so would be better to move this validation into URL rewrite model itself.

Could you adjust your PR?

@mautz-et-tong
Copy link
Contributor Author

Actually I would do everything:

  1. create data patch that will find & delete all such incorrect URL rewrites (maybe moving to a working redirect with addition (-unique_hash) is better than a deletion?)
  2. adjust logic to do NOT perform redirect in case of target path equal to request path (the PR you mentioned should be fair enough, isn't it?)
  3. Create a model based validation to prevent this kind of redirects

@sidolov sidolov changed the base branch from 2.3-develop to 2.4-develop December 5, 2019 17:09
@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Dec 11, 2019

Hi @mautz-et-tong,
Do you have any estimates when you'll be able to update your PR?
Maybe do you have any issues?

@ihor-sviziev
Copy link
Contributor

Hi @mautz-et-tong,
I am closing this PR now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!

@m2-assistant
Copy link

m2-assistant bot commented Jan 14, 2020

Hi @mautz-et-tong, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants