Ticket #18117: 18117.4.diff
File 18117.4.diff, 4.3 KB (added by , 10 years ago) |
---|
-
src/wp-includes/ms-blogs.php
296 296 297 297 $update_details = array(); 298 298 $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 } 301 304 305 $update_details[ $field ] = $details[ $field ]; 306 } 307 302 308 $result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) ); 303 309 304 310 if ( false === $result ) -
tests/phpunit/tests/multisite/site.php
293 293 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogpath', 'title' => 'Test Title' ) ); 294 294 $this->assertInternalType( 'int', $blog_id ); 295 295 296 $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => ' my_path/') );296 $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => '/my_path/') ); 297 297 $this->assertTrue( $result ); 298 298 299 299 $blog = get_blog_details( $blog_id ); 300 300 $this->assertEquals( 'example.com', $blog->domain ); 301 $this->assertEquals( ' my_path/', $blog->path );301 $this->assertEquals( '/my_path/', $blog->path ); 302 302 $this->assertEquals( '0', $blog->spam ); 303 303 304 304 $result = update_blog_details( $blog_id, array('domain' => 'example2.com','spam' => 1) ); 305 305 $this->assertTrue( $result ); 306 306 $blog = get_blog_details( $blog_id ); 307 307 $this->assertEquals( 'example2.com', $blog->domain ); 308 $this->assertEquals( ' my_path/', $blog->path );308 $this->assertEquals( '/my_path/', $blog->path ); 309 309 $this->assertEquals( '1', $blog->spam ); 310 310 311 311 $result = update_blog_details( $blog_id ); 312 312 $this->assertFalse( $result ); 313 313 $blog = get_blog_details( $blog_id ); 314 314 $this->assertEquals( 'example2.com', $blog->domain ); 315 $this->assertEquals( ' my_path/', $blog->path );315 $this->assertEquals( '/my_path/', $blog->path ); 316 316 $this->assertEquals( '1', $blog->spam ); 317 317 318 318 $test_action_counter = 0; … … 444 444 } 445 445 446 446 /** 447 * Check the path for a sub-directory site is correctly sanitised, 448 * and has a trailing slash. 449 * 450 * @ticket 18117 451 */ 452 function test_update_blog_sanitises_subdirectory_path() { 453 454 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 455 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogpath', 'title' => 'Test Title' ) ); 456 $this->assertInternalType( 'int', $blog_id ); 457 458 $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => 'my_path') ); 459 $blog = get_blog_details( $blog_id ); 460 $this->assertEquals( '/my_path/', $blog->path ); 461 462 $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => 'my_path//') ); 463 $blog = get_blog_details( $blog_id ); 464 $this->assertEquals( '/my_path/', $blog->path ); 465 466 $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => '//my_path') ); 467 $blog = get_blog_details( $blog_id ); 468 $this->assertEquals( '/my_path/', $blog->path ); 469 470 $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => '/my_path') ); 471 $blog = get_blog_details( $blog_id ); 472 $this->assertEquals( '/my_path/', $blog->path ); 473 474 $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => 'multiple/dirs') ); 475 $blog = get_blog_details( $blog_id ); 476 $this->assertEquals( '/multiple/dirs/', $blog->path ); 477 478 $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => 'multiple///dirs') ); 479 $blog = get_blog_details( $blog_id ); 480 $this->assertEquals( '/multiple/dirs/', $blog->path ); 481 } 482 483 /** 447 484 * Test cached data for a site that does not exist and then again after it exists. 448 485 * 449 486 * @ticket 23405