Make WordPress Core


Ignore:
Timestamp:
01/12/2015 01:42:46 AM (10 years ago)
Author:
jeremyfelt
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-blogs.php

    r30656 r31155  
    297297    $update_details = array();
    298298    $fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id');
    299     foreach ( array_intersect( array_keys( $details ), $fields ) as $field )
    300         $update_details[$field] = $details[$field];
     299    foreach ( array_intersect( array_keys( $details ), $fields ) as $field ) {
     300        if ( 'path' === $field ) {
     301            $details[ $field ] = array_filter( explode( '/', $details[ $field ] ) );
     302            $details[ $field ] = trailingslashit( '/' . implode( '/', $details[ $field ] ) );
     303        }
     304
     305        $update_details[ $field ] = $details[ $field ];
     306    }
    301307
    302308    $result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
Note: See TracChangeset for help on using the changeset viewer.