WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 5 months ago

#39992 new defect (bug)

Bug in get_the_content

Reported by: olik9 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.2
Component: Posts, Post Types Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

In get_the_content $post is not checked if it's null, after

<?php
$post = get_post();


and then on line:

<?php
if ( false !== strpos( $post->post_content, '<!--noteaser-->' ) && ( ! $multipage || $page == 1 ) )

as you see, $post->post_content is queried. Then if $post is null, the program falls.

A solution can be to check:

<?php
$post = get_post();
if ( ! $post ) { return ''; }
//else

and then continue.

Thank you for everything! :)

Attachments (2)

39992.patch (399 bytes) - added by 1naveengiri 7 months ago.
Fixed in this patch.
39992.2.patch (398 bytes) - added by 1naveengiri 7 months ago.

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
7 months ago

  • Component changed from General to Posts, Post Types

#2 @swissspidy
7 months ago

  • Keywords needs-patch added

@1naveengiri
7 months ago

Fixed in this patch.

#3 @1naveengiri
7 months ago

  • Keywords has-patch added; needs-patch removed

#4 @1naveengiri
6 months ago

Hi team,
any update on above Bug.

#5 @swissspidy
5 months ago

  • Keywords needs-unit-tests added
Note: See TracTickets for help on using tickets.