WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 4 months ago

Last modified 6 days ago

#47430 closed defect (bug) (fixed)

wp-db: Always adds a filter on every query

Reported by: withinboredom Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: minor Version: 5.2.1
Component: Database Keywords: has-patch
Focuses: Cc:
PR Number:

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 6 months ago.
fix_has_filter_check.2.patch (746 bytes) - added by withinboredom 6 months ago.
Previous patch was incorrect

Download all attachments as: .zip

Change History (6)

#1 @SergeyBiryukov
6 months ago

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

@withinboredom
6 months ago

Previous patch was incorrect

#2 @SergeyBiryukov
4 months ago

Introduced in [42056].

#3 @SergeyBiryukov
4 months 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
6 days ago

#48843 was marked as a duplicate.

Note: See TracTickets for help on using tickets.