WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/14/2019 05:17:51 PM (2 months ago)
Author:
SergeyBiryukov
Message:

Posts, Post Types: In wp_trim_words() make sure the $num_words parameter is always an integer, as documented, to avoid a PHP warning.

Props donmhico, pikamander2.
Fixes #47867.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/WPTrimWords.php

    r45505 r45796  
    7474        $this->assertEquals( $expected, $actual );
    7575    }
     76
     77    /**
     78     * @ticket 47867
     79     */
     80    function test_works_with_non_numeric_num_words() {
     81        $this->assertEquals( '', wp_trim_words( $this->long_text, '', '' ) );
     82        $this->assertEquals( '', wp_trim_words( $this->long_text, 'abc', '' ) );
     83        $this->assertEquals( '', wp_trim_words( $this->long_text, null, '' ) );
     84        $this->assertEquals( 'Lorem ipsum dolor', wp_trim_words( $this->long_text, '3', '' ) );
     85    }
    7686}
Note: See TracChangeset for help on using the changeset viewer.