Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#51042 closed defect (bug) (fixed)

Post missing excerpt

Reported by: riaanlom's profile riaanlom Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5.1 Priority: normal
Severity: normal Version: 5.5
Component: Posts, Post Types Keywords: commit fixed-major
Focuses: Cc:

Description

If post doesn't have an excerpt, expected outcome is for it to be generated from the post content.

wp-includes/formatting.php
function wp_trim_excerpt line 3811

if ( '' === $text )

Previous versions of WP used == instead of === . The strict comparison operator returns an empty excerpt

Change History (8)

#1 @Laxman Prajapati
4 years ago

@riaanlom

Yes, I agree the == instead of === condition changed on the WordPress version 5.5

But are using like this?: https://developer.wordpress.org/reference/functions/wp_trim_excerpt/

Can you please review this one, May be it will help you.

Thanks,
Laxman P.

#2 follow-up: @riaanlom
4 years ago

@laxman-prajapati

I'm not calling the function directly.

This used to return the generate excerpt from the post content but with WP 5.5 it returns NULL

$post = get_post(1);
$excerpt = ! empty( $post->post_excerpt ) ? $post->post_excerpt : null;
$excerpt = apply_filters( 'get_the_excerpt', $excerpt, $post );

#3 in reply to: ↑ 2 @Laxman Prajapati
4 years ago

@riaanlom
Ok, I have one minor change.
Can you please try with below?

$post = get_post(1);
$excerpt = ! empty( $post->post_content ) ? $post->post_excerpt : null;
$excerpt = apply_filters( 'get_the_excerpt', $excerpt, $post );

Hope It will works for you.

Thanks,
Laxman P

Replying to riaanlom:

@laxman-prajapati

I'm not calling the function directly.

This used to return the generate excerpt from the post content but with WP 5.5 it returns NULL

$post = get_post(1);
$excerpt = ! empty( $post->post_excerpt ) ? $post->post_excerpt : null;
$excerpt = apply_filters( 'get_the_excerpt', $excerpt, $post );

#4 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 5.5.1
  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

Hi there, welcome to WordPress Trac! Thanks for the report.

This appears to be a regression in [47808].

The fix would probably be similar to [47580] / #49853.

#5 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 48817:

Formatting: Make the check for empty text in wp_trim_excerpt() more resilient.

This addresses a regression in [47808], which caused excerpts to be generated from post content if an empty string is passed, but not for other values considered empty, e.g. null or false.

Props riaanlom, laxman-prajapati, SergeyBiryukov.
Fixes #51042.

#6 @SergeyBiryukov
4 years ago

  • Keywords commit fixed-major added; needs-patch removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for the 5.5 branch.

#7 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 48819:

Formatting: Make the check for empty text in wp_trim_excerpt() more resilient.

This addresses a regression in [47808], which caused excerpts to be generated from post content if an empty string is passed, but not for other values considered empty, e.g. null or false.

Props riaanlom, laxman-prajapati, SergeyBiryukov.
Merges [48817] to the 5.5 branch.
Fixes #51042.

#8 @SergeyBiryukov
4 years ago

  • Component changed from Post Formats to Posts, Post Types
Note: See TracTickets for help on using tickets.