Make WordPress Core

Ticket #30566: fix-notice-with-tests-3.30566.diff

File fix-notice-with-tests-3.30566.diff, 1.8 KB (added by nerrad, 10 years ago)

sigh. the times when I wish I could delete submitted patches... This is the one that should be used.

  • src/wp-includes/ms-blogs.php

    diff --git src/wp-includes/ms-blogs.php src/wp-includes/ms-blogs.php
    index e1c70e1..11f9cb1 100644
    function wpmu_update_blogs_date() { 
    3737 */
    3838function get_blogaddress_by_id( $blog_id ) {
    3939        $bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details!
    40         return esc_url( 'http://' . $bloginfo->domain . $bloginfo->path );
     40        return isset( $bloginfo->domain ) && isset( $bloginfo->path ) ?  esc_url( 'http://' . $bloginfo->domain . $bloginfo->path ) : '';
    4141}
    4242
    4343/**
  • tests/phpunit/tests/multisite/site.php

    diff --git tests/phpunit/tests/multisite/site.php tests/phpunit/tests/multisite/site.php
    index 3dafbee..c82453e 100644
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    877877                $this->assertFalse( $site );
    878878        }
    879879
     880
     881        /**
     882         * Tests returning an address for both invalid and valid ids and that the appropriate responses occur.
     883         *
     884         */
     885        function test_get_blogaddress_by_id() {
     886                $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     887                $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id,  'path' => '/testdomainexists', 'title' => 'Test Title' ) );
     888
     889                // Test valid id.
     890                $blogaddress = get_blogaddress_by_id( $blog_id );
     891                $this->assertEquals( $blogaddress,  'http://example.org/testdomainexists/' );
     892
     893                //Test invalid id.
     894                $invalidblogaddress = get_blogaddress_by_id( 999 );
     895                $this->assertEquals( $invalidblogaddress, '' );
     896        }
     897
     898
     899
    880900        /**
    881901         * Test the original and cached responses for a created and then deleted site when
    882902         * the blog ID is requested through get_blog_id_from_url().
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    11211141        }
    11221142}
    11231143
    1124 endif;
    1125  No newline at end of file
     1144endif;