Skip to content

ServerSideRender no longer passing post_id query arg  #31786

@bobbingwide

Description

@bobbingwide

Description

I believe the change in PR #29246 was slightly flawed.
It may have resolved the problem with Server Side Rendered blocks failing when used in the Site Editor or Template editor but it's broken other SSR blocks which depend on the post_id being passed on the REST request to render the block.

It was working in 10.3.2; broken in 10.4.0 and higher.

The code change was:

if ( currentPostId && typeof currentPostId.id === 'number' ) {

In my system typeof currentPostId.id is undefined.

I believe the code should have been

if ( currentPostId && typeof currentPostId === 'number' ) {

Step-by-step reproduction instructions

  1. Install a plugin such as sb-children-block, which is a plugin that relies on the post_id being passed during server side rendering of the block in the editor.
  2. With Gutenberg 10.3.2 demonstrate that for a page that has children the block works in both the editor and front end.
  3. Update to Gutenberg 10.4.0 or higher
  4. Retest. The block is not rendered correctly in the editor.

Expected behaviour

For <ServerSideRendered> blocks the post_id query arg should be passed to the server when editing a post.

Actual behaviour

It's not being passed. The blocks do not render correctly in the editor.

Screenshots or screen recording (optional)

Code snippet (optional)

WordPress information

  • WordPress version: 5.7.1
  • Gutenberg version: 10.6.0
  • Are all plugins except Gutenberg deactivated? No
  • Are you using a default theme (e.g. Twenty Twenty-One)? Yes

Device information

  • Device: Desktop
  • Operating system: Windows
  • Browser: Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions