Making WordPress.org


Ignore:
Timestamp:
12/08/2020 05:11:04 AM (6 years ago)
Author:
dd32
Message:

Trac: Component overview pages: list each type of ticket and the breakdown of tickets open in each.

This avoids PHP Notices when a component has no defects open, and also helps link off to each set of tickets.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-components.php

    r10327 r10499  
    568568                }
    569569
    570                 $tickets_by_type = $this->api->get_ticket_counts_for_component( $component );
    571                 if ( ! $tickets_by_type ) {
    572                         $tickets_by_type = array( 'defect (bug)' => 0 ); // Incorrect, but allows page render
    573                 }
     570                $tickets_by_type = (array) $this->api->get_ticket_counts_for_component( $component );
    574571
    575572                $count = array_sum( $tickets_by_type );
    576573                echo '<h3>' . sprintf( _n( '%s open ticket', '%s open tickets', $count ), $count ) . '</h3>';
    577                 echo "\n" . '<strong>Open bugs: ' . $tickets_by_type['defect (bug)'] . '</strong>. ';
    578                 echo $this->trac_query_link( 'View list on Trac', array( 'component' => $component, 'type' => 'defect (bug)' ) );
    579                 echo "\n\n";
    580 
    581                 return;
    582574
    583575                $types = array(
    … …  
    588580
    589581                foreach ( $types as $type => $title ) {
    590                         $args = compact( 'component', 'type' );
    591                         if ( $tickets = $this->api->get_tickets_by( $args ) ) {
    592                                 printf( '<h3>%s (%d)</h3>', $title, count( $tickets ) );
    593                                 echo $this->trac_query_link( 'View list on Trac', $args );
    594                                 $this->render_tickets( $tickets );
    595                         }
     582                        $count = $tickets_by_type[ $type ] ?? 0;
     583                        printf( '<strong>%s: %d<strong> ', $title, $count );
     584                        echo $this->trac_query_link( 'View list on Trac', compact( 'component', 'type' ) );
     585                        echo '<br>';
    596586                }
    597587        }
Note: See TracChangeset for help on using the changeset viewer.