diff -r 34716fd837a4 -r be944660c56a wp/wp-includes/bookmark.php --- a/wp/wp-includes/bookmark.php Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-includes/bookmark.php Wed Sep 21 18:19:35 2022 +0200 @@ -53,11 +53,11 @@ $_bookmark = sanitize_bookmark( $_bookmark, $filter ); - if ( OBJECT == $output ) { + if ( OBJECT === $output ) { return $_bookmark; - } elseif ( ARRAY_A == $output ) { + } elseif ( ARRAY_A === $output ) { return get_object_vars( $_bookmark ); - } elseif ( ARRAY_N == $output ) { + } elseif ( ARRAY_N === $output ) { return array_values( get_object_vars( $_bookmark ) ); } else { return $_bookmark; @@ -391,16 +391,17 @@ * @param string $field The bookmark field. * @param mixed $value The bookmark field value. * @param int $bookmark_id Bookmark ID. - * @param string $context How to filter the field value. Accepts 'raw', 'edit', 'attribute', - * 'js', 'db', or 'display' + * @param string $context How to filter the field value. Accepts 'raw', 'edit', 'db', + * 'display', 'attribute', or 'js'. Default 'display'. * @return mixed The filtered value. */ function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) { + $int_fields = array( 'link_id', 'link_rating' ); + if ( in_array( $field, $int_fields, true ) ) { + $value = (int) $value; + } + switch ( $field ) { - case 'link_id': // ints - case 'link_rating': - $value = (int) $value; - break; case 'link_category': // array( ints ) $value = array_map( 'absint', (array) $value ); // We return here so that the categories aren't filtered. @@ -445,6 +446,11 @@ } } + // Restore the type for integer fields after esc_attr(). + if ( in_array( $field, $int_fields, true ) ) { + $value = (int) $value; + } + return $value; }