-
Notifications
You must be signed in to change notification settings - Fork 82
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
Fix/189 ignore query params #196
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the coding style check is failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@braders It works! I added some comments to improve code readability.
inc/classes/class-srm-redirect.php
Outdated
if ( ! empty( $parsed_requested_path['path'] ) ) { | ||
$normalized_requested_path_no_query = untrailingslashit( stripslashes( $parsed_requested_path['path'] ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$parsed_requested_path['path']
will be always exist because the #normalized_requested_path
variable is not empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unfortunately not correct, as our debug log is getting flooded with undefined index warnings: Undefined index: path in .../plugins/safe-redirect-manager/inc/classes/class-srm-redirect.php on line 121
We're not yet sure what's wrong exactly, but it's clear that there's an issue here.
inc/classes/class-srm-redirect.php
Outdated
$parsed_requested_path = parse_url( $normalized_requested_path ); | ||
} | ||
|
||
if ( is_array( $parsed_requested_path ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$parsed_requested_path
is always an array, so this is always true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
inc/classes/class-srm-redirect.php
Outdated
$normalized_requested_path_no_query = ''; | ||
$requested_query_params = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated variables declaration.
IMO, we can safely use $parsed_requested_path
without declaring
intermediate variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your great work @braders, LGTM 🎉
Now that its been a few months I was just wondering if there is any update on when this might be merged? Thanks! |
Description of the Change
This fixes #189.
In short, if the redirect is simple (i.e. not regex) and the redirect_from field does not contain query parameters, then any query parameters will be ignored when doing the matching. Any ignored query parameters will be appended to the eventual $redirect_to, to maintain marketing params.
Possible Drawbacks
This is a possible breaking change, but I consider it unlikely that anyone would be relying on the previous behaviour. Users who want to keep the existing behaviour can use the new
srm_match_query_params
filterVerification Process
phpunit
tests.Checklist:
Applicable Issues
#189