Changeset 919 in tests for trunk/includes/trac.php
- Timestamp:
- 07/19/2012 04:14:52 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/includes/trac.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/trac.php
r891 r919 16 16 public static function isTracTicketClosed( $trac_url, $ticket_id ) { 17 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 ); 18 // In case you're running the tests offline, keep track of open tickets. 19 $file = DIR_TESTDATA . '/.trac-ticket-cache.' . str_replace( array( 'http://', 'https://' ), '', $trac_url ); 20 $tickets = @file_get_contents( $trac_url . '/query?status=%21closed&format=csv&col=id' ); 21 // Check if our HTTP request failed. 22 if ( false === $tickets ) { 23 if ( file_exists( $file ) ) { 24 register_shutdown_function( array( 'TracTickets', 'usingLocalCache' ) ); 25 $tickets = file_get_contents( $file ); 26 } else { 27 register_shutdown_function( array( 'TracTickets', 'forcingKnownBugs' ) ); 28 self::$trac_ticket_cache[ $trac_url ] = array(); 29 return true; // Assume the ticket is closed, which means it gets run. 30 } 31 } else { 32 $tickets = substr( $tickets, 2 ); // remove 'id' column header 33 $tickets = trim( $tickets ); 34 file_put_contents( $file, $tickets ); 35 } 21 36 $tickets = explode( "\r\n", $tickets ); 22 37 self::$trac_ticket_cache[ $trac_url ] = $tickets; … … 25 40 return ! in_array( $ticket_id, self::$trac_ticket_cache[ $trac_url ] ); 26 41 } 42 43 public static function usingLocalCache() { 44 echo PHP_EOL . "Trac was inaccessible, so a local ticket status cache was used." . PHP_EOL; 45 } 46 47 public static function forcingKnownBugs() { 48 echo PHP_EOL . "Trac was inaccessible, so known bugs weren't able to be skipped." . PHP_EOL; 49 } 27 50 }
Note: See TracChangeset
for help on using the changeset viewer.