Making WordPress.org

Changeset 13992


Ignore:
Timestamp:
08/26/2024 02:12:20 AM (6 months ago)
Author:
dd32
Message:

Make: Trac Component overview: Generate a link that works for Meta trac (and any others).

Only core.trac has a rewrite handler for the /components/(.+) endpoint.

Props dd32, enrico.sorcinelli.
Fixes #7755.

File:
1 edited

Legend:

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

    r13880 r13992  
    3636    function trac_url() {
    3737        return 'https://' . $this->trac . '.trac.wordpress.org';
     38    }
     39
     40    function get_component_url( $component ) {
     41        if ( 'core' === $this->trac ) {
     42            // Core has a rewrite for /component/(.+) to a report.
     43            return $this->trac_url() . '/component/' . rawurlencode( $component );
     44        } elseif ( 'meta' === $this->trac ) {
     45            // Meta has the same report, but with no rewrite
     46            return $this->trac_url() . '/report/19?COMPONENT=' . rawurlencode( $component );
     47        } else {
     48            // Otherwise, just query for open tickets.
     49            return $this->trac_url() . '/query?status=!closed&component=' . rawurlencode( $component );
     50        }
    3851    }
    3952
     
    716729            $open_tickets = array_sum( $this->breakdown_component_type[ $component ] );
    717730        }
    718         echo '<td class="right"><a href="' . $this->trac_url() . '/component/' . esc_attr( rawurlencode( $component ) ) . '">' . $open_tickets . '</a></td>';
     731        echo '<td class="right"><a href="' . esc_attr( $this->get_component_url( $component ) ) . '">' . $open_tickets . '</a></td>';
    719732        if ( $history['change'] ) {
    720733            $count = sprintf( "%+d", $history['change'] );
Note: See TracChangeset for help on using the changeset viewer.