Make WordPress Core

Changeset 62925


Ignore:
Timestamp:
07/29/2026 06:38:25 PM (6 weeks ago)
Author:
westonruter
Message:

Taxonomy: Pass the missing $args to several term hooks.

The edit_terms, edited_terms, edit_term_taxonomy, edited_term_taxonomy, and term_id_filter hooks have documented an $args parameter since 6.1.0, when r53627 added it. However, this new parameter was not passed to all instances of the hooks being fired, resulting in a possible fatal error if a callback is expecting it.

In wp_insert_term() and wp_update_term() the function's own $args is passed. In _update_post_term_count() and _update_generic_term_count() there is no such array, since the actions fire while recounting rather than while a term is being edited, so an empty array is passed.

These call sites were surfaced by the PHPStan extensions under development for this ticket, which are committed separately.

Developed as subset of https://github.com/WordPress/wordpress-develop/pull/12022.
Follow-up to r31525, r53627.

See #65376, #55441.

File:
1 edited

Legend:

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

    r62682 r62925  
    26332633
    26342634                /** This action is documented in wp-includes/taxonomy.php */
    2635                 do_action( 'edit_terms', $term_id, $taxonomy );
     2635                do_action( 'edit_terms', $term_id, $taxonomy, $args );
    26362636                $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
    26372637
    26382638                /** This action is documented in wp-includes/taxonomy.php */
    2639                 do_action( 'edited_terms', $term_id, $taxonomy );
     2639                do_action( 'edited_terms', $term_id, $taxonomy, $args );
    26402640        }
    26412641
     
    34953495
    34963496        /** This filter is documented in wp-includes/taxonomy.php */
    3497         $term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
     3497        $term_id = apply_filters( 'term_id_filter', $term_id, $tt_id, $args );
    34983498
    34993499        clean_term_cache( $term_id, $taxonomy );
     
    42504250
    42514251                /** This action is documented in wp-includes/taxonomy.php */
    4252                 do_action( 'edit_term_taxonomy', $tt_id, $taxonomy->name );
     4252                do_action( 'edit_term_taxonomy', $tt_id, $taxonomy->name, array() );
    42534253                $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $tt_id ) );
    42544254
    42554255                /** This action is documented in wp-includes/taxonomy.php */
    4256                 do_action( 'edited_term_taxonomy', $tt_id, $taxonomy->name );
     4256                do_action( 'edited_term_taxonomy', $tt_id, $taxonomy->name, array() );
    42574257        }
    42584258}
     
    42804280
    42814281                /** This action is documented in wp-includes/taxonomy.php */
    4282                 do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
     4282                do_action( 'edit_term_taxonomy', $term, $taxonomy->name, array() );
    42834283                $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
    42844284
    42854285                /** This action is documented in wp-includes/taxonomy.php */
    4286                 do_action( 'edited_term_taxonomy', $term, $taxonomy->name );
     4286                do_action( 'edited_term_taxonomy', $term, $taxonomy->name, array() );
    42874287        }
    42884288}
Note: See TracChangeset for help on using the changeset viewer.