Make WordPress Core

Opened 12 years ago

Closed 3 months ago

#21321 closed enhancement (invalid)

Remove is_null() checks in apply_filters(), do_action(), et al.

Reported by: nacin's profile nacin Owned by: nacin's profile nacin
Milestone: Priority: normal
Severity: normal Version:
Component: Plugins Keywords: dev-feedback
Focuses: performance Cc:


In apply_filters(), do_action(), and friends, there is a check for ! is_null( $the['function'] ). As these functions get called collectively thousands of times per page, a tiny check like this can add up.

A few months ago, I decided to track it down. They were shuffled around a bit in [4955], but they actually had roots in [1394]. The link there ( is dead, but I found it at, via

The original bug was that remove_filter() left NULL's in the $wp_filter array, rather than properly unsetting it as it was modified to do long ago. Now that we no longer leave NULL scattered about, this check is safe to remove.

Change History (9)

#1 @nacin
12 years ago

This requires either #21169 or a change to remove_filter().

#2 @nacin
12 years ago

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

In [21287]:

Remove unnecessary is_null() checks from the worker loops inside do_action(), apply_filters(), etc. fixes #21321. see #21169.

#12 @nacin
12 years ago

In [21299]:

Revert [21287] until #21169 goes through. see #21321.

#13 @nacin
12 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Some side effects here, due to our janky current() loop and self-removal of actions. see [UT935]

#14 @nacin
12 years ago

  • Milestone changed from 3.5 to Future Release

#15 @nacin
10 years ago

  • Component changed from Performance to Plugins
  • Focuses performance added

#16 @DrewAPicture
9 years ago

@nacin: Do we still need to handle this?

#17 @johnbillion
9 years ago

  • Keywords dev-feedback added

This might be mooted by #17817, but FWIW null !== $x is marginally faster than ! is_null( $x ). On 10,000 iterations you save around 200ms.

#18 @pbearne
3 months ago

  • Resolution set to invalid
  • Status changed from reopened to closed

PLugin.php got a rewrite this is now invalid

Note: See TracTickets for help on using tickets.