[wp-trac] [WordPress Trac] #46670: Compact throws notice on PHP7.3 at ajax-actions.php

WordPress Trac noreply at wordpress.org
Wed Mar 27 14:39:39 UTC 2019


#46670: Compact throws notice on PHP7.3 at ajax-actions.php
--------------------------+-----------------------------
 Reporter:  pilou69       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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
 <?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
 <?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,
                 )
         );

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46670>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list