Make WordPress Core


Ignore:
Timestamp:
10/16/2020 02:41:15 AM (4 years ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-taxonomy.php

    r49141 r49171  
    427427            empty( $args['update_count_by_callback'] )
    428428        ) {
    429             $args['update_count_by_callback'] = function( $tt_ids, $taxonomy, $modify_by ) {
     429            $args['update_count_by_callback'] = function( $tt_ids, $taxonomy ) use ( $args ) {
    430430                return call_user_func( $args['update_count_callback'], $tt_ids, $taxonomy );
    431431            };
Note: See TracChangeset for help on using the changeset viewer.