Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#47430 closed defect (bug) (fixed)

wp-db: Always adds a filter on every query

Reported by: withinboredom's profile withinboredom Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: minor Version: 5.2.1
Component: Database Keywords: has-patch
Focuses: Cc:

Description

It appears that in the function placeholder_escape it adds a filter remove_placeholder_escape. It adds a filter with the priority of 0. However, has_filter doesn't return true or false, it returns the priority. Since the priority is 0, it always adds a filter on every call. This issue is minor because WP_Hook prevents the infinite loop that would occur, however, it still causes a small amount of memory to be used and causes a small performance penalty.

Attachments (2)

fix_has_filter_check.patch (746 bytes) - added by withinboredom 5 years ago.
fix_has_filter_check.2.patch (746 bytes) - added by withinboredom 5 years ago.
Previous patch was incorrect

Download all attachments as: .zip

Change History (6)

#1 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

@withinboredom
5 years ago

Previous patch was incorrect

#2 @SergeyBiryukov
5 years ago

Introduced in [42056].

#3 @SergeyBiryukov
5 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 45707:

Database: Use a strict comparison for has_filter() check in wpdb::placeholder_escape().

The filter is added with a priority of 0, so a loose comparison had an unintended effect of adding the filter on every call.

Props withinboredom.
Fixes #47430.

#4 @SergeyBiryukov
5 years ago

#48843 was marked as a duplicate.

Note: See TracTickets for help on using tickets.