Make WordPress Core

Opened 2 weeks ago

Last modified 30 hours ago

#61592 new defect (bug)

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

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


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'] ); ?>

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 (2)

#1 @bramwaas
12 days 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 9 days ago by bramwaas (previous) (diff)

#2 @bramwaas
30 hours ago

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

Note: See TracTickets for help on using tickets.