#46670 closed defect (bug) (fixed)
Compact throws notice on PHP7.3 at ajax-actions.php
Reported by: | pilou69 | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.2 | Priority: | normal |
Severity: | normal | Version: | 5.1 |
Component: | Taxonomy | Keywords: | |
Focuses: | administration | Cc: |
Description
There is no $noparents variable if the taxonomy is not hierarchical, so the compact used for the taxonomy supplemental throws a notice.
function wp_ajax_add_tag
line 1039
Before:
<?php $level = 0; if ( is_taxonomy_hierarchical( $taxonomy ) ) { $level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) ); ob_start(); $wp_list_table->single_row( $tag, $level ); $noparents = ob_get_clean(); } ob_start(); $wp_list_table->single_row( $tag ); $parents = ob_get_clean(); $x->add( array( 'what' => 'taxonomy', 'supplemental' => compact( 'parents', 'noparents' ), ) );
Proposed fix:
<?php $level = 0; $taxonomy_supplemental = []; if ( is_taxonomy_hierarchical( $taxonomy ) ) { $level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) ); ob_start(); $wp_list_table->single_row( $tag, $level ); $taxonomy_supplemental['noparents'] = ob_get_clean(); } ob_start(); $wp_list_table->single_row( $tag ); $taxonomy_supplemental['parents'] = ob_get_clean(); $x->add( array( 'what' => 'taxonomy', 'supplemental' => $taxonomy_supplemental, ) );
Change History (4)
#1
@
5 years ago
- Component changed from General to Taxonomy
- Focuses administration added
- Milestone changed from Awaiting Review to 5.2
#3
@
5 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 45034:
#4
@
5 years ago
I should mention that the result of your fix https://core.trac.wordpress.org/changeset/45034 is not exactly what PHP7.2 did.
You see, in PHP7.2 if the variable for compact didn't exists the resulting array won't have the key with the variable name.
With Your change the 'noparents' key will be always there. I don't know if it's a mistake or You were intended to do that.
Note: See
TracTickets for help on using
tickets.
Appears to be missed in #44416.