Make WordPress Core

Changeset 60299


Ignore:
Timestamp:
06/11/2025 03:27:43 PM (6 weeks ago)
Author:
SergeyBiryukov
Message:

Users: Correct get_the_author_posts() to always return an integer.

This matches the documented @return type.

Follow-up to [5638], [13576], [36085], [60296].

Props justlevine.
See #63268.

Location:
trunk
Files:
2 edited

Legend:

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

    r55755 r60299  
    287287        return 0;
    288288    }
    289     return count_user_posts( $post->post_author, $post->post_type );
     289    return (int) count_user_posts( $post->post_author, $post->post_type );
    290290}
    291291
  • trunk/tests/phpunit/tests/user/getTheAuthorPosts.php

    r55754 r60299  
    4343        $this->assertSame( 0, get_the_author_posts() );
    4444        $GLOBALS['post'] = self::$post_id;
    45         $this->assertEquals( 1, get_the_author_posts() );
     45        $this->assertSame( 1, get_the_author_posts() );
    4646    }
    4747
     
    6161        $GLOBALS['post'] = $cpt_ids[0];
    6262
    63         $this->assertEquals( 2, get_the_author_posts() );
     63        $this->assertSame( 2, get_the_author_posts() );
    6464
    6565        _unregister_post_type( 'wptests_pt' );
Note: See TracChangeset for help on using the changeset viewer.