Changeset 11582
- Timestamp:
- 02/18/2022 05:43:57 AM (3 years ago)
- Location:
- sites/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/slack/trac-bot.php
r11359 r11582 38 38 $slack->set_user( $trac_obj ); 39 39 40 $parsed_objects = array( 41 'ticket' => array(), 42 'commit' => array(), 43 ); 44 40 45 foreach ( $results as $type => $values ) { 41 46 // Loop through all tickets and commits for this Trac. … … 46 51 // Get the Ticket or Commit object for this Trac + ID. 47 52 $obj = call_user_func( array( $class, 'get' ), $trac_obj, $id ); 53 54 // Keep a reference to this object for later. 55 $parsed_objects[ $type ][ $id ] = $obj; 48 56 49 57 // Check if we should be posting this to Slack so quickly. … … 97 105 } 98 106 99 // If there's no tickets referenced (ie. just commits) then there's no need to flag t ghe reference on Trac.107 // If there's no tickets referenced (ie. just commits) then there's no need to flag the reference on Trac. 100 108 if ( empty( $results['ticket'] ) ) { 101 109 continue; … … 106 114 $comment = sprintf( $comment_template, $_POST['channel_name'], $_POST['user_name'], str_replace( '.', '', $_POST['timestamp'] ) ); 107 115 foreach ( $results['ticket'] as $ticket ) { 108 if ( is_array( $ticket ) ) { 109 $ticket = $ticket['id']; 116 $ticket_id = is_array( $ticket ) ? $ticket['id'] : $ticket; 117 118 // If the ticket is closed and hasn't been modified in over 2 years, don't post a reference to it. 119 if ( ! empty( $parsed_objects[ 'ticket' ][ $ticket_id ] ) ) { 120 $ticket_object = $parsed_objects[ 'ticket' ][ $ticket_id ]; 121 $ticket_object->fetch(); 122 123 $is_closed = ( 'closed' === $ticket_object->status ); 124 $last_modified = strtotime( $ticket_object->modified ); 125 $has_recent_change = ( ! $last_modified || $last_modified > ( time() - 2 * YEAR_IN_SECONDS ) ); 126 127 if ( $is_closed && ! $has_recent_change ) { 128 continue; 129 } 110 130 } 111 131 112 if ( $parser->is_redundant( 'trac', $trac, 'ticket', $ticket ) ) {132 if ( $parser->is_redundant( 'trac', $trac, 'ticket', $ticket_id ) ) { 113 133 continue; 114 134 } 115 $parser->set_redundancy( 'trac', $trac, 'ticket', $ticket );116 135 117 $trac_xmlrpc->ticket_update( $ticket, $comment ); 136 $parser->set_redundancy( 'trac', $trac, 'ticket', $ticket_id ); 137 138 $trac_xmlrpc->ticket_update( $ticket_id, $comment ); 118 139 } 119 140 } -
sites/trunk/common/includes/slack/trac/ticket.php
r10001 r11582 64 64 65 65 $url = sprintf( 66 '%s/query?id=%s&col=id&col=summary&col=owner&col=type&col=cc&col=status&col=priority&col=milestone&col=component&col=version&col=severity&col=resolution&col=time&col= focuses&col=reporter&col=keywords&col=description&format=csv',66 '%s/query?id=%s&col=id&col=summary&col=owner&col=type&col=cc&col=status&col=priority&col=milestone&col=component&col=version&col=severity&col=resolution&col=time&col=changetime&col=focuses&col=reporter&col=keywords&col=description&format=csv', 67 67 $this->trac->get_url(), 68 68 $this->id
Note: See TracChangeset
for help on using the changeset viewer.