[wp-trac] [WordPress Trac] #37738: WP_Post::get_instance returns erroneous data for invalid input such as an array or object instead of false.
WordPress Trac
noreply at wordpress.org
Fri Aug 19 14:22:27 UTC 2016
#37738: WP_Post::get_instance returns erroneous data for invalid input such as an
array or object instead of false.
-------------------------------+-----------------------------
Reporter: deeptiboddapati | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
Steps to reproduce the problem:
1. On any wp site which has a post with id =1 run:
{{{
$post = WP_Post::get_instance(array("a","b"));
print_r($post); //will print the post with id = 1 (most probably hello
world)
}}}
2. It does the same thing with objects
{{{
$obj = (object) array("a","b");
$post = WP_Post::get_instance($obj);
print_r($post);
}}}
3. floats it rounds down to the nearest int and tries to get that post
{{{
$post = WP_Post::get_instance(3.5);
returns post with id = 3
}}}
4. If you pass in a boolean it returns the first post for true and false
for false.
{{{
$post = WP_Post::get_instance(true); //returns post id =1
$post = WP_Post::get_instance(false); //returns false
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37738>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list