Make WordPress Core

Opened 5 years ago

#48442 new defect (bug)

deleting a site leaves "orphaned" user options

Reported by: pbiron's profile pbiron Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords:
Focuses: multisite Cc:


When a site/blog is deleted, whether from the Network > Sites screen or via wp_delete_site(), most "per site" user options (i.e., those added with update_user_option() where $global == false) remain in the usermeta table. The capabilities and user_level ones are deleted, but all others remain.

Core adds at least the following such user options:

  • dashboard_quick_press_last_post_id
  • media_library_mode
  • user-settings
  • user-settings-time

and plugins often add others (e.g., classic editor adds classic-editor-settings).

In a large network (with many users and many sites that have been deleted) this can result in significant bloat to the usermeta table.

To reproduce:

  1. create a network and add at least 1 site in addition to the main site (e.g., with blog_id == 2)
    • can be either sub-domain or sub-directory network
  2. visit the dashboard of the site with blog_id == 2
    • this will create the wp_2_dashboard_quick_press_last_post_id user meta
  3. delete the site with blog_id == 2
  4. see that wp_2_capabilities and wp_2_user_level user metas have been deleted from the usermeta table but that wp_2_dashboard_quick_press_last_post_id remains

Change History (0)

Note: See TracTickets for help on using tickets.