WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#21527 closed enhancement (fixed)

post_type_supports(), no arguments case

Reported by: bilalcoder Owned by: SergeyBiryukov
Milestone: 3.6 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch commit
Focuses: Cc:

Description

At line 1388 in wp-includes/post.php when checking for number of arguments passed to post_type_supports():

if( function_num_args() <= 2 )

return true;

Obviously it does not hurt, but absolutely it's just an extra code.

Attachments (2)

21527.diff (671 bytes) - added by obenland 8 years ago.
21527.2.diff (1.1 KB) - added by SergeyBiryukov 8 years ago.

Download all attachments as: .zip

Change History (12)

#1 @bilalcoder
8 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#2 @helenyhou
8 years ago

  • Milestone Awaiting Review deleted

#3 @SergeyBiryukov
8 years ago

Looking at the code (introduced in [12682]), seems that the check can be removed indeed:
http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/post.php#L1358

Related: #17584

@obenland
8 years ago

#4 @obenland
8 years ago

  • Keywords has-patch added
  • Resolution invalid deleted
  • Status changed from closed to reopened

#5 @SergeyBiryukov
8 years ago

  • Milestone set to Awaiting Review

#6 @SergeyBiryukov
8 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 3.6

#7 follow-up: @SergeyBiryukov
8 years ago

Looks like remove_post_type_support() can lose some redundant code too, the second isset() check is unnecessary: 21527.2.diff.

#8 in reply to: ↑ 7 ; follow-up: @obenland
8 years ago

I know returning early is a popular coding convention in core, but why not just say:

<?php

if ( isset( $_wp_post_type_features[$post_type] ) )
    unset( $_wp_post_type_features[$post_type][$feature] );

#9 @SergeyBiryukov
8 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from reopened to closed

In 23722:

Remove redundant code from post_type_supports() and remove_post_type_support(). props obenland, bilalcoder. fixes #21527.

#10 in reply to: ↑ 8 @nacin
8 years ago

Replying to obenland:

I know returning early is a popular coding convention in core, but why not just say:

<?php

if ( isset( $_wp_post_type_features[$post_type] ) )
    unset( $_wp_post_type_features[$post_type][$feature] );

Even the isset() here is unnecessary. :-)

Note: See TracTickets for help on using tickets.