Changeset 14431
- Timestamp:
- 04/22/2025 03:27:10 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/lib/class-trac.php
r14420 r14431 63 63 } 64 64 65 $ok = $this->rpc ->query('ticket.create', $subj, $desc, $attr );65 $ok = $this->rpc_query_retry( 5, 'ticket.create', $subj, $desc, $attr ); 66 66 if ( ! $ok ) { 67 67 trigger_error( 'Trac: ticket.create: ' . $this->rpc->error->message, E_USER_WARNING ); … … 86 86 public function ticket_update( $id, $comment, $attr = array(), $notify = false ) { 87 87 if ( empty( $attr['_ts'] ) ) { 88 $get = $this->ticket_get( $id ); 88 $get = $this->ticket_get( $id ); 89 if ( ! $get ) { 90 trigger_error( 'Trac: ticket.update: Couldn\'t get: ' . $this->rpc->error->message, E_USER_WARNING ); 91 return false; 92 } 93 89 94 $attr['_ts'] = $get['_ts']; 90 95 } … … 93 98 } 94 99 95 $ok = $this->rpc ->query('ticket.update', $id, $comment, $attr, $notify );100 $ok = $this->rpc_query_retry( 5, 'ticket.update', $id, $comment, $attr, $notify ); 96 101 if ( ! $ok ) { 97 102 trigger_error( 'Trac: ticket.update: ' . $this->rpc->error->message, E_USER_WARNING ); … … 125 130 */ 126 131 public function ticket_get( $id ) { 127 $ok = $this->rpc->query( 'ticket.get', $id ); 132 $ok = $this->rpc_query_retry( 5, 'ticket.get', $id ); 133 128 134 if ( ! $ok ) { 135 trigger_error( 'Trac: ticket.get: ' . $this->rpc->error->message, E_USER_WARNING ); 136 129 137 return false; 130 138 } … … 138 146 return $response; 139 147 } 148 149 /** 150 * Queries Trac RPC with a backoff retry. 151 * 152 * @param int $retries Number of retries. 153 * @param mixed ...$args Arguments to pass to the query. 154 */ 155 public function rpc_query_retry( $retries, ...$args ) { 156 $ok = false; 157 $retry = 0; 158 while ( ! $ok && $retry < $retries ) { 159 if ( $retry ) { 160 sleep( $retry ); 161 } 162 $retry++; 163 164 $ok = call_user_func_array( [ $this->rpc, 'query' ], $args ); 165 } 166 167 if ( ! $ok ) { 168 trigger_error( 'Trac: rpc query retry failed: ' . $args[0] . ' ' . $this->rpc->error->message, E_USER_WARNING ); 169 } 170 171 return $ok; 172 } 173 140 174 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)