Make WordPress Core


Ignore:
Timestamp:
05/20/2021 12:03:04 AM (4 years ago)
Author:
SergeyBiryukov
Message:

General: Ensure consistent type for integer properties of a bookmark object.

Previously, these properties could be unexpectedly converted to strings in some contexts.

This applies to the following function:

  • sanitize_bookmark_field()

and the following properties:

  • $bookmark::link_id
  • $bookmark::link_rating

Follow-up to [50935].

See #53235.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/bookmark/getBookmark.php

    r50789 r50936  
    342342
    343343    /**
     344     * @ticket 53235
     345     */
     346    public function test_numeric_properties_should_be_cast_to_ints() {
     347        $contexts = array( 'raw', 'edit', 'db', 'display', 'attribute', 'js' );
     348
     349        foreach ( $contexts as $context ) {
     350            $bookmark = get_bookmark( self::$bookmark->link_id, OBJECT, $context );
     351
     352            $this->assertInternalType( 'int', $bookmark->link_id );
     353            $this->assertInternalType( 'int', $bookmark->link_rating );
     354        }
     355    }
     356
     357    /**
    344358     * Initialize the get_bookmark's function arguments to match the order of the function's signature and
    345359     * reduce code in the tests.
Note: See TracChangeset for help on using the changeset viewer.