[wp-trac] [WordPress Trac] #42641: On multisite upgrade the wp_blog_versions table doesn't get updated

WordPress Trac noreply at wordpress.org
Mon Nov 20 14:22:57 UTC 2017


#42641: On multisite upgrade the wp_blog_versions table doesn't get updated
-----------------------------+-----------------------------
 Reporter:  lenasterg        |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Upgrade/Install  |    Version:  4.9
 Severity:  normal           |   Keywords:
  Focuses:  multisite        |
-----------------------------+-----------------------------
 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

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42641>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list