WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 2 months ago

#41507 closed enhancement (fixed)

Replace $wpdb->siteid with get_current_network_id()

Reported by: spacedmonkey Owned by: sathyapulse
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.6
Component: Networks and Sites Keywords: good-first-bug has-patch commit
Focuses: multisite Cc:

Description

The helper function get_current_network_id() was introduced in 4.6. It is already used in a number of places, however there was still references to $wpdb->siteid throughout the core.

Attachments (4)

41507.diff (5.3 KB) - added by sathyapulse 3 months ago.
41507.1.diff (5.8 KB) - added by sathyapulse 3 months ago.
41507.2.diff (7.7 KB) - added by spacedmonkey 2 months ago.
41507.3.diff (8.1 KB) - added by flixos90 2 months ago.

Download all attachments as: .zip

Change History (16)

#1 @spacedmonkey
3 months ago

Usage in

  • get_active_blog_for_user
  • wpmu_activate_signup
  • get_last_updated
  • can_edit_network

Less important as deprecated

  • wp_get_sites
  • get_admin_users_for_domain
  • get_blog_list
  • validate_another_blog_signup

#2 @spacedmonkey
3 months ago

  • Keywords good-first-bug added

@sathyapulse
3 months ago

#3 @sathyapulse
3 months ago

@spacedmonkey I have attached the patch file with the ticket which addresses the replace of $wpdb->siteid with get_current_network_id() in the functions mentioned. Additionally I found the usage in the function wp_load_core_site_options and replaced it. Could you please check the patch and let me know your thoughts?

#4 @sathyapulse
3 months ago

  • Keywords has-patch added; needs-patch removed

#5 @spacedmonkey
3 months ago

@sathyapulse Great work.

Couple of things. Can you make sure to remove the global $wpdb references and update the docs.

There are also 7 references in the phpunit tests to $wpdb->siteid that should be replaced.

@sathyapulse
3 months ago

#6 @sathyapulse
3 months ago

@spacedmonkey I have created a new patch file by removing the global references. I am not sure about the changes in the phpunit tests. It's mostly in the assignment. Could you please be clear what needs to be removed? All the 7 occurrences?

This ticket was mentioned in Slack in #core-multisite by spacedmonkey. View the logs.


2 months ago

#8 @flixos90
2 months ago

  • Milestone changed from Awaiting Review to 4.9

#9 @flixos90
2 months ago

  • Owner set to sathyapulse
  • Status changed from new to assigned

#10 @spacedmonkey
2 months ago

41507.2.diff removes references to $wpdb->siteid in test. This basically means it is deprecated and is not used for anything.

@flixos90 what are your thoughts on officially deprecating it at some point.

@flixos90
2 months ago

#11 @flixos90
2 months ago

  • Keywords commit added

41507.3.diff ensures that it applies cleanly after the changes made in [41241]. It furthermore removes the hacky network switching logic from the unit tests completely, since that is no longer necessary as wp_update_network_site_counts() and wp_update_network_user_counts() now accept the $network_id as parameter.

#12 @flixos90
2 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 41242:

Multisite: Remove references to $wpdb->siteid and use get_current_network_id() instead.

Props sathyapulse, spacedmonkey.
Fixes #41507.

Note: See TracTickets for help on using tickets.