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

Bugfix: Issue 208 wildcard redirects #217

Merged
merged 4 commits into from
Oct 20, 2020

Conversation

amyevans
Copy link
Contributor

Description of the Change

Fixes #208.

This PR fixes a regression introduced in 1.9.3 that caused paths to match erroneously against a rule ending in /*.

Alternate Designs

None.

Benefits

  • Improved handling for wildcard redirects.

Possible Drawbacks

  • Nothing immediately obvious, but there's perhaps the potential to break redirects in unforeseen scenarios not currently accounted for in test cases.

Verification Process

  • Added a test to address the case.
  • Existing tests still pass.
  • Tested within a project.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

#208

Changelog Entry

  • Fixed: Regression related to wildcard matching

@jeffpaul jeffpaul added this to the 2.0.0 milestone Sep 1, 2020
@jeffpaul jeffpaul added the type:bug Something isn’t working. label Sep 1, 2020
@jeffpaul
Copy link
Member

jeffpaul commented Sep 1, 2020

@amyevans many thanks for the PR, its greatly appreciated! We'll do a review on this and get back to you with any questions/concerns, but otherwise I've milestoned this for our next release.

Copy link
Collaborator

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

Thank @amyevans so much! Tested and this PR worked as expected! I only have a question about the unit test. Otherwise, this one is looking good to me.

srm_create_redirect( '/one/*', $redirect_to );
add_action(
'srm_do_redirect',
function( $requested_path, $redirected_to, $status_code ) use ( &$redirect_to, &$redirected, &$expected ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you explain why you pass $redirect_to and $expected here? I don't see the usage of these variables.

Copy link
Member

Choose a reason for hiding this comment

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

@amyevans are you able to explain those variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, they aren't used, just relics from copy/pasting another test as a starting point. I'll push up a new commit removing them.

@picocodes
Copy link

I don't know if this is related,

but the following redirect rule /guide/email-forms/* => /guide/getting-email-subscribers/* redirects a request for "example.com/guide/email-forms/opt-in-forms-editor/" to "example.com/guide/getting-email-subscribersopt-in-forms-editor"

Notice the missing slash.

@dinhtungdu
Copy link
Collaborator

@picocodes the issue you mentioned is fixed by this PR

Copy link
Collaborator

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@dinhtungdu dinhtungdu merged commit b1357e2 into 10up:develop Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn’t working.
Projects
None yet
4 participants