Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#25011 closed enhancement (fixed)

Unnecessary foreach loops in default-filters.php

Reported by: Jayjdk Owned by: nacin
Priority: normal Milestone: 3.7
Component: General Version: 2.2.3
Severity: minor Keywords: has-patch
Cc: Focuses:

Description

In two cases, defaults-filters.php runs a foreach loop even through there's only one item in the array.
I don't know if it's just me but that seems unnecessary.

// Slugs
foreach ( array( 'pre_term_slug' ) as $filter ) {
	add_filter( $filter, 'sanitize_title' );
}

...

// Format for RSS
foreach ( array( 'term_name_rss' ) as $filter ) {
	add_filter( $filter, 'convert_chars' );
}

Slugs code introduced in [5937] and the feed code in [5979].
The code was last changed in [12041].

Attachments (1)

25011.patch​ (839 bytes ) - added by Jayjdk 13 years ago.

Download all attachments as: .zip

Change History (4)

@Jayjdk
13 years ago

#1 @SergeyBiryukov
13 years ago

  • Type defect (bug) → enhancement

#2 @nacin
13 years ago

  • Milestone Awaiting Review → 3.7

I imagine this was done to make it easy to add elements here in the future. Given the lack of changes in the last 6.5 years, I think it is safe to go ahead with 25011.patch​.

For those laughing at [12041], you may enjoy the follow-up more: [12042].

#3 @nacin
13 years ago

  • Owner set to nacin
  • Resolution → fixed
  • Status new → closed

In 25134:

Remove unnecessary loops in default-filters.php.

props Jayjdk.
fixes #25011.

Note: See TracTickets for help on using tickets.