Perform feature flag change and redirection in the same request (#38833)

* Perform feature flag change and redirection in the same request

* Add changelog file

* Remove feature related query args after enabling/disabling it

* Use REQUEST_URI instead of referred one

* Fix lint errors

* Move phpcs to new line

* Use isset instead of empty

---------

Co-authored-by: Nathan Schneider <nsschneider1@gmail.com>
Co-authored-by: Lourens Schep <lourensschep@gmail.com>
This commit is contained in:
Maikel David Pérez Gómez 2023-07-04 11:06:40 -04:00 committed by GitHub
parent ed5737ba87
commit 11541583e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Perform feature flag change and redirection in the same request and remove feature related query args after enabling/disabling it

View File

@ -1152,8 +1152,9 @@ class FeaturesController {
$query_params_to_remove[] = $feature_id;
}
}
if ( count( $query_params_to_remove ) > 1 ) {
wp_safe_redirect( remove_query_arg( $query_params_to_remove, wp_get_referer() ) );
if ( count( $query_params_to_remove ) > 1 && isset( $_SERVER['REQUEST_URI'] ) ) {
// phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
wp_safe_redirect( remove_query_arg( $query_params_to_remove, $_SERVER['REQUEST_URI'] ) );
}
}
}