WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#25011 closed enhancement (fixed)

Unnecessary foreach loops in default-filters.php

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

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 8 years ago.

Download all attachments as: .zip

Change History (4)

@Jayjdk
8 years ago

#1 @SergeyBiryukov
8 years ago

  • Type changed from defect (bug) to enhancement

#2 @nacin
8 years ago

  • Milestone changed from Awaiting Review to 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
8 years ago

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

In 25134:

Remove unnecessary loops in default-filters.php.

props Jayjdk.
fixes #25011.

Note: See TracTickets for help on using tickets.