Make WordPress Core

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#52818 closed defect (bug) (fixed)

Ordering metaboxes broken in WP 5.7

Reported by: terraling's profile terraling Owned by: desrosj's profile 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)

52818.diff (1.3 KB) - added by ribaricplusplus 3 years ago.

Download all attachments as: .zip

Change History (22)

#1 @desrosj
4 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 5.7.1

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 within wp_ajax_meta_box_order(), causing the meta key to be incorrect (relevant source code). The resulting keys are meta-box-order_ instead of meta-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.

#2 @desrosj
4 years ago

Related: #50699.

#3 @peterwilsoncc
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 @vladytimy
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 @audrasjb
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 @dd32
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 @desrosj
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.

#11 @desrosj
3 years ago

  • Milestone changed from 5.7.3 to 5.8.1

#12 @circlecube
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 @ribaricplusplus
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

#14 @circlecube
3 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

#15 @desrosj
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 @dariak
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 @desrosj
3 years ago

  • Owner set to desrosj
  • Resolution set to fixed
  • Status changed from new to closed

In 51719:

Editor: Update block editor packages for WordPress 5.8.1.

The following packages were updated:

  • @wordpress/a11y to 3.1.2
  • @wordpress/annotations to 2.1.6
  • @wordpress/api-fetch to 5.1.2
  • @wordpress/autop to 3.1.2
  • @wordpress/babel-preset-default to 6.2.1
  • @wordpress/blob to 3.1.2
  • @wordpress/block-directory to 2.1.21
  • @wordpress/block-editor to 6.1.14
  • @wordpress/block-library to 3.2.19
  • @wordpress/block-serialization-default-parser to 4.1.2
  • @wordpress/blocks to 9.1.8
  • @wordpress/components to 14.1.11
  • @wordpress/compose to 4.1.6
  • @wordpress/core-data to 3.1.12
  • @wordpress/customize-widgets to 1.0.20
  • @wordpress/data-controls to 2.1.6
  • @wordpress/data to 5.1.6
  • @wordpress/date to 4.1.2
  • @wordpress/deprecated to 3.1.2
  • @wordpress/dom-ready to 3.1.2
  • @wordpress/dom to 3.1.5
  • @wordpress/e2e-test-utils to 5.3.1
  • @wordpress/edit-post to 4.1.21
  • @wordpress/edit-widgets to 2.1.21
  • @wordpress/editor to 10.1.17
  • @wordpress/element to 3.1.2
  • @wordpress/escape-html to 2.1.2
  • @wordpress/format-library to 2.1.14
  • @wordpress/html-entities to 3.1.2
  • @wordpress/i18n to 4.1.2
  • @wordpress/icons to 4.0.3
  • @wordpress/interface to 3.1.12
  • @wordpress/keyboard-shortcuts to 2.1.7
  • @wordpress/keycodes to 3.1.2
  • @wordpress/list-reusable-blocks to 2.1.11
  • @wordpress/media-utils to 2.1.2
  • @wordpress/notices to 3.1.6
  • @wordpress/nux to 4.1.11
  • @wordpress/plugins to 3.1.6
  • @wordpress/primitives to 2.1.2
  • @wordpress/priority-queue to 2.1.2
  • @wordpress/react-i18n to 2.1.2
  • @wordpress/redux-routine to 4.1.2
  • @wordpress/reusable-blocks to 2.1.17
  • @wordpress/rich-text to 4.1.6
  • @wordpress/scripts to 16.1.5
  • @wordpress/server-side-render to 2.1.12
  • @wordpress/shortcode to 3.1.2
  • @wordpress/url to 3.1.2
  • @wordpress/viewport to 3.1.6
  • @wordpress/warning to 2.1.2
  • @wordpress/widgets to 1.1.19
  • @wordpress/wordcount to 3.1.2

Props oandregal, juanmaguitar, gziolo, jblz, talldanwp, ribaricplusplus, peterwisoncc, youknowriad, paaljoachim, kreppar, ellatrix, aristath, walbo, ajlende, kevin940726, mamaduka, ntsekouras, toro_unit, mkaz, joen, noisysocks, zieladam, andraganescu, antonvlasenko, terraling, dariak, vladytimy, circlecube, desrosj.
Fixes #54052, #52818.

#20 @ribaricplusplus
3 years ago

It would still be nice if we applied the patch that I submitted here. It is not absolutely necessary but it makes the code nicer and less complex.

#21 @desrosj
3 years ago

In 51721:

Editor: Update block editor packages for WordPress 5.8.1.

The following packages were updated:

  • @wordpress/a11y to 3.1.2
  • @wordpress/annotations to 2.1.6
  • @wordpress/api-fetch to 5.1.2
  • @wordpress/autop to 3.1.2
  • @wordpress/babel-preset-default to 6.2.1
  • @wordpress/blob to 3.1.2
  • @wordpress/block-directory to 2.1.21
  • @wordpress/block-editor to 6.1.14
  • @wordpress/block-library to 3.2.19
  • @wordpress/block-serialization-default-parser to 4.1.2
  • @wordpress/blocks to 9.1.8
  • @wordpress/components to 14.1.11
  • @wordpress/compose to 4.1.6
  • @wordpress/core-data to 3.1.12
  • @wordpress/customize-widgets to 1.0.20
  • @wordpress/data-controls to 2.1.6
  • @wordpress/data to 5.1.6
  • @wordpress/date to 4.1.2
  • @wordpress/deprecated to 3.1.2
  • @wordpress/dom-ready to 3.1.2
  • @wordpress/dom to 3.1.5
  • @wordpress/e2e-test-utils to 5.3.1
  • @wordpress/edit-post to 4.1.21
  • @wordpress/edit-widgets to 2.1.21
  • @wordpress/editor to 10.1.17
  • @wordpress/element to 3.1.2
  • @wordpress/escape-html to 2.1.2
  • @wordpress/format-library to 2.1.14
  • @wordpress/html-entities to 3.1.2
  • @wordpress/i18n to 4.1.2
  • @wordpress/icons to 4.0.3
  • @wordpress/interface to 3.1.12
  • @wordpress/keyboard-shortcuts to 2.1.7
  • @wordpress/keycodes to 3.1.2
  • @wordpress/list-reusable-blocks to 2.1.11
  • @wordpress/media-utils to 2.1.2
  • @wordpress/notices to 3.1.6
  • @wordpress/nux to 4.1.11
  • @wordpress/plugins to 3.1.6
  • @wordpress/primitives to 2.1.2
  • @wordpress/priority-queue to 2.1.2
  • @wordpress/react-i18n to 2.1.2
  • @wordpress/redux-routine to 4.1.2
  • @wordpress/reusable-blocks to 2.1.17
  • @wordpress/rich-text to 4.1.6
  • @wordpress/scripts to 16.1.5
  • @wordpress/server-side-render to 2.1.12
  • @wordpress/shortcode to 3.1.2
  • @wordpress/url to 3.1.2
  • @wordpress/viewport to 3.1.6
  • @wordpress/warning to 2.1.2
  • @wordpress/widgets to 1.1.19
  • @wordpress/wordcount to 3.1.2

Props oandregal, juanmaguitar, gziolo, jblz, talldanwp, ribaricplusplus, peterwisoncc, youknowriad, paaljoachim, kreppar, ellatrix, aristath, walbo, ajlende, kevin940726, mamaduka, ntsekouras, toro_unit, mkaz, joen, noisysocks, zieladam, andraganescu, antonvlasenko, terraling, dariak, vladytimy, circlecube, desrosj.
Merges [51719] to the 5.8 branch.
Fixes #54052, #52818.

Note: See TracTickets for help on using tickets.