getblocklab/block-lab

Error loading block: Invalid parameter(s): context in Wordpress 5.3.2

Closed this issue · 17 comments

The above error is displayed in the Gutenberg editor for any block-lab block that is not selected. The block shows fine in the frontend. The error occurs for all blocks, including blocks without any fields. According to #244, the plugin was installed via the Wordpress backend.

@c-abird Could you please attach a screenshot of your console output?

@lukecarbis thanks for the quick reply. What do you mean by "console output" (Sorry, I'm fairly new to Wordpress). I'm attaching a screenshot of the editor showing the error. There are no errors in the server logs.
wp_error

Hi @c-abird,
Depending on the browser, it might be something like View > Developer > JavaScript Console. It should look something like this:

console-js

Also, is there any other block-related plugin active, and is the Gutenberg plugin active?

Ah, I see, thanks for the hint. There is a JSON request to the URL
http://example.com/wp-json/wp/v2/block-renderer/block-lab/teaser?context=edit&post_id=2&_locale=user
("teaser" is the name of the custom block. Note, that I aliased example.com with my local host). This request leads to a 400 response with the following content:
{"code":"rest_invalid_param","message":"Invalid parameter(s): context","data":{"status":400,"params":{"context":"context is not one of edit."}}}

The console output looks like this:
wp_error

Hi @kienstra. Thanks for your input, see message above. Concerning additional plugins, I deactivated all block related plugins (namely "Ultimate Addons for Gutenberg"), but still getting the same error.

Hi @c-abird,
Thanks a lot for the console output. That helps.

Sorry to keep asking for more, but would you be able to paste here the PHP template code for the block, and a screenshot of the block configuration?

For example, here's a block configuration:

example-block-configuration

Hi @kienstra. Thanks for your help!
I've tried multiple templates and configurations (including a block without any variables + static template). I attached a very simple block. As previously mentioned, the block itself is working perfectly in the frontend. Just the rendering in the editor seems to be broken if the block is not highlighted for editing.

wp-error1
wp-error2

Update: please ignore this

Thanks, @c-abird!

The configuration and template look good, they don't look to be causing the issue.

Is the Gutenberg plugin active, by chance? If not, could you try activating it the latest released version?

There was a fix for an issue similar to this that was merge last month:

Codeinwp/gutenberg-css#12

Ah, sorry. The fix above was in a separate plugin, not Gutenberg.

It looks like the Gutenberg issue similar to this is still open: WordPress/gutenberg#16850

After the following steps, does that same error still appear?

  1. Deactivate all block-related plugins (with Gutenberg active if you'd like)
  2. Create a new simple Block Lab configuration, like 'Foo Block'
  3. Click 'New Post,' and add that 'Foo Block'
  4. Edit that block
  5. Does that error still appear?

This error might be from another plugin adding something to the block: WordPress/gutenberg#16850

They might persist even after another plugin is deactivated.

If the steps above don't help, does this same issue occur with the Core 'Latest Comments' block? That also uses the <ServerSideRender> component that Block Lab uses.

Hi @kienstra. Thanks for the hints. Indeed, the "Latest Comments" block produces exactly the same error. So, I guess this means that there is a problem with my Wordpress installation, right?

Hi @c-abird,
Yeah, it's more likely to be a general problem with WordPress Core or Gutenberg, not Block Lab in particular.

Does this error appear for the 'Latest Comments' block if all plugins are deactivated, including Block Lab? If so, opening an issue with Gutenberg is probably appropriate.

Hello I have the same problems , screenshot of console below. No Gutenberg plugin installed.
Screenshot 2020-01-31 at 11 08 22

Hi @fredrik-luckan,
Thanks for bringing that up. Could you please open a new bug issue so we can look at the specific issue you have?

Maybe it is the same as this issue, but more details would really help.

ok I posted a bug

Closing in favor of WordPress/gutenberg#16850.