Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#18845 closed enhancement (fixed)

Introduce __return_null()

Reported by: johnbillion Owned by: nacin
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.3
Component: General Keywords: has-patch commit 3.4-early
Focuses: Cc:


I've recently had some uses for __return_null().

Attachments (1)

18845.patch (592 bytes) - added by johnbillion 7 years ago.

Download all attachments as: .zip

Change History (9)

7 years ago

#1 @johnbillion
7 years ago

  • Keywords has-patch added

#2 follow-up: @scribu
7 years ago

  • Keywords reporter-feedback added

Could you list those uses by any chance?

#3 in reply to: ↑ 2 @johnbillion
7 years ago

  • Keywords reporter-feedback removed

Replying to scribu:

Could you list those uses by any chance?

Sure. The transient API and the options API let you short-circuit values using the pre_transient_{transient} and pre_option_{option} filters. __return_null() allows a null short circuit value. __return_false() can't be used because the short circuits use === to check for false.

#4 @nacin
7 years ago

  • Keywords commit 3.4-early added
  • Milestone changed from Awaiting Review to Future Release

#5 @nacin
6 years ago

I doubt there's much of a use case for returning null but it's nice to have the consistent function.

#6 @nacin
6 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [19607]:

Add __return_null() to complement the existing true, false, zero, and empty array methods. props johnbillion, fixes #18845.

#7 @nacin
6 years ago

In [19608]:

Update since. see #18845.

#8 @nacin
6 years ago

  • Milestone changed from Future Release to 3.4
Note: See TracTickets for help on using tickets.