[wp-trac] [WordPress Trac] #24827: bug in post-template.php
WordPress Trac
noreply at wordpress.org
Wed Jul 24 15:29:58 UTC 2013
#24827: bug in post-template.php
--------------------------+-----------------------------
Reporter: crysman | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.5.2
Severity: normal | Keywords:
--------------------------+-----------------------------
== The bug ==
There is a bug in ''wp-includes/post-template.php'', line 208:
{{{
if ( (false !== strpos($post->post_content, '<!--noteaser-->') &&
((!$multipage) || ($page==1))) )
...
}}}
''$post'' variable is being inicialized on line 183 like this:
{{{
$post = get_post();
}}}
What is wrong is that ''get_post()'' may return NULL, and it sometimes
does. So the code
{{{
$post->post_content
}}}
is obviously incorrect, because it is trying to access an object, which
does not exist. Therefore, you get a PHP notice, thus getting "header
already send" errors...
== the fix ==
is simple - just check first if non-empty:
{{{
if(!empty($post))
if ( (false !== strpos($post->post_content, '<!--noteaser-->') &&
((!$multipage) || ($page==1))) )
...
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24827>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list