Make WordPress Core

Opened 12 years ago

Closed 9 years ago

#16059 closed defect (bug) (worksforme)

wp_kses_split2() is private, no need to create a function with the sole purpose to call a function.

Reported by: hakre's profile hakre Owned by:
Milestone: Priority: lowest
Severity: normal Version: 3.1
Component: Formatting Keywords: has-patch dev-feedback
Focuses: Cc:

Description

In the effort to remove create_function() constructs from the file (#10623, #7363) the last one was removed in 16313 / #14424.

While the analysis in the last ticket was right that create_function() is not needed, the resolution to introduce a named function was not.

Infact the anonymous callback function has been replaced with a named callback function without taking into account, that a named callback function already exists. So a function whith its sole purpose to call another function has been introduced by the google summer of code student.

The existing functions name is wp_kses_split2(), having the needed properties. The function is marked as private and not used anywhere else in the file kses.php nor the whole core php code.

It can be safely adopted to fulfill the requirements of the callback function signature.

This saves the overhead of a function call per callback call.

Additionally passing the data needs only one entry in the symbol table by using an array.

Attachments (3)

16059.patch (1.8 KB) - added by hakre 12 years ago.
16059.2.patch (3.2 KB) - added by hakre 12 years ago.
Better callback function name, Deprecate the old function.
16059.3.patch (2.7 KB) - added by hakre 12 years ago.
Phpdocs moved.

Download all attachments as: .zip

Change History (10)

@hakre
12 years ago

#1 @hakre
12 years ago

Changeset in question: r16313 kses.php

Last edited 12 years ago by hakre (previous) (diff)

#2 @SergeyBiryukov
12 years ago

Perhaps we can also rename the resulting wp_kses_split2() function to _wp_kses_split_callback()? Seems like a more accurate name to me.

#3 follow-up: @westi
12 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Priority changed from normal to lowest

This changes the prototype of wp_kses_split2 in a backward incompatible way.

While it is marked private a plugin could be using it and changing the prototype would break that.

#4 in reply to: ↑ 3 @hakre
12 years ago

Replying to SergeyBiryukov:

Perhaps we can also rename the resulting wp_kses_split2() function to _wp_kses_split_callback()? Seems like a more accurate name to me.

&&

Replying to westi:

This changes the prototype of wp_kses_split2 in a backward incompatible way. ...

Both feedback has been addressed in the updated patch. Should the deprecated function move into that deprecated function file?

@hakre
12 years ago

Better callback function name, Deprecate the old function.

#5 @hakre
12 years ago

  • Keywords dev-feedback added

#6 @hakre
12 years ago

And what about moving the Phpdocs of the old function to the new one?

@hakre
12 years ago

Phpdocs moved.

#7 @nacin
9 years ago

  • Component changed from General to Formatting
  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.