mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-22 00:01:27 +01:00
Code Modernization: Correct the check for parent
argument in wp_insert_term()
and wp_update_term()
.
PHP 8 changes the way string to number comparisons are performed: https://wiki.php.net/rfc/string_to_number_comparison In particular, checking if a non-empty, non-numeric string is greater than zero in PHP 8 evaluates to `true`, not `false`. For `wp_insert_term()`, this resulted in a "Parent term does not exist" error for a non-numeric string, instead of discarding the value. By explicitly casting the value to `int`, we make sure to compare both values as numbers, rather than a string and a number. Follow-up to [29196], [29830], [29867]. See #50913. Built from https://develop.svn.wordpress.org/trunk@49043 git-svn-id: http://core.svn.wordpress.org/trunk@48805 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cfe5b1c9f2
commit
4f8f42747f
@ -2233,7 +2233,7 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||||||
);
|
);
|
||||||
$args = wp_parse_args( $args, $defaults );
|
$args = wp_parse_args( $args, $defaults );
|
||||||
|
|
||||||
if ( $args['parent'] > 0 && ! term_exists( (int) $args['parent'] ) ) {
|
if ( (int) $args['parent'] > 0 && ! term_exists( (int) $args['parent'] ) ) {
|
||||||
return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
|
return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3001,7 +3001,7 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
|||||||
return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) );
|
return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $parsed_args['parent'] > 0 && ! term_exists( (int) $parsed_args['parent'] ) ) {
|
if ( (int) $parsed_args['parent'] > 0 && ! term_exists( (int) $parsed_args['parent'] ) ) {
|
||||||
return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
|
return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.6-alpha-49042';
|
$wp_version = '5.6-alpha-49043';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user