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 /> component does not support blocks with lots of attributes #16396

Closed
TimoGlastra opened this issue Jul 2, 2019 · 5 comments
Labels
[Package] Server Side Render /packages/server-side-render [Type] Enhancement A suggestion for improvement. [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.

Comments

@TimoGlastra
Copy link

Is your feature request related to a problem? Please describe.
When using the <ServerSideRender /> component to render a block and pass in a lot of attributes to the attributes prop of the component, the render request fails due to the request query having too many characters.

There are two scenario's where this happens for me. The first one is (sort of) a bug in my opinion. When writing a long paragraph that contains (+-) over 2000 characters it will fail. I think having a paragraph that is 2000 characters long is not a very common use case, but it happens.

Second scenario, which has more to do with my specific usage, is that i also pass all the names and attributes of all innerBlocks to the <ServerSideRender /> component. This because during editing in the editor and server side rendering, the $content variable is an empty string. I do however need to render the innerBlocks content inside the server side rendered block. In this case adding a couple of innerBlocks to a block pretty quickly reaches the character limit, which results in the server side render request failing. I know this is not how the <ServerSideRender /> component is supposed to be used, but i don't see a better solution to render the innerBlocks inside the server side rendered block.

Describe the solution you'd like
A solution to this would be using POST instead of GET requests to render the block with the <ServerSideRender /> component. This way the attributes can be placed in the body of the request which eliminates the GET url request character limit (is this a WordPress limit?)

Describe alternatives you've considered
At the moment i can't think of any other solutions to solve this in an easy manner.

@swissspidy swissspidy added [Package] Server Side Render /packages/server-side-render [Type] Enhancement A suggestion for improvement. [Type] Help Request Help with setup, implementation, or "How do I?" questions. [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked. labels Jul 5, 2019
@swissspidy
Copy link
Member

Perhaps the component could support a requestBody prop. If it's used, it would do a POST request with the body sent as JSON.

But that would require a change to \WP_REST_Block_Renderer_Controller in core to support POST requests as well.

@wpt00ls
Copy link

wpt00ls commented Sep 13, 2019

+1

I think having a paragraph that is 2000 characters long is not a very common use case, but it happens.

Here is my use case.

I am in the middle of creating a ServerSideRender'ed block too.

Coming from the view point of page builders like Elementor and divi where an elementor/divi module supports a lot of UI options like typography, border, border radius etc.

If we want to create equivalent blocks we will have a lot of attributes. Combined with the necessity to do a ServerSideRender (for example building an gutenberg block on top of a third party shortcode), using POST makes perfect sense. With no such cap on the attribute characters, we can create feature rich ServerSideRendered gutenberg blocks

@myleshyson
Copy link
Contributor

myleshyson commented Nov 6, 2019

Hey any update on this? We need to use the ServerSideRender component for a block but can't since our data for it exceeds our apache url limit. Ideally we really don't want to update that apache setting.

@talldan
Copy link
Contributor

talldan commented Apr 23, 2020

This now seems to be more of an enhancement request rather than a help request so relabeling and retitling.

@talldan talldan changed the title Use POST request for <ServerSideRender /> component instead of GET <ServerSideRender /> component does not support blocks with lots of attributes Apr 23, 2020
@talldan
Copy link
Contributor

talldan commented May 10, 2021

Seems like this was fixed a while ago in #21068

@talldan talldan closed this as completed May 10, 2021
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] Enhancement A suggestion for improvement. [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.
Projects
None yet
Development

No branches or pull requests

5 participants