Skip to content

get_the_excerpt is taking PHP out of memory in a block rendering #5572

@maximebj

Description

@maximebj

Issue Overview

I'm rendering a block in PHP that display another post preview card so I simply use (in the render_callabck) :

$id = $attributes['postID'];

$post = get_post( $id );
$excerpt = get_the_excerpt( $id );

I get a Fatal error: Allowed memory size of... from PHP from get_the_excerpt()
It look like it's too much for WP to parse the gutenberg saved markup

The targeted post only has a few paragraphs and a read more tag.

The issue does not happen if I set manually an excerpt in the inspector.

capture 2018-03-12 a 17 45 42

This memory issue does not occur outside a block rendered in PHP

Steps to Reproduce

  1. create a post with gutenberg
  2. add a read more block but no excerpt on inspector
  3. create a block rendering in PHP
  4. on the render hook, try to get_post and get_the_excerpt

Expected Behavior

display everything

Current Behavior

Allowed memory size of

Todos

  • Tests
  • Is it a legit issue?
  • find where occurs the memory leak and why

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions