Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerSideRender no longer passing post_id query arg #31786

Closed
bobbingwide opened this issue May 13, 2021 · 2 comments
Closed

ServerSideRender no longer passing post_id query arg #31786

bobbingwide opened this issue May 13, 2021 · 2 comments
Labels
[Package] Server Side Render /packages/server-side-render [Type] Regression Related to a regression in the latest release

Comments

@bobbingwide
Copy link
Contributor

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
@bobbingwide
Copy link
Contributor Author

It's only a 3 character fix, which I have tested locally. It'll take me a while to develop a PR.
But I'm going to try.

I believe this fix also resolves some problems with blocks encountering errors in the Site editor.

@Mamaduka Mamaduka added [Package] Server Side Render /packages/server-side-render [Type] Regression Related to a regression in the latest release labels May 13, 2021
@Mamaduka
Copy link
Member

Hi, @bobbingwide

I merged PR (#31787) last week, so going to close this one now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Server Side Render /packages/server-side-render [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

No branches or pull requests

2 participants