Make WordPress Core

Opened 11 years ago

Last modified 5 years ago

#25819 new defect (bug)

"ms_files_rewriting" site option is not created during upgrades

Reported by: gradyetc's profile gradyetc Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Upgrade/Install Keywords: needs-patch
Focuses: multisite Cc:

Description

While testing an upgrade for a MU era multisite install from 3.1.4 -> 3.6.1 I discovered that the "ms_files_rewriting" site option was not being created.

The attempt in upgrade_network()...

if ( $wp_current_db_version < 21823 )
 	update_site_option( 'ms_files_rewriting', '1' );
}

... is failing. I believe this has gone unnoticed since the default value is forced to true in wp-includes/ms-default-filters.php:

// If the network upgrade hasn't run yet, assume ms-files.php rewriting is used.
add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );

Attachments (1)

25819.patch (503 bytes) - added by gradyetc 11 years ago.

Download all attachments as: .zip

Change History (8)

@gradyetc
11 years ago

#1 @gradyetc
11 years ago

The call to update_site_option( 'ms_files_rewriting', '1' ) in upgrade_network() is failing due to that filter.

In most cases the "ms_files_rewriting" site option will not exist when running the upgrade. The default value added by that filter causes the check within update_site_option that would normally add it to fail:

if ( false === $oldvalue )
	return add_site_option( $option, $value );

The end result is it continues, attempting to UPDATE a non-existent meta_key within wp_sitemeta.

UPDATE `wp_sitemeta` SET `meta_value` = '1' WHERE `site_id` = 1 AND `meta_key` = 'ms_files_rewriting'

A fix is attached in 25819.patch.

#2 @SergeyBiryukov
11 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.8

#3 @dd32
11 years ago

25819.patch looks good, however, it'll only apply to future users updating their networks, anyone who has updated past-3.5 won't trigger this again.

Perhaps we should also add a 3.8 update check that checks to see if the row exists in the DB at all, and if not, creates it?

#4 @nacin
10 years ago

  • Keywords 3.9-early added
  • Milestone changed from 3.8 to Future Release

Let's deal with this at once.

#5 @gradyetc
10 years ago

Perhaps something like this in upgrade_network() or a 3.9 upgrade routine?

$ms_files_rewriting = get_site_option( 'ms_files_rewriting' );

remove_all_filters( 'default_site_option_ms_files_rewriting' );

if ( get_site_option( 'ms_files_rewriting' ) != $ms_files_rewriting ) {
	update_site_option( 'ms_files_rewriting', intval( $ms_files_rewriting ) );
}

#6 @chriscct7
9 years ago

  • Keywords needs-patch added; has-patch 3.9-early removed
  • Severity changed from minor to normal

#7 @jeremyfelt
8 years ago

  • Focuses multisite added
Note: See TracTickets for help on using tickets.