Make WordPress Core

Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#41685 closed enhancement (fixed)

Save database version in site meta (Multisite)

Reported by: spacedmonkey's profile spacedmonkey Owned by: whyisjake's profile whyisjake
Milestone: 5.3 Priority: normal
Severity: normal Version: 3.0
Component: Networks and Sites Keywords: has-patch has-dev-note
Focuses: multisite Cc:

Description

Currently there is there a table in multisite called blog_versions. All this table stores is the database version as number and the date updated. With plans to add site meta in #37923 this new table should be used. This has a number of benefits, including functions to CRUD these values in the database. Once this data is in the blogmeta, table, the blog_versions table can be removed all together. If require a SQL view can be used blog_versions from data stored in blogmeta.

Attachments (2)

41685.diff (977 bytes) - added by spacedmonkey 7 years ago.
41865-2.patch (620 bytes) - added by leogermani 5 years ago.
refreshed patch

Download all attachments as: .zip

Change History (16)

@spacedmonkey
7 years ago

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


7 years ago

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


7 years ago

#4 @spacedmonkey
5 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 5.3

I think we are ready for this in 5.3.

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


5 years ago

#6 @leogermani
5 years ago

  • Keywords needs-refresh added

Looks like this patch needs refresh.

Working on this and on unit tests at the DevDay WCEU2019

@leogermani
5 years ago

refreshed patch

#7 @leogermani
5 years ago

  • Keywords needs-refresh removed

Patch

I've refreshed the patch, but looking at it I realized it only updates this info when a db upgrade runs... Isn't it a good idea to add this to the multisite activation somehow to make sure this information is always present? even in a fresh install?

Tests

I was not able to write the tests and would need some help here. Calling wp_upgrade() does not seem to trigger the actual function in the tests environment. Maybe something to do with the pluggable functions... Or maybe Im just missing somehting... Im not sure...

This is what I was working on for tests (draft code)

/**
 * @ticket 41685
 */
public function test_update_db_info_upon_db_update() {
	
	if ( ! is_site_meta_supported() ) {
		$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
	}
	
	global $wp_db_version;
	// force a fake upgrade
	$wp_db_version ++;
	
	wp_upgrade();
	
	$x = get_site_meta( self::$site_id, 'db_version', true );
	
	// check if current site metadata was upgraded...
}

#8 @whyisjake
5 years ago

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

#9 @whyisjake
5 years ago

  • Keywords commit added; needs-unit-tests removed

Got confirmation over in #19755 for this approach.

#10 @whyisjake
5 years ago

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

In 46193:

Networks and Sites: Save database version in site meta (Multisite)

Currently there is there a table in multisite called blog_versions. All this table stores is the database version as number and the date updated. With plans to add site meta in #37923 this new table should be used. This has a number of benefits, including functions to CRUD these values in the database. Once this data is in the blogmeta, table, the blog_versions table can be removed all together. If require a SQL view can be used blog_versions from data stored in blogmeta.

Props spacedmonkey, leogermani.

Fixes #41685. See #19755.

#11 @whyisjake
5 years ago

In 46194:

Multisite: Remove the redundant blog_versions table.

As part of the Multisite installation process, a blog_versions table is created. This table is never read from (except immediately prior to updating it), it's only ever inserted into or updated. It is not used to determine which blogs need to be upgraded.
This table was introduced in 3.0 when the WPMU schema was merged #11644 and it appears the table has never been used in core and is therefore redundant and may as well be removed.

Props johnbillion, nacin, ryan, johnjamesjacoby, whyisjake.

Fixes #19755. See #41685.

#12 @justinahinon
5 years ago

  • Keywords needs-dev-note added

#13 @justinahinon
5 years ago

Adding needs-dev-notes tag since I drafted a shared note for this and #19755.

https://make.wordpress.org/core/?p=66113&preview=1&_ppp=ddb7b957d8

Note: See TracTickets for help on using tickets.