Opened 8 years ago
Closed 7 years ago
#44365 closed enhancement (fixed)
Coding Standards: Yoda condition check is not present
| Reported by: | subrataemfluence | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.4 |
| Component: | Administration | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | coding-standards |
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)
#2
@
8 years ago
- Resolution duplicate
- Status closed → 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.