michaelryanmcneill / shibboleth

Shibboleth plugin for WordPress
https://wordpress.org/plugins/shibboleth/
19 stars 11 forks source link

Incorrect redirect_to URL since WordPress 6 #86

Closed caosborne89 closed 1 year ago

caosborne89 commented 1 year ago

I realize that Wordpress 6 is not officially supported at the moment, but I thought I'd mention a bug I found since upgrading. Our Shibboleth login button URL used to be correct. The URL used to include a redirect_to parameter value with the sites URL with the path /wp/wp-admin/ in it. Since upgrading it's just the home URL.

I think the issue is here https://github.com/michaelryanmcneill/shibboleth/blob/f9bae4445778cd00a61a40942abeba5799a2ea8b/shibboleth.php#L962. $wp->request used to have a default value of NULL, but since Wordpress 6 it seems the default value is an empty string (just var dumping the $wp object). When that function used to be called on our site $url used to be false, so the call to add_query_arg used to use $_SERVER['REQUEST_URI'] as the default (according to their documentation here). Now that if statement code block is being executed, so $url is getting set to the home URL.

jrchamp commented 1 year ago

Hi @caosborne89

Please try changing that line to:

 if ( ! empty( $wp->request ) ) { 

If it starts working, please let us know.

jakeparis commented 1 year ago

Hello, I was working to solve this same problem and came across this issue. I implemented the if( ! empty( $wp->request ) ) fix, and it works as expected. I would love to see this in an update soon!

jrchamp commented 1 year ago

I'm using the plugin on WordPress 6.1.1, but I'm not able to reproduce the issue. Did WordPress revert the change or how can I reproduce the issue?