Make WordPress Core

Changeset 48435


Ignore:
Timestamp:
07/11/2020 12:12:46 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict type check for in_array() in wp-includes/feed.php.

Additionally:

  • Correct inline comments per the documentation standards.
  • Correct the @ticket reference in tests/feed/atom.php.

Follow-up to [48429].

See #33591.

Location:
trunk
Files:
2 edited

Legend:

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

    r48429 r48435  
    527527                                $mimes = get_allowed_mime_types();
    528528
    529                                 // Parse url
     529                                // Parse URL.
    530530                                if ( isset( $enclosure[0] ) && is_string( $enclosure[0] ) ) {
    531531                                        $url = trim( $enclosure[0] );
    532532                                }
    533533
    534                                 // Parse length and type
    535                                 foreach ( range( 1, 2 ) as $i ) {
     534                                // Parse length and type.
     535                                for ( $i = 1; $i <= 2; $i++ ) {
    536536                                        if ( isset( $enclosure[ $i ] ) ) {
    537537                                                if ( is_numeric( $enclosure[ $i ] ) ) {
    538538                                                        $length = trim( $enclosure[ $i ] );
    539                                                 } elseif ( in_array( $enclosure[ $i ], $mimes ) ) {
     539                                                } elseif ( in_array( $enclosure[ $i ], $mimes, true ) ) {
    540540                                                        $type = trim( $enclosure[ $i ] );
    541541                                                }
    … …  
    549549                                        esc_attr( $type )
    550550                                );
     551
    551552                                /**
    552553                                 * Filters the atom enclosure HTML link tag for the current post.
  • trunk/tests/phpunit/tests/feed/atom.php

    r48431 r48435  
    208208
    209209        /**
    210          * @test 33591
     210         * @ticket 33591
    211211         */
    212212        function test_atom_enclosure_with_extended_url_length_type_parsing() {
    213213                $enclosures = array(
    214214                        array(
    215                                 'actual'   => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4\n318465\nvideo/mp4",     // url length type
     215                                // URL, length, type.
     216                                'actual'   => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4\n318465\nvideo/mp4",
    216217                                'expected' => array(
    217218                                        'href'   => 'https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4',
    … …  
    221222                        ),
    222223                        array(
    223                                 'actual'   => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4\nvideo/mp4\n318465",     // url type length
     224                                // URL, type, length.
     225                                'actual'   => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4\nvideo/mp4\n318465",
    224226                                'expected' => array(
    225227                                        'href'   => 'https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4',
    … …  
    229231                        ),
    230232                        array(
    231                                 'actual'   => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4\n318465",                // url length
     233                                // URL, length.
     234                                'actual'   => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4\n318465",
    232235                                'expected' => array(
    233236                                        'href'   => 'https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4',
    … …  
    237240                        ),
    238241                        array(
    239                                 'actual'   => "https://wordpress.dev/wp-content/uploads/2017/01/audio.mp3\n\naudio/mpeg",          // url type
     242                                // URL, type.
     243                                'actual'   => "https://wordpress.dev/wp-content/uploads/2017/01/audio.mp3\n\naudio/mpeg",
    240244                                'expected' => array(
    241245                                        'href'   => 'https://wordpress.dev/wp-content/uploads/2017/01/audio.mp3',
    … …  
    245249                        ),
    246250                        array(
    247                                 'actual'   => 'https://wordpress.dev/wp-content/uploads/2016/01/test.mp4',                         // url
     251                                // URL.
     252                                'actual'   => 'https://wordpress.dev/wp-content/uploads/2016/01/test.mp4',
    248253                                'expected' => array(
    249254                                        'href'   => 'https://wordpress.dev/wp-content/uploads/2016/01/test.mp4',
Note: See TracChangeset for help on using the changeset viewer.