[wp-trac] [WordPress Trac] #41036: wp_redirect and wp_safe_redirect calls fails in WP 4.8

WordPress Trac noreply at wordpress.org
Sat Jun 17 03:14:04 UTC 2017


#41036: wp_redirect and wp_safe_redirect calls fails in WP 4.8
-------------------------------+------------------------------
 Reporter:  dkurth             |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Administration     |     Version:  4.8
 Severity:  critical           |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------
Changes (by dkurth):

 * severity:  normal => critical


Comment:

 Replying to [comment:1 dd32]:
 > Hi @dkurth and welcome to Trac,
 >
 > Can you please provide some extra details as to the problem you're
 running into?
 >
 > Based on your comment in #41006 it sounds like calling
 `wp_redirect()`/`wp_safe_redirect()` isn't performing a redirect at all -
 would that be correct?
 >
 > In testing, I can't find any issues - which makes me think this may not
 be `wp_redirect()` failing (although it could be) but possibly related to
 the code you're using to trigger it.
 >

 I did some more work with this problem, making my plugin a very very
 simple couple of lines.  My site is also the latest wordpress.  Any sight
 you can give me with why these few lines causes the following, would be
 appreciated:

 function mmd_ca_redirect_func()
 {
 ob_start();
 $RedirectURL = 'https://www.mmd-ca.com/';
 $location = wp_sanitize_redirect($RedirectURL);
 //header("Location: 'https://www.mmd-ca.com/'", true, 302);
 <-------CRASHES WITH THE ERROR BELOW:
 wp_redirect($location); <--------- NOTHING HAPPENS
 }
 add_shortcode( 'mmd_redirect', 'mmd_ca_redirect_func' );

 ERROR RECEIVED: Warning: Cannot modify header information - headers
 already sent by

 Cam be seem on page: https://mmd-ca.com/test-page/


 All this started happening after the last upgrade.
 > Can you provide a small bit of code to reproduce what you're seeing?
 > Can you verify it against a clean no-plugins WordPress install?
 > Is it triggered specifically by a plugin? (If so, what one?)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41036#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list