Making WordPress.org

Changeset 3610


Ignore:
Timestamp:
07/01/2016 09:12:17 AM (9 years ago)
Author:
ocean90
Message:

Trac Components: Fix single component pages.

  • Quick fix to a data type change in the shift from MySQL to SQLite, see [3604].
  • Bail out if API returns no results.
File:
1 edited

Legend:

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

    r3604 r3610  
    339339    function generate_component_breakdowns() {
    340340        if ( isset( $this->breakdown_component_type, $this->breakdown_component_milestone_type, $this->breakdown_component_unreplied ) ) {
    341             return;
     341            return true;
    342342        }
    343343
     
    346346        if ( ! $rows ) {
    347347            $rows = $this->api->get_tickets_by_component_type_milestone();
     348            if ( ! $rows ) {
     349                return false; // API error.
     350            }
    348351            wp_cache_add( 'trac_tickets_by_component_type_milestone', $rows, '', 300 );
    349352        }
    350353
    351354        foreach ( $rows as $row ) {
     355            $row = (object) $row;
    352356            if ( empty( $component_type[ $row->component ] ) ) {
    353357                $component_type[ $row->component ] = $type_filled;
     
    370374        $this->breakdown_component_milestone_type = $component_milestone_type;
    371375        $this->breakdown_component_unreplied = $component_unreplied;
    372     }
    373 
    374     function ticket_table( $component  ) {
    375         $this->generate_component_breakdowns();
     376
     377        return true;
     378    }
     379
     380    function ticket_table( $component ) {
     381        $result = $this->generate_component_breakdowns();
     382        if ( ! $result ) {
     383            return;
     384        }
     385
    376386        $component_type = $this->breakdown_component_type;
    377387        $component_milestone_type = $this->breakdown_component_milestone_type;
     
    457467        if ( $next_milestone ) {
    458468            $count = count( $next_milestone );
    459             echo '<h3>' . sprintf( _n( '%s ticket slated for ' . $next_milestone[0]->milestone, '%s tickets slated for ' . $next_milestone[0]->milestone, $count ), $count ) . '</h3>';
    460             echo $this->trac_query_link( 'View list in Trac', array( 'component' => $component, 'milestone' => $next_milestone[0]->milestone ) );
     469            $next_milestone_object = (object) $next_milestone[0];
     470            echo '<h3>' . sprintf( _n( '%s ticket slated for ' . $next_milestone_object->milestone, '%s tickets slated for ' . $next_milestone_object->milestone, $count ), $count ) . '</h3>';
     471            echo $this->trac_query_link( 'View list in Trac', array( 'component' => $component, 'milestone' => $next_milestone_object->milestone ) );
    461472            $this->render_tickets( $next_milestone );
    462473        }
     
    555566
    556567    function component_table_row( $post ) {
     568        $result = $this->generate_component_breakdowns();
     569        if ( ! $result ) {
     570            return;
     571        }
     572
    557573        static $once = true;
    558574        if ( $once ) {
     
    562578
    563579        $component = $post->post_title;
    564         $this->generate_component_breakdowns();
    565580        $history = $this->api->get_component_history( $component );
    566581
Note: See TracChangeset for help on using the changeset viewer.