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

Allow larger attributes by using new <ServerSideRender> prop #39

Merged
merged 5 commits into from
Oct 13, 2020

Conversation

kienstra
Copy link
Contributor

@kienstra kienstra commented Oct 12, 2020

Changes

Even if there is a lot of text, the block preview will still render:

block-here

Fixes issues reported in BL: #477, #436, #511

Testing instructions

  1. Please see 'Steps to reproduce' in BHH-569
  2. Please test with current version of WP and 5.4.2. The expected behavior is the same.

Even if there is a lot of text,
the block preview should still render.
@kienstra kienstra marked this pull request as draft October 12, 2020 20:47
* @param string $method_name The name of the method to get the callback for.
* @return callable An enclosure that calls the function.
*/
protected function get_callback( $method_name ) {
Copy link
Contributor Author

@kienstra kienstra Oct 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, but it's not necessary.

I wanted to keep methods protected, and use ->get_callback to expose them in add_action() and add_filter().

But this is verbose and unnecessary 🤣

@lukecarbis
Copy link
Contributor

🎉

@@ -38,6 +38,7 @@ const Edit = ( { blockProps, block } ) => {
block={ `genesis-custom-blocks/${ block.name }` }
attributes={ attributes }
className="genesis-custom-blocks-editor__ssr"
httpMethod="POST"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new prop for this component.

@kienstra
Copy link
Contributor Author

kienstra commented Oct 13, 2020

Hi @nickcernis and @mindctrl,
Could you please review this when you have a chance?

This fixes an issue where the REST API endpoint for the <ServerSideRender> couldn't handle an attributes object over a certain size. So it uses the newly-added httpMethod prop of that component to make it use POST requests, which allow a bigger attributes object.

BHH-569 has more details.

Thanks!

Copy link
Contributor

@nickcernis nickcernis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working great for me with a million "a"s, @kienstra. [About 1MB of text.]

Works under 5.4.2 too. Great job covering that.

millionas.txt

* The <ServerSideRender> uses the httpMethod of 'POST' to handle a larger attributes object.
* That is already added in WP 5.6+, so no need to add it there.
*
* @todo: Delete when this plugin's 'Requires at least' is bumped to 5.6.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to add this reminder. Will be nice when we can bump the minimum version to 5.6.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yeah, that'll be good!

@kienstra
Copy link
Contributor Author

Thanks so much for reviewing this.

@kienstra kienstra merged commit 60295cb into develop Oct 13, 2020
@kienstra kienstra deleted the fix/posts-excessive-attributes branch October 13, 2020 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants