Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#48843 closed defect (bug) (duplicate)

wpdb::placeholder_escape fails to conditionally add a remove_placeholder_escape hook to query

Reported by: pcfreak30's profile pcfreak30 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8.3
Component: Database Keywords:
Focuses: Cc:


Found this edge case issue while doing some hacking around the wp hook structures/API.

You have:

if ( ! has_filter( 'query', array( $this, 'remove_placeholder_escape' ) ) ) {
                        add_filter( 'query', array( $this, 'remove_placeholder_escape' ), 0 );

However, has_filter returns the priority of hook if it exists, which happens to be 0... 0 is falsely in PHP, so every call to placeholder_escape re-sets the array hook ad add_filter doesn't do an exists check, and not sure it even should?

Since we are adding to a priority 0, we need to do a strict #!php false !== .

I will probably submit a patch shortly.

The function in question was committed with the bug in ticket #41925.

Change History (2)

#1 @pcfreak30
5 years ago

Woops, I mean

false ===

#2 @SergeyBiryukov
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Thanks for the report, this was fixed in [45707] / #47430 for WordPress 5.3.

Note: See TracTickets for help on using tickets.