Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 7 years ago

#20017 closed defect (bug) (fixed)

Reduce memory usage in kses.php

Reported by: duck_'s profile duck_ Owned by: duck_'s profile duck_
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: Performance Keywords: has-patch needs-testing
Focuses: Cc:

Description

Our allowed attributes rules in kses.php create a large number of empty arrays. These can all be replaced with true instead. This reduces memory usage by 62 kilobytes - not huge, but it all adds up.

This change is possible because the arrays are only used for attribute value checks, see wp_kses_attr(). Anything other than array just indicates that the attribute is allowed, see kses README and docs/attribute-value-checks for examples.

The block that filters style attributes with safecss_filter_attr() has to be moved out of the is_array() check to accommodate for this.

Attachments (1)

20017.diff (15.7 KB) - added by duck_ 13 years ago.

Download all attachments as: .zip

Change History (7)

@duck_
13 years ago

#1 follow-up: @nacin
13 years ago

With the patch, array() will still work, right?

#2 in reply to: ↑ 1 @duck_
13 years ago

Replying to nacin:

With the patch, array() will still work, right?

Yes.

#3 @duck_
13 years ago

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

In [19976]:

Reduce memory usage in wp-includes/kses.php by switching unnecessary empty arrays to boolean. Fixes #20017.

safecss_filter_attr() block for style tags must be moved out of the is_array() only branch of wp_kses_attr() to accommodate for this.

#4 @duck_
13 years ago

  • Milestone changed from Awaiting Review to 3.4

#5 @westi
13 years ago

Great work!

#6 @ocean90
7 years ago

In 40637:

KSES: Support 'tag' => true as a shorthand for 'tag' => array() in wp_kses_attr().

Automatic_Upgrader_Skin::feedback() had always assumed that this is already the case, now it is.

See #20017.
Fixes #40680.

Note: See TracTickets for help on using tickets.