#52818 closed defect (bug) (fixed)
Ordering metaboxes broken in WP 5.7
Reported by: | terraling | Owned by: | desrosj |
---|---|---|---|
Milestone: | 5.8.1 | Priority: | normal |
Severity: | normal | Version: | 5.7 |
Component: | Editor | Keywords: | has-patch |
Focuses: | Cc: |
Description
Post edit screens with metaboxes allow for drag and drop re-ordering.
This worked up to WordPress 5.6.2, but stopped working in WP 5.7, though it continues to work if you use the Classic Editor to edit posts rather than the block editor.
When re-ordering the metaboxes, an ajax update with the action 'meta-box-order' occurs, and this reports a succesful response both in the working and non-working cases, so it appears as if updating the metabox order works.
But, when the page is reloaded, the metaboxes are displayed in an unchanged order.
For testing you can use the following code to register two dummy metaboxes:
<?php /** * Add two dummy metaboxes to post edit screens */ function xyz_init_meta_boxes(){ add_meta_box( 'metabox_id_1', __( 'Metabox One', 'textdomain' ), 'xyz_metabox_callback', 'post', 'normal', 'low', array( 'foo' => 'One' ) ); add_meta_box( 'metabox_id_2', __( 'Metabox Two', 'textdomain' ), 'xyz_metabox_callback', 'post', 'normal', 'low', array( 'foo' => 'Two' ) ); } add_action( 'load-post.php', 'xyz_init_meta_boxes' ); add_action( 'load-post-new.php', 'xyz_init_meta_boxes' ); function xyz_metabox_callback( $post, $metabox ) { $foo = $metabox['args']['foo']; echo "<p>Content of metabox $foo</p>"; }
To reproduce, with WP 5.7 edit a post using the block editor.
Re-order the two metaboxes and update the post.
Reload the page.
Attachments (1)
Change History (22)
#3
@
4 years ago
Indeed, it looks like this will need an upstream fix in the Gutenberg repo as it was introduced in [50048] according to git bisect
which is a package update for Gutenberg/the block editor.
I've logged an issue on GitHub for the editor team but will wait until I hear back before making status changes to this ticket. https://github.com/WordPress/gutenberg/issues/30071
#4
@
4 years ago
The page parameter is not included in the AJAX request to the admin-ajax action closed-postboxes
either, resulting in not saving the closed status of metaboxes.
Not sure if this needs a separate ticket / issue, since I guess it has the same cause (missing page parameter). I'll open a separate ticket / issue if it's better to keep track of.
Issue brought up on this forum topic by @viliusl. I can replicate the issue on 5.7, not on 5.6.2
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
4 years ago
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
4 years ago
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
4 years ago
#8
@
4 years ago
- Milestone changed from 5.7.1 to 5.7.2
Moving to Milestone 5.7.2 as WordPress 5.7.1 Release Candidate 1 is planned for today.
#9
@
3 years ago
- Milestone changed from 5.7.2 to 5.7.3
WordPress 5.7.2 has been released, moving open tickets to 5.7.3
#10
@
3 years ago
With 5.8 RC1 due out next week and no 5.7.3 currently planned, I'm going to punt this to the milestone for the next minor release: 5.8.1.
#12
@
3 years ago
To be considered for the next release (5.8.1) this will need a patch and testing before RC1 which is scheduled for Wednesday, Sept 1.
#13
@
3 years ago
Submitted a patch, but it is only valid if this PR from Gutenberg is also merged: https://github.com/WordPress/gutenberg/pull/30617
#15
@
3 years ago
- Keywords needs-testing removed
https://github.com/WordPress/gutenberg/pull/30617 has been merged in GitHub and is marked for backporting. Leaving this open for now, but this will be resolved when the Gutenberg packages are updated.
This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.
3 years ago
#17
@
3 years ago
Tested and commented in PR https://github.com/WordPress/gutenberg/pull/30617#issuecomment-910198556, the bug is not reproduced.
This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.
3 years ago
#19
@
3 years ago
- Owner set to desrosj
- Resolution set to fixed
- Status changed from new to closed
In 51719:
Hi @terraling,
Welcome to Trac!
I've done some testing and I am able to reproduce the issue you are describing (thanks for the proof of concept code)!
Based on my testing, it seems that the post type is not being included in the request, so
$page
is empty withinwp_ajax_meta_box_order()
, causing the meta key to be incorrect (relevant source code). The resulting keys aremeta-box-order_
instead ofmeta-box-order_post
,meta-box-order_page
, etc.When the page refreshes, it is unable to find the user's preferred ordering for that post type. I tested with pages, and it seems to happen regardless of post type.
I'm moving this to 5.7.1 to investigate further, but this may require an issue and fix over on the Gutenberg GitHub repository.