Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#41507 closed enhancement (fixed)

Replace $wpdb->siteid with get_current_network_id()

Reported by: spacedmonkey's profile spacedmonkey Owned by: sathyapulse's profile 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 7 years ago.
41507.1.diff (5.8 KB) - added by sathyapulse 7 years ago.
41507.2.diff (7.7 KB) - added by spacedmonkey 7 years ago.
41507.3.diff (8.1 KB) - added by flixos90 7 years ago.

Download all attachments as: .zip

Change History (16)

#1 @spacedmonkey
7 years 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
7 years ago

  • Keywords good-first-bug added

@sathyapulse
7 years ago

#3 @sathyapulse
7 years 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
7 years ago

  • Keywords has-patch added; needs-patch removed

#5 @spacedmonkey
7 years 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
7 years ago

#6 @sathyapulse
7 years 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.


7 years ago

#8 @flixos90
7 years ago

  • Milestone changed from Awaiting Review to 4.9

#9 @flixos90
7 years ago

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

@spacedmonkey
7 years ago

#10 @spacedmonkey
7 years 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
7 years ago

#11 @flixos90
7 years 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
7 years 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.