WordPress.org

Make WordPress Core

Opened 22 months ago

Last modified 6 days ago

#41685 new enhancement

Save database version in site meta (Multisite)

Reported by: spacedmonkey Owned by:
Milestone: 5.3 Priority: normal
Severity: normal Version: 3.0
Component: Networks and Sites Keywords: needs-unit-tests has-patch
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 22 months ago.
41865-2.patch (620 bytes) - added by leogermani 6 days ago.
refreshed patch

Download all attachments as: .zip

Change History (9)

@spacedmonkey
22 months ago

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


21 months ago

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


16 months ago

#4 @spacedmonkey
5 weeks 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.


3 weeks ago

#6 @leogermani
6 days ago

  • Keywords needs-refresh added

Looks like this patch needs refresh.

Working on this and on unit tests at the DevDay WCEU2019

@leogermani
6 days ago

refreshed patch

#7 @leogermani
6 days 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...
}
Note: See TracTickets for help on using tickets.