From eaf7f8df740a1957aa91c6653d0138c509ca8eae Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Mon, 12 Jan 2015 01:43:22 +0000 Subject: [PATCH] Enforce leading and trailing slashes on paths updated with `update_blog_details()` In multisite, core expects the stored value for a site's path to have leading and trailing slashes. When these slashes are missing, it becomes impossible to visit the site. This enforces proper `/path/` creation in `update_blog_details()`, most likely used when updating an existing site through `site-info.php`. Props earnjam, simonwheatley. Fixes #18117. Fixes #23865. Built from https://develop.svn.wordpress.org/trunk@31155 git-svn-id: http://core.svn.wordpress.org/trunk@31136 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-blogs.php | 10 ++++++++-- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index e1c70e1a8d..72ebbaa3a8 100644 --- a/wp-includes/ms-blogs.php +++ b/wp-includes/ms-blogs.php @@ -296,8 +296,14 @@ function update_blog_details( $blog_id, $details = array() ) { $update_details = array(); $fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'); - foreach ( array_intersect( array_keys( $details ), $fields ) as $field ) - $update_details[$field] = $details[$field]; + foreach ( array_intersect( array_keys( $details ), $fields ) as $field ) { + if ( 'path' === $field ) { + $details[ $field ] = array_filter( explode( '/', $details[ $field ] ) ); + $details[ $field ] = trailingslashit( '/' . implode( '/', $details[ $field ] ) ); + } + + $update_details[ $field ] = $details[ $field ]; + } $result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 8dfe0f24e1..4e90c73e79 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31154'; +$wp_version = '4.2-alpha-31155'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.