#43618 closed defect (bug) (worksforme)
get_the_excerpt breaking wp-json API
| Reported by: | DannyCooper | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Posts, Post Types | Version: | 5.0 |
| Severity: | normal | Keywords: | has-screenshots |
| Cc: | Focuses: | rest-api |
Description
When creating a dynamic block for Gutenberg I added this code to a plugin:
register_block_type( 'my-plugin/latest-post', array(
'render_callback' => 'my_plugin_render_block_latest_posts',
) );
function my_plugin_render_block_latest_posts( $atts ) {
$output = '';
$args = array(
'posts_per_page' => 3,
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) :
$query->the_post();
$output .= '<li>';
$output .= get_the_excerpt();
$output .= '</li>';
endwhile;
wp_reset_postdata();
else :
$output .= 'No posts found.';
endif;
return $output;
}
For some reason, get_the_excerpt is causing this error in /wp-json/wp/v2/posts:
Fatal error: Maximum function nesting level of '256' reached, aborting! in /app/public/wp-includes/plugin.php on line <i>899</i>
When I remove get_the_excerpt() or replace it with get_the_content() the error disappears.
I use 'Local by Flywheel' and this is happening on PHP5.6 and 7
Attachments (1)
Change History (4)
#3
@
11 months ago
- Keywords has-screenshots added
- Milestone Awaiting Review
- Resolution → worksforme
- Status new → closed
Reproduction Report
Description
❌ This report can't validate that the issue can be reproduced.
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.29
- PHP: 7.2.34
- Server: nginx/1.29.1
- Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
- Browser: Chrome 140.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty 2.9
- MU Plugins: None activated
- Plugins:
- BBB - Block Plugin 1.0.0
- Test Reports 1.2.0
Testing Instructions
- Using the plugin provided in Supp Artifacts
Actual Results
- ❌ Error condition is not occurring
Additional Notes
- I've tested down to PHP 7.2 because WP 6.8 just not supporting anything under this. I'm not sure if this was an old problem in gutenberg, I'm not even sure that this belongs to the Posts component, and it could even be a trouble with PHP. We will never know.
- Given that this is not reproducible anymore, I'm closing this, as
worksforme
Supplemental Artifacts
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)

Demo plugin to test this