Changeset 41606
- Timestamp:
- 09/27/2017 08:35:16 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/embed.php
r41600 r41606 1072 1072 */ 1073 1073 function wp_filter_pre_oembed_result( $result, $url, $args ) { 1074 $switched_blog = false; 1075 1074 1076 if ( is_multisite() ) { 1075 1077 $url_parts = wp_parse_args( wp_parse_url( $url ), array( … … 1095 1097 if ( $site && (int) $site->blog_id !== get_current_blog_id() ) { 1096 1098 switch_to_blog( $site->blog_id ); 1099 $switched_blog = true; 1097 1100 } 1098 1101 } … … 1112 1115 $data = _wp_oembed_get_object()->data2html( (object) $data, $url ); 1113 1116 1114 if ( is_multisite() && ms_is_switched()) {1117 if ( $switched_blog ) { 1115 1118 restore_current_blog(); 1116 1119 } -
trunk/tests/phpunit/tests/oembed/wpOembed.php
r41600 r41606 172 172 $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); 173 173 } 174 175 /** 176 * @ticket 40673 177 * @group multisite 178 * @group ms-required 179 */ 180 public function test_wp_filter_pre_oembed_result_multisite_preserves_switched_state() { 181 $user_id = self::factory()->user->create(); 182 183 $blog_id = self::factory()->blog->create( array( 'user_id' => $user_id ) ); 184 switch_to_blog( $blog_id ); 185 186 $expected_stack = $GLOBALS['_wp_switched_stack']; 187 188 $post_id = self::factory()->post->create(); 189 $permalink = get_permalink( $post_id ); 190 191 add_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) ); 192 $actual = $this->oembed->get_html( $permalink ); 193 remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) ); 194 195 $actual_stack = $GLOBALS['_wp_switched_stack']; 196 197 restore_current_blog(); 198 199 $this->assertNotNull( $this->pre_oembed_result_filtered ); 200 $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); 201 $this->assertSame( $expected_stack, $actual_stack ); 202 } 174 203 }
Note: See TracChangeset
for help on using the changeset viewer.