Changeset 25168
- Timestamp:
- 08/29/2013 06:48:29 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r25160 r25168 3672 3672 3673 3673 $inclusions = ''; 3674 if ( ! empty($include) ) {3674 if ( ! empty( $include ) ) { 3675 3675 $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include 3676 3676 $parent = -1; … … 3680 3680 $hierarchical = false; 3681 3681 $incpages = wp_parse_id_list( $include ); 3682 if ( ! empty( $incpages ) ) { 3683 foreach ( $incpages as $incpage ) { 3684 if (empty($inclusions)) 3685 $inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage); 3686 else 3687 $inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage); 3688 } 3689 } 3690 } 3691 if (!empty($inclusions)) 3692 $inclusions .= ')'; 3682 if ( ! empty( $incpages ) ) 3683 $inclusions = ' AND ID IN (' . implode( ',', array_map( 'intval', $incpages ) ) . ')'; 3684 } 3693 3685 3694 3686 $exclusions = ''; 3695 if ( ! empty($exclude) ) {3687 if ( ! empty( $exclude ) ) { 3696 3688 $expages = wp_parse_id_list( $exclude ); 3697 if ( ! empty( $expages ) ) { 3698 foreach ( $expages as $expage ) { 3699 if (empty($exclusions)) 3700 $exclusions = $wpdb->prepare(' AND ( ID <> %d ', $expage); 3701 else 3702 $exclusions .= $wpdb->prepare(' AND ID <> %d ', $expage); 3703 } 3704 } 3705 } 3706 if (!empty($exclusions)) 3707 $exclusions .= ')'; 3689 if ( ! empty( $expages ) ) 3690 $exclusions = ' AND ID NOT IN (' . implode( ',', array_map( 'intval', $expages ) ) . ')'; 3691 } 3708 3692 3709 3693 $author_query = ''; -
trunk/tests/phpunit/tests/post.php
r25002 r25168 20 20 parent::tearDown(); 21 21 } 22 22 23 23 // helper function: return the timestamp(s) of cron jobs for the specified hook and post 24 24 function _next_schedule_for_post($hook, $id) { 25 25 return wp_next_scheduled('publish_future_post', array(0=>intval($id))); 26 26 } 27 27 28 28 // helper function, unsets current user globally 29 29 function _unset_current_user() { 30 30 global $current_user, $user_ID; 31 31 32 32 $current_user = $user_ID = null; 33 33 } 34 34 35 35 // test simple valid behavior: insert and get a post 36 36 function test_vb_insert_get_delete() { … … 708 708 function test_insert_programmatic_sanitized() { 709 709 $this->_unset_current_user(); 710 710 711 711 register_taxonomy( 'test_tax', 'post' ); 712 712 713 713 $title = rand_str(); 714 714 $post_data = array( … … 723 723 $insert_post_id = wp_insert_post( $post_data, true, true ); 724 724 $this->assertTrue( ( is_int($insert_post_id) && $insert_post_id > 0 ) ); 725 725 726 726 $post = get_post( $insert_post_id ); 727 727 $this->assertEquals( $post->post_author, $this->author_id ); … … 734 734 function test_insert_programmatic_without_current_user_success() { 735 735 $this->_unset_current_user(); 736 736 737 737 register_taxonomy( 'test_tax', 'post' ); 738 738 739 739 $title = rand_str(); 740 740 $post_data = array( … … 749 749 // with sanitize set to false 750 750 $insert_post_id = wp_insert_post( $post_data, true, false ); 751 751 752 752 $post = get_post( $insert_post_id ); 753 753 $this->assertEquals( $post->post_author, $this->author_id ); 754 754 $this->assertEquals( $post->post_title, $title ); 755 755 756 756 $terms = wp_get_object_terms( $insert_post_id, 'test_tax' ); 757 757 $this->assertTrue( ( is_array( $terms ) && count( $terms ) == 3 ) ); … … 763 763 function test_insert_programmatic_without_current_user_fail() { 764 764 $this->_unset_current_user(); 765 765 766 766 register_taxonomy( 'test_tax', 'post' ); 767 767 768 768 $title = rand_str(); 769 769 $post_data = array( … … 799 799 $this->assertEquals( new stdClass, wp_count_posts( $post_type, 'readable' ) ); 800 800 } 801 802 /** 803 * @ticket 22074 804 */ 805 function test_get_pages_include_exclude() { 806 $page_ids = array(); 807 808 foreach ( range( 1, 20 ) as $i ) 809 $page_ids[] = $this->factory->post->create( array( 'post_type' => 'page' ) ); 810 811 $inc = array_slice( $page_ids, 0, 10 ); 812 sort( $inc ); 813 $exc = array_slice( $page_ids, 10 ); 814 sort( $exc ); 815 816 $include = get_pages( array( 'include' => $inc ) ); 817 $inc_result = wp_list_pluck( $include, 'ID' ); 818 sort( $inc_result ); 819 $this->assertEquals( $inc, $inc_result ); 820 821 $exclude = get_pages( array( 'exclude' => $exc ) ); 822 $exc_result = wp_list_pluck( $exclude, 'ID' ); 823 sort( $exc_result ); 824 $this->assertEquals( $inc, $exc_result ); 825 } 801 826 }
Note: See TracChangeset
for help on using the changeset viewer.