-
Notifications
You must be signed in to change notification settings - Fork 57
Closed
Labels
Description
Describe the bug
When a self-hosted site has a reusable block that contains a self-reference, it produces a bad response on every request to the reusable blocks endpoint (v2/blocks path), breaking the reusable block functionality.
This is reproducible on self-hosted sites with and without Jetpack, although the error response is different.
Without Jetpack
To Reproduce
- Create a self-hosted site without Jetpack (I used https://jurassic.ninja/create/) or use an already created one.
- Create a reusable block
- Edit the reusable block, add the same reusable block as part of the content and save it
- Add the reusable block to a post/page
- Edit the post/page in the mobile app
- Check the response of requests to
/wp-json/wp/v2/blocksand observe that the data is not JSON format
Here I copied an example of one:
Request response
<br />
<b>Warning</b>: Could not render Reusable Block <strong>RB 1</strong>: blocks cannot be rendered inside themselves. in <b>/srv/users/<USER>/apps/<USER>/public/wp-includes/blocks/block.php</b> on line <b>35</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /srv/users/<USER>/apps/<USER>/public/wp-includes/blocks/block.php:35) in <b>/srv/users/<USER>/apps/<USER>/public/wp-includes/rest-api/class-wp-rest-server.php</b> on line <b>1642</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /srv/users/<USER>/apps/<USER>/public/wp-includes/blocks/block.php:35) in <b>/srv/users/<USER>/apps/<USER>/public/wp-includes/rest-api/class-wp-rest-server.php</b> on line <b>1642</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /srv/users/<USER>/apps/<USER>/public/wp-includes/blocks/block.php:35) in <b>/srv/users/<USER>/apps/<USER>/public/wp-includes/rest-api/class-wp-rest-server.php</b> on line <b>1642</b><br />
[{"id":6,"date":"2021-05-04T14:02:17","date_gmt":"2021-05-04T14:02:17","guid":{"rendered":"https:\/\/vivacious-aardvark.jurassic.ninja\/2021\/05\/04\/untitled-reusable-block\/","raw":"https:\/\/vivacious-aardvark.jurassic.ninja\/2021\/05\/04\/untitled-reusable-block\/"},"modified":"2021-05-04T14:36:16","modified_gmt":"2021-05-04T14:36:16","password":"","slug":"untitled-reusable-block","status":"publish","type":"wp_block","link":"https:\/\/vivacious-aardvark.jurassic.ninja\/2021\/05\/04\/untitled-reusable-block\/","title":{"raw":"RB 1"},"content":{"raw":"<!-- wp:heading -->\n<h2>Heading<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Paragraph<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:block {\"ref\":6} \/-->","protected":false,"block_version":1},"template":"","_links":{"self":[{"href":"https:\/\/vivacious-aardvark.jurassic.ninja\/wp-json\/wp\/v2\/blocks\/6"}],"collection":[{"href":"https:\/\/vivacious-aardvark.jurassic.ninja\/wp-json\/wp\/v2\/blocks"}],"about":[{"href":"https:\/\/vivacious-aardvark.jurassic.ninja\/wp-json\/wp\/v2\/types\/wp_block"}],"wp:attachment":[{"href":"https:\/\/vivacious-aardvark.jurassic.ninja\/wp-json\/wp\/v2\/media?parent=6"}],"wp:action-publish":[{"href":"https:\/\/vivacious-aardvark.jurassic.ninja\/wp-json\/wp\/v2\/blocks\/6"}],"wp:action-unfiltered-html":[{"href":"https:\/\/vivacious-aardvark.jurassic.ninja\/wp-json\/wp\/v2\/blocks\/6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]
Some parts of the log have been replaced with <USER> just in case they were sensitive.
With Jetpack
To Reproduce
- Create a self-hosted site with Jetpack (I used https://jurassic.ninja/create/) or use an already created one.
- Create a reusable block
- Edit the reusable block, add the same reusable block as part of the content and save it
- Add the reusable block to a post/page
- Edit the post/page in the mobile app
- Check the response of requests to
/wp/v2/sites/<SITE_ID>/blocksand observe that the response code is500
Request response:
{"code":"no_response_body","message":"Server could not read response.","data":{"status":500}}
In iOS on a self-hosted site with Jetpack connected, it produces the following error that could lead to a crash:

Expected behavior
Requests to blocks endpoint should be successful.
Smartphone (please complete the following information):
- Device: iPhone 8
- OS: iOS 14.2
- Version 17.1 DEV