Make WordPress Core

Changeset 25924


Ignore:
Timestamp:
10/26/2013 02:54:21 AM (13 years ago)
Author:
nacin
Message:

3.7 regression from [25119]: Have in_category() return false when the first argument is empty.

Merges [25923] to the 3.7 branch.

props ericlewis.
fixes #25706.

Location:
branches/3.7
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src

  • branches/3.7/src/wp-includes/category-template.php

    r25662 r25924  
    233233 */
    234234function in_category( $category, $post = null ) {
     235        if ( empty( $category ) )
     236                return false;
     237
    235238        return has_category( $category, $post );
    236239}
  • branches/3.7/tests/phpunit/tests/taxonomy.php

    r25596 r25924  
    153153
    154154        }
     155        /**
     156         * @ticket 25706
     157         */
     158        function test_in_category() {
     159                $post = $this->factory->post->create_and_get();
     160
     161                // in_category() returns false when first parameter is empty()
     162                $this->assertFalse( in_category( '', $post ) );
     163                $this->assertFalse( in_category( false, $post ) );
     164                $this->assertFalse( in_category( null, $post ) );
     165
     166                // Test expected behavior of in_category()
     167                $term = wp_insert_term( 'Test', 'category' );
     168                wp_set_object_terms( $post->ID, $term['term_id'], 'category' );
     169                $this->assertTrue( in_category( $term['term_id'], $post ) );
     170        }
    155171}
Note: See TracChangeset for help on using the changeset viewer.