Taxonomy: Fix warnings thrown by custom term count callbacks.

Add a `use` to a closure to avoid an undefined variable throwing a warning. Adds unit tests to ensure the custom callbacks run as expected when defined.

Follow up to [49141].
Props ocean90, dd32.
Fixes #40351.


Built from https://develop.svn.wordpress.org/trunk@49171


git-svn-id: http://core.svn.wordpress.org/trunk@48933 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2020-10-16 02:43:06 +00:00
parent 81ce3c1335
commit cd8b13842f
2 changed files with 2 additions and 2 deletions

View File

@ -426,7 +426,7 @@ final class WP_Taxonomy {
is_callable( $args['update_count_callback'] ) &&
empty( $args['update_count_by_callback'] )
) {
$args['update_count_by_callback'] = function( $tt_ids, $taxonomy, $modify_by ) {
$args['update_count_by_callback'] = function( $tt_ids, $taxonomy ) use ( $args ) {
return call_user_func( $args['update_count_callback'], $tt_ids, $taxonomy );
};
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-alpha-49170';
$wp_version = '5.6-alpha-49171';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.