WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#5326 closed defect (bug) (fixed)

Don't use sanitize_title in widgets API

Reported by: ryan Owned by:
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.5
Component: General Keywords: performance
Focuses: Cc:

Description

widgets.php calls sanitize_title() on widget IDs. For the new API (functions starting with wp_), this isn't necessary. sanitize_title() is a slow function that does lots of stuff we don't need to do when sanitizing an ID. Let's just drop the sanitization and take the ID as is. For the old widgets API (functions without wp_), the sanitization can stay for maximum back-compat.

Attachments (1)

sanitize_widgets.diff (695 bytes) - added by ryan 6 years ago.

Download all attachments as: .zip

Change History (3)

ryan6 years ago

comment:1 ryan6 years ago

This patch reduced the number of calls to sanitize_title() from 103 to 2 on my testbed. The amount of time spent in sanitize_title() dropped from almost 10% to a fraction of a percent.

comment:2 ryan6 years ago

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

(In [6323]) Don't run sanitize_title on IDs in new widgets API to avoid performance overhead. fixes #5326

Note: See TracTickets for help on using tickets.