Make WordPress Core

Changeset 41634


Ignore:
Timestamp:
09/28/2017 04:28:46 PM (9 years ago)
Author:
ocean90
Message:

Embeds: In switched state, restore previous state if no post ID is found.

Fixes #40673.

Location:
trunk
Files:
2 edited

Legend:

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

    r41606 r41634  
    11071107
    11081108        if ( ! $post_id ) {
     1109                if ( $switched_blog ) {
     1110                        restore_current_blog();
     1111                }
     1112
    11091113                return $result;
    11101114        }
  • trunk/tests/phpunit/tests/oembed/wpOembed.php

    r41606 r41634  
    201201                $this->assertSame( $expected_stack, $actual_stack );
    202202        }
     203
     204        /**
     205         * @ticket 40673
     206         * @group multisite
     207         * @group ms-required
     208         */
     209        public function test_wp_filter_pre_oembed_result_multisite_restores_state_if_no_post_is_found() {
     210                $current_blog_id = get_current_blog_id();
     211
     212                $user_id = self::factory()->user->create();
     213                $blog_id = self::factory()->blog->create( array(
     214                        'user_id' => $user_id,
     215                ) );
     216
     217                $permalink = get_home_url( $blog_id, '/foo/' );
     218
     219                add_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
     220                $actual = $this->oembed->get_html( $permalink );
     221                remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
     222
     223                $this->assertNull( $this->pre_oembed_result_filtered );
     224                $this->assertFalse( $actual );
     225                $this->assertSame( $current_blog_id, get_current_blog_id() );
     226        }
    203227}
Note: See TracChangeset for help on using the changeset viewer.