Make WordPress Core

Opened 4 weeks ago

Closed 11 days ago

#61592 closed defect (bug) (reported-upstream)

6.6-RC2 Editing/Inserting Synced pattern (reusable block) with server side rendering broken.

Reported by: bramwaas's profile bramwaas Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.6
Component: Editor Keywords:
Focuses: Cc:

Description

I have a plugin that uses Server side rendering with render_callback in server side register_block_type to create calendar output.
In some test I had made a reusable block of it to put it on a page. After a while the reusable block became a synced pattern. It keeped working on the frontend and I could also edit the page where it is at least until release 6.5.4.

After upgrading to 6.6.-RC2 the front end still worked as expected, but in the editor the page could not be edited any more.
Screen feezes and I get some 30 messages like this:
Connect to backend rejected on sending request(POST /wp6/wp-json/wp/v2/block-renderer/simplegoogleicalenderwidget/simple-ical-block?context=edit&post_id=58&_locale=user HTTP/2.0); uri(/wp6/index.php?context=edit&post_id=58&_locale=user)

When I remove all references to server side renderer in the plugin, the page can be edited again, but of course I have no content in my block any more.

When I replace render_callback in server side register_block_type by rendering via the render option in block.json "render": "file:./includes/renderssv3.php" I keep getting the same error even when renderssv3.php contains only the example code:

<div <?php echo get_block_wrapper_attributes(); ?>>
    <?php echo esc_html( $attributes['title'] ); ?>
</div>

Creating a new pattern with my block (simple-google-icalendar-widget) is still possible, but when I try to place that pattern on a page the page freezes also with the same php errors.

Change History (3)

#1 @bramwaas
4 weeks ago

Found the trigger of this issue in my edit javascript I start with trying to set an unique id in the attribute sibid.
That seems to fail on pages where the block is put on as a synced pattern.

In WordPress 6.6 after that the edit function is started again (again with empty attribute sibid) and fails again thus creating an endless loop.

In older versions this endless loop does not appear.

Relevant code:

	edit: function(props) {
		useEffect(function() {
		if ((typeof props.attributes.sibid !== 'string') && (typeof props.attributes.blockid == 'string')) {
			props.setAttributes({ sibid: props.attributes.blockid });
		}
		else {if (typeof props.attributes.sibid !== 'string') {
			 props.setAttributes({ sibid: 'b' + props.clientId }); }
			 }
		}, [props.attributes]);
		...


Last edited 3 weeks ago by bramwaas (previous) (diff)

#2 @bramwaas
2 weeks ago

Provisional solved by adding local assigns like:
props.attributes.sibid = props.attributes.blockid

#3 @talldanwp
11 days ago

  • Milestone Awaiting Review deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed

Thanks for reporting this. This seems like the same issue being reported here - React methods are executed infinited times when block is inserted through a custom pattern

I'll close this trac ticket, as editor issue are generally being reported in the gutenberg github repository.

Note: See TracTickets for help on using tickets.