[wp-trac] [WordPress Trac] #33068: get_post() returning current object if 0
WordPress Trac
noreply at wordpress.org
Wed Jul 22 21:57:44 UTC 2015
#33068: get_post() returning current object if 0
-------------------------------+------------------------------
Reporter: Rahe | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 3.5
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------------+------------------------------
Changes (by juliobox):
* version: 4.2.2 => 3.5
Comment:
Good catch,
A little of history:
WP 1.5.1, the ''get_post()'' function is added. The first parameter was
(and is) ''$post''. But at this time you can avoid it, it's required, no
default value.
So if you try to use it with an empty string, a false, null or 0, the
global var will be used if set.
WP 3.5, the first parameter gets its default value ''null''. BUT we kept
to test this with ''is_empty''.
Since the ''$post'' parameter is set to ''null'' by default, i prefer to
test this to be different.
Also, i already found that some plugin were creating a post with the ID 0,
ok, it's not a good idea but now we know that this can break that. See
what i mean.
Thanks anyway!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33068#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list