Make WordPress Core

Opened 14 years ago

Closed 12 years ago

Last modified 12 years ago

#17472 closed defect (bug) (duplicate)

wp_redirect() should return true on success

Reported by: draca's profile draca Owned by: draca's profile draca
Milestone: Priority: normal
Severity: minor Version: 1.5.1
Component: General Keywords:
Focuses: 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)

pluggable.diff (337 bytes) - added by draca 14 years ago.
Patch for pluggable.php

Download all attachments as: .zip

Change History (5)

@draca
14 years ago

Patch for pluggable.php

#1 @duck_
14 years ago

How about doing this?

if ( wp_redirect($redirect_url) === false ) {
  // Handle redirect failure
}

#2 @draca
14 years ago

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.

#3 @c3mdigital
12 years ago

  • Keywords has-patch removed
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version changed from 3.1.2 to 1.5.1

Fixed in r24996 Marking as duplicate of #24969 since it has already been committed.

#4 @SergeyBiryukov
12 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.