#46670 closed defect (bug) (fixed)
Compact throws notice on PHP7.3 at ajax-actions.php
| Reported by: | pilou69 | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.2 |
| Component: | Taxonomy | Version: | 5.1 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | administration |
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
@
7 years ago
- Component General → Taxonomy
- Focuses administration added
- Milestone Awaiting Review → 5.2
#4
@
7 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Appears to be missed in #44416.