Changeset 29745
- Timestamp:
- 09/15/2014 02:23:31 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r29468 r29745 4720 4720 $defaults = array( 4721 4721 'file' => $file, 4722 'post_parent' => $parent4722 'post_parent' => 0 4723 4723 ); 4724 4724 4725 $data = wp_parse_args( $args, $defaults ); 4726 4727 if ( ! empty( $parent ) ) { 4728 $data['post_parent'] = $parent; 4729 } 4725 4730 4726 4731 $data['post_type'] = 'attachment'; -
trunk/tests/phpunit/tests/post/attachments.php
r29120 r29745 255 255 } 256 256 257 /** 258 * @ticket 29646 259 */ 260 function test_update_orphan_attachment_parent() { 261 $filename = ( DIR_TESTDATA . '/images/test-image.jpg' ); 262 $contents = file_get_contents( $filename ); 263 264 $upload = wp_upload_bits( basename( $filename ), null, $contents ); 265 $this->assertTrue( empty( $upload['error'] ) ); 266 267 $attachment_id = $this->_make_attachment( $upload ); 268 269 // Assert that the attachment is an orphan 270 $attachment = get_post( $attachment_id ); 271 $this->assertEquals( $attachment->post_parent, 0 ); 272 273 $post_id = wp_insert_post( array( 'post_content' => rand_str(), 'post_title' => rand_str() ) ); 274 275 // Assert that the attachment has a parent 276 wp_insert_attachment( $attachment, '', $post_id ); 277 $attachment = get_post( $attachment_id ); 278 $this->assertEquals( $attachment->post_parent, $post_id ); 279 } 280 257 281 }
Note: See TracChangeset
for help on using the changeset viewer.