Opened 6 years ago
Closed 5 years ago
#44365 closed enhancement (fixed)
Coding Standards: Yoda condition check is not present
Reported by: | subrataemfluence | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | |
Focuses: | coding-standards | Cc: |
Description
In wp-admin/admin.php between line nos. 358 and 372, Yoda conditions are not met according to the sniffer.
Here is the code we have now:
<?php if ( $typenow == 'page' ) { if ( $pagenow == 'post-new.php' ) { do_action( 'load-page-new.php' ); } elseif ( $pagenow == 'post.php' ) { do_action( 'load-page.php' ); } } elseif ( $pagenow == 'edit-tags.php' ) { if ( $taxnow == 'category' ) { do_action( 'load-categories.php' ); } elseif ( $taxnow == 'link_category' ) { do_action( 'load-edit-link-categories.php' ); } } elseif ( 'term.php' === $pagenow ) { do_action( 'load-edit-tags.php' ); }
One thing to notice at the end of the above code block. We have a Yoda condition checked. I am not sure why it used only at one place. Is this done in purpose?
<?php ... } elseif ( 'term.php' === $pagenow ) { do_action( 'load-edit-tags.php' ); }
Can we re-write the block of code and make it consistent as proposed in my patch?
Attachments (1)
Change History (7)
#1
@
6 years ago
- Keywords 2nd-opinion removed
- Resolution set to duplicate
- Status changed from new to closed
#2
@
6 years ago
- Resolution duplicate deleted
- Status changed from closed to reopened
Thank you for looking into it.
But as far as I have seen there is no patch for admin.php in #44208.
Should I upload the patch there?
Note: See
TracTickets for help on using
tickets.
Duplicate of #44028.