Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#27133 closed enhancement (fixed)

Redundant type casting in wp_get_object_terms

Reported by: OriginalEXE Owned by: wonderboymusic
Priority: normal Milestone: 3.9
Component: Taxonomy Version: 3.9
Severity: minor Keywords: has-patch
Cc: Focuses:

Description

In wp_get_object_terms function (taxonomy.php), there is a redundant type casting to array after is_array() check has already been performed on that variable.

Attachments (1)

27133.patch (497 bytes ) - added by OriginalEXE 13 years ago.
Proposed improvement

Download all attachments as: .zip

Change History (6)

@OriginalEXE
13 years ago

Proposed improvement

#1 @OriginalEXE
13 years ago

  • Keywords has-patch added
  • Severity normalminor

I have attached a patch removing the unnecessary type casting. It is, however, worth considering replacing all is_array() checks with direct type casting, which appears to be faster in php.

#2 @nacin
13 years ago

Blind type-casting can cause its own hidden issues. (array) null produces array() but (array) false (length of 0) produces array( 0 => false ) (length of 1). It's best to be explicit; is_array() is not exactly slow.

#3 @nacin
13 years ago

  • Milestone Awaiting Review3.9

#4 @OriginalEXE
13 years ago

Yeah you're right about that, good point, thanks for clearing it up.

#5 @wonderboymusic
13 years ago

  • Owner set to wonderboymusic
  • Resolutionfixed
  • Status newclosed

In 27186:

Remove extraneous type-casting in wp_get_object_terms().

Props OriginalEXE.
Fixes #27133.

Note: See TracTickets for help on using tickets.