Opened 7 years ago
Closed 7 years ago
#42641 closed defect (bug) (fixed)
On multisite upgrade the wp_blog_versions table doesn't get updated
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.9.1 | Priority: | normal |
Severity: | major | Version: | 4.9 |
Component: | Upgrade/Install | Keywords: | has-patch fixed-major |
Focuses: | multisite | Cc: |
Description
Hi. Thanks for the great work with WP 4.9.
I noticed that in my multisite installation the wp_blog_versions doesn't get updated.
I manage to isolate the problem to the lines
https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/upgrade.php#L438 - line 442.
The code there:
- adds quotes to the table names and
- uses the mysql now() as php function which causes php warning
The code there is:
if ( $wpdb->get_row( $wpdb->prepare( 'SELECT blog_id FROM %s WHERE blog_id = %d', $wpdb->blog_versions, $site_id ) ) ) { $wpdb->query( $wpdb->prepare( 'UPDATE %s SET db_version = %d WHERE blog_id = %d', $wpdb->blog_versions, $wp_db_version, $site_id ) ); } else { $wpdb->query( $wpdb->prepare( 'INSERT INTO %s ( `blog_id` , `db_version` , `last_updated` ) VALUES ( %d, %d, %s);', $wpdb->blog_versions, $site_id, $wp_db_version, NOW() ) ); }
In my installation the following changes fixed the issue.
if ( $wpdb->get_row( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blog_versions WHERE blog_id = %d", $site_id ) ) ) { $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->blog_versions SET db_version = %d WHERE blog_id = %d", $wp_db_version, $site_id ) ); } else { $now = current_time( 'mysql' ); $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->blog_versions( `blog_id` , `db_version` ,`last_updated`) VALUES ( %d, %d, %s)", $site_id, $wp_db_version, $now ) ); }
Since I couldn't find a relavant ticket, I'm not sure if this is a bug or only in my installation (Running PHP 7.0.25).
Bests,
Lena
Attachments (1)
Change History (9)
#1
@
7 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 4.9.1
- Severity changed from normal to major
This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.
7 years ago
#3
@
7 years ago
- Owner set to flixos90
- Status changed from new to assigned
Seems like a rather straightforward fix. I'll take care of it, unless someone beats me to it.
#4
@
7 years ago
- Keywords has-patch added; needs-patch removed
Hi,
I have done a patch for this issue, thanks to @lenasterg and @flixos90
#5
@
7 years ago
- Status changed from assigned to reviewing
Thanks for the patch @Mista-Flo, and the detailed explanation @lenasterg! This looks like a solid fix.
Hello @lenasterg, thanks for your report!
This was introduced in [41661].