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. Built from https://develop.svn.wordpress.org/trunk@50936 git-svn-id: http://core.svn.wordpress.org/trunk@50545 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
893beee31e
commit
cf90ff2427
|
@ -391,16 +391,17 @@ function sanitize_bookmark( $bookmark, $context = 'display' ) {
|
|||
* @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 @@ function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) {
|
|||
}
|
||||
}
|
||||
|
||||
// Restore the type for integer fields after esc_attr().
|
||||
if ( in_array( $field, $int_fields, true ) ) {
|
||||
$value = (int) $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-alpha-50935';
|
||||
$wp_version = '5.8-alpha-50936';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue