Opened 2 years ago
Last modified 2 years ago
#17472 new defect (bug)
wp_redirect() should return true on success
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | General | Version: | 3.1.2 |
| Severity: | minor | Keywords: | has-patch |
| Cc: |
Description
Ticket #3250 added the ability for a filter to cancel a redirect request and returns false in that event.
On success, there is no return value specified so the function returns NULL per the PHP spec. A value of true should be returned so that logic such as the following can be used:
if (! wp_redirect($redirect_url)) {
// Handle redirect failure
}
Attachments (1)
Change History (3)
How about doing this?
if ( wp_redirect($redirect_url) === false ) {
// Handle redirect failure
}
Yes, that can be done as a workaround.
I believe the fix is still relevant as it's better to return a value that will be interpreted as true on success so the simpler form of the condition clause can be used.
Alternatively, the function could return the value of $location.
Note: See
TracTickets for help on using
tickets.

Patch for pluggable.php