mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@31155 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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) );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user