Changeset 891 in tests
- Timestamp:
- 07/09/2012 02:12:58 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/trac.php
r883 r891 3 3 class TracTickets { 4 4 /** 5 * When ever a track ticket is checked to see if it's closed or not6 * the results are stored here5 * When open tickets for a Trac install is requested, the results are stored here. 6 * 7 7 * @var array 8 8 */ … … 14 14 * @return bool|null true if the ticket is resolved, false if not resolved, null on error 15 15 */ 16 static function isTracTicketClosed($trac_url, $ticket_id) { 17 $trac_url = rtrim($trac_url, '/'); 18 $url = "$trac_url/ticket/$ticket_id?format=tab"; 19 if ( array_key_exists( $url, self::$trac_ticket_cache ) ) { 20 return self::$trac_ticket_cache[$url]; 16 public static function isTracTicketClosed( $trac_url, $ticket_id ) { 17 if ( ! isset( self::$trac_ticket_cache[ $trac_url ] ) ) { 18 $tickets = file_get_contents( $trac_url . '/query?status=%21closed&format=csv&col=id' ); 19 $tickets = substr( $tickets, 2 ); // remove 'id' 20 $tickets = trim( $tickets ); 21 $tickets = explode( "\r\n", $tickets ); 22 self::$trac_ticket_cache[ $trac_url ] = $tickets; 21 23 } 22 $ticket_tsv = file_get_contents($url); 23 if (false === $ticket_tsv) { 24 self::$trac_ticket_cache[$url] = null; 25 return self::$trac_ticket_cache[$url]; 26 } 27 $lines = explode("\n", $ticket_tsv, 2); 28 if (!is_array($lines) || count($lines) < 2) { 29 self::$trac_ticket_cache[$url] = null; 30 return self::$trac_ticket_cache[$url]; 31 } 32 $titles = str_getcsv( $lines[0], "\t" ); 33 $status_idx = array_search('status', $titles); 34 if (false === $status_idx) { 35 self::$trac_ticket_cache[$url] = null; 36 return self::$trac_ticket_cache[$url]; 37 } 38 $tabs = str_getcsv( $lines[1], "\t" ); 39 self::$trac_ticket_cache[$url] = ( 'closed' === $tabs[$status_idx] ); 40 return self::$trac_ticket_cache[$url]; 24 25 return ! in_array( $ticket_id, self::$trac_ticket_cache[ $trac_url ] ); 41 26 } 42 27 }
Note: See TracChangeset
for help on using the changeset viewer.