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

Bypass check_admin_referrer() call in the use_block_editor_for_post() #351

Merged
merged 2 commits into from
Mar 15, 2019

Conversation

drebbits
Copy link
Contributor

@drebbits drebbits commented Mar 15, 2019

Since WordPress 5.0 will do a check_admin_referrer() inside the use_block_editor_for_posts(), this call would fail and kill the request if there's any custom meta boxes in the edit screen.

Unsetting the 'meta-box-loader' in the global request would bypass that check. Then, we will restore the value once we secured the date from the use_block_editor_for_posts() API.

This fixes the infinite saving / previewing on WordPress 5.0.

Dreb Bits added 2 commits March 15, 2019 03:34
Since WordPress 5.1 will do a check_admin_referrer() inside the use_block_editor_for_posts(),
and this call would fail and returns a 404 if there's custom meta box.

Unsetting the 'meta-box-loader' in the global request would bypass that check.
@adamsilverstein
Copy link

PR looks good!

It feels odd that we have to work around what feels like an upstream bug. I don't understand why the meta box check was added inside this function, might be worth investigating the origin further and perhaps opening an upstream PR to change.

Copy link

@adamsilverstein adamsilverstein left a comment

Choose a reason for hiding this comment

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

While this isn't great, it solves a significant bug that breaks saving/previewing in Gutenberg.

@jeffpaul jeffpaul added this to the 1.4.1 milestone Mar 15, 2019
@adamsilverstein
Copy link

I verified this is an issue in the current version of WordPress & Distributor without any additional plugins.

I tested in WordPress trunk with Distributor on the develop branch.

Steps to reproduce

  • create a new post, add a title and some content
  • enable custom fields in the Block Editor (Gutenberg) interface: this is under the ... more menu-> options: Advanced Panels: Custom Fields
    image
  • At the bottom of the page, under Custom fields: Add New Custom Field, click enter new:
    image
  • Create a test field and click add custom field:
    image
  • Click 'Save Draft'

Expected Behavior

Saving works.

Actual Behavior

Saving fails with wp_die error:
image

After this PR, saving works as expected.

@adamsilverstein adamsilverstein merged commit d0189e2 into 10up:develop Mar 15, 2019
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.

None yet

3 participants