WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 2 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:

Description

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

Attachments (1)

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

Download all attachments as: .zip

Change History (9)

johnbillion3 years ago

comment:1 johnbillion3 years ago

  • Keywords has-patch added

comment:2 follow-up: scribu3 years ago

  • Keywords reporter-feedback added

Could you list those uses by any chance?

comment:3 in reply to: ↑ 2 johnbillion3 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.

comment:4 nacin2 years ago

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

comment:5 nacin2 years ago

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

comment:6 nacin2 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.

comment:7 nacin2 years ago

In [19608]:

Update since. see #18845.

comment:8 nacin2 years ago

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