Make WordPress Core

Opened 13 years ago

Last modified 19 months ago

#17370 new defect (bug)

Screen options and meta box settings can lose per-blog meta box positions

Reported by: jmdodd's profile jmdodd Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1
Component: Users Keywords: needs-patch
Focuses: ui, administration, multisite Cc:

Description (last modified by sabernhardt)

User preferences for admin interface appearance of the Dashboard and the Edit/Add New pages are stored in per-user options in wp_usermeta: closedpostboxes_$page, metaboxhidden_$page, meta-box-order_$page, and screen_layout_$page, where $page is one of 'post', 'page', or 'dashboard'. Users can customize the order of the Dashboard and editing meta boxes to better suit their workflow using the drag-and-drop AJAX interface to move the meta boxes into ordered columns and the Screen Options tab to show and hide the boxes. Many plugins add custom meta boxes to the Edit/Add New Post page.

In a multisite installation, with different plugins active on different blogs, users who rearrange an Add New Post page on a blog with a custom meta box and then rearrange it on a different blog without that meta box will lose the position of the custom meta box. Blogs can have different features and workflows implemented, and having per user options for the appearance instead of per user, per blog options limits the ability of a user to customize the interface.

The expected behavior for moving things around is that it changes on one blog, not on all blogs.

Change History (9)

#1 @Viper007Bond
13 years ago

  • Summary changed from Screen options and meta box settings in multisite apply across all of a user's blogs to Screen options and meta box settings can strip per-blog meta boxes

As discussed on IRC, global settings for this is intentional and desired. The stripping of box position when they are not currently defined however is not desired.

#2 @Viper007Bond
13 years ago

  • Summary changed from Screen options and meta box settings can strip per-blog meta boxes to Screen options and meta box settings can lose per-blog meta box positions

#3 @SergeyBiryukov
13 years ago

  • Keywords needs-patch added

#4 @chriscct7
10 years ago

  • Focuses ui administration added

#5 @chriscct7
8 years ago

  • Version changed from 3.1.2 to 3.1

#6 @TobiasBg
23 months ago

  • Milestone set to 6.1

I've been running into this as well, with different plugins being active on different sites on a network, and these user options overriding each other for the different sites. I therefore fully agree, that these user options should be per-user and per-site, instead of per-user only.

The change should not be difficult, and it should not bring backwards compat issues.
In fact, this change had been made in the past at one point already. I went down the rabbit hole on this a bit, focussing on the closedpostboxes_$page setting for now:

  • Essentially, there's a "setter" wp_ajax_closed_postboxes() and a "getter" postbox_classes() for this option, no other code seems to be interacting with it.
  • Both were introduced in [6584], before WP 3.0 multisite merge (thus, the problem didn't exist back then).
  • In [9871], this was inadvertently changed in the "getter" postbox_classes(), so that suddenly with the multisite merge in WP 3.0, it would be compatible to per-user per-site settings, in addition to the existing per-user only setting.
  • In #12439, non-saving of the settings was observed, with [13551] actually turning this setting into a per-user per-site setting (without fully noticing it, it seems).
  • This again was noticed in #13032, which resulted in [14112] making the setting global per-user again.
  • ("Recently", but just a technicality without functional change, the update_user_option( ..., true ) was changed to update_user_meta() to save function calls, in [50981].)

So, in summary, the "getter" postbox_classes() is ready to use both the per-user per-site setting as well as the per-user only setting (as a fallback), thanks to using get_user_option().
This means that changing the "setter" wp_ajax_closed_postboxes() to use a per-user per-site setting is possible, without breaking backwards compatibility (the existing per-user setting will be used on all sites where no new per-user per-site setting has been saved). There will be a behavioral change though, that in worst case would mean that a user has to change/adjust metabox visibility/state on multiple sites of a network, instead of just once.
The advantage however would be that different plugins on different sites would not run into issues with their metaboxes state changes influencing each other, as outlined in the ticket description.

The necessary code change would be basically revert [50981] (partially) and then [14112] (for the wp_ajax_closed_postboxes() function), i.e. changing

update_user_meta( $user->ID, "closedpostboxes_$page", $closed );

to

update_user_option( $user->ID, "closedpostboxes_{$page}", $closed, false );

(and everything likewise for the metaboxhidden_$page, meta-box-order_$page, and screen_layout_$page user options.)

Last edited 19 months ago by TobiasBg (previous) (diff)

#7 @sabernhardt
23 months ago

  • Description modified (diff)
  • Focuses multisite added

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


19 months ago

#9 @audrasjb
19 months ago

  • Milestone changed from 6.1 to Future Release

Thanks for sharing so much details about the issue and potential fix @TobiasBg!

Unfortunately, we're at an advanced stage of 6.1 release cycle…
As per today's bug scrub, and since there is no patch for now, let's move it to Future Release for now.

Patch welcome! 🙏

Note: See TracTickets for help on using tickets.