-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Code Quality: Account for object being supplied as post, term, or comment
#11096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
417b389
366a685
20cf57e
d3407f2
f9e371f
917ccfc
92952de
a0adb6a
3736bea
9fc4723
5fbfeed
cbddb78
31984a0
888ba44
6816649
93006ad
07d76fd
2e67166
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1159,8 +1159,10 @@ function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) { | |
| $_post = new WP_Post( $_post ); | ||
| } elseif ( 'raw' === $post->filter ) { | ||
| $_post = new WP_Post( $post ); | ||
| } else { | ||
| } elseif ( isset( $post->ID ) ) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would mean that PHPdoc for So if you expect this to be a generic object, that is formed like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, the PHPDoc needs to be updated to add
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or I guess, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How/why is it possible that an object that mimics WP_Post is passed here? Doesn’t look like solid architecture
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's when post data is passed straight from a database query.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed in d3407f2 |
||
| $_post = WP_Post::get_instance( $post->ID ); | ||
| } else { | ||
| $_post = null; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess some test coverage here would be good.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 92952de |
||
| } | ||
| } else { | ||
| $_post = WP_Post::get_instance( $post ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1723,7 +1723,7 @@ function sanitize_term( $term, $taxonomy, $context = 'display' ) { | |
|
|
||
| $do_object = is_object( $term ); | ||
|
|
||
| $term_id = $do_object ? $term->term_id : ( $term['term_id'] ?? 0 ); | ||
| $term_id = $do_object ? ( $term->term_id ?? 0 ) : ( $term['term_id'] ?? 0 ); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test coverage here too.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 3736bea |
||
|
|
||
| foreach ( (array) $fields as $field ) { | ||
| if ( $do_object ) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.