Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#46357 closed defect (bug) (fixed)

Don't prime site meta caches core functions

Reported by: spacedmonkey Owned by: flixos90
Priority: normal Milestone: 5.1.2
Component: Networks and Sites Version: 5.1
Severity: normal Keywords: has-patch fixed-major
Cc: Focuses: multisite, performance

Description

WP_Site_Query and get_sites are used in core functions to query the blogs table. As of 42836 site meta is in core and by default, primes the site meta caches on every WP_Site_Query call. However, in many places it is extremely unlikely the site meta will be required or used. For performance reasons, these calls that do not require site meta should be changed.

Attachments (1)

46357.diff (5.0 KB ) - added by spacedmonkey 7 years ago.

Download all attachments as: .zip

Change History (10)

#1 @spacedmonkey
7 years ago

The following functions should be changed to not prime site meta caches

  • get_site_by_path
  • get_oembed_response_data_for_url
  • get_id_from_blogname
  • wp_update_network_site_counts
  • domain_exists
  • get_main_site_id
  • network/upgrade.php

Maybes

  • get_blogs_of_user
  • get_blog_id_from_url
  • get_id_from_blogname

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


7 years ago

#3 @desrosj
7 years ago

  • Milestone Awaiting ReviewFuture Release

@spacedmonkey
7 years ago

#4 @spacedmonkey
7 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone Future Release5.1.2
  • Owner set to flixos90
  • Status newassigned

Added to 5.1.2 and assigning to @flixos90 for merge. More details #46167

#5 @flixos90
7 years ago

I think this is phrased incorrectly a little bit - if this is an enhancement, it shouldn't go into 5.1.x. However, it appears to be related to the bug #46167. Can you clarify how this is related? If this ticket indeed fixes a fatal error, it should probably be a "bug", not an "enhancement".

#6 @spacedmonkey
7 years ago

  • Type enhancementdefect (bug)

This is a bug and enhancement at the same time.

The fixes the issue in #46167 as the error happens in function get_site_by_path that calls prime site meta before the check is loaded.

The two patches together work hand in hand, to make that queries are a not run on a none existing table, generating the error.

@flixos90 if 5.2 is landing soon, I am happy that it goes in that.

#7 @flixos90
7 years ago

  • Resolutionfixed
  • Status assignedclosed

In 44926:

Multisite: Do not prime site meta caches unless necessary.

Props spacedmonkey.
Fixes #46357. See #46167.

#8 @flixos90
7 years ago

  • Keywords fixed-major added
  • Resolution fixed
  • Status closedreopened

#9 @flixos90
7 years ago

  • Resolutionfixed
  • Status reopenedclosed

In 44928:

Multisite: Do not prime site meta caches unless necessary.

Merges [44926] to the 5.1 branch.

Props spacedmonkey.
Fixes #46357. See #46167.

Note: See TracTickets for help on using tickets.