Changeset 13081
- Timestamp:
- 12/22/2023 06:55:38 AM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/functions.php
r12627 r13081 244 244 $ticket = false; 245 245 246 // If the trac found is the key, return the value.247 $trac_redirects = [248 // Themes trac mentions are likely Meta tickets.249 'themes' => 'meta',250 ];251 252 246 // For now, we assume everything is destined for the Core Trac. 253 247 $trac = 'core'; … … 271 265 } 272 266 273 // If a specific trac is mentioned within the PR body: 274 elseif ( preg_match( '!/(?P<trac>[a-z]+).trac.wordpress.org/!i', $pr->body, $m ) ) { 275 $trac = $m['trac']; 267 // If a specific trac is mentioned within the PR body (and only that trac) 268 elseif ( 269 preg_match_all( '!/(?P<trac>[a-z]+).trac.wordpress.org/!i', $body, $m ) && 270 1 === count( array_unique( $m[0] ) ) 271 ) { 272 $trac = $m['trac'][0]; 276 273 } 277 274 … … 284 281 285 282 $regexes = [ 283 // Match explicit ticket-ref links, as included in most PR descriptions. 284 "!Trac ticket:\s*https://(?P<trac>[a-z]+).trac.wordpress.org/ticket/(?P<id>\d+)!i", 285 286 // Match any references to the "expected" trac instance first. This covers cases where multiple tracs are mentioned. 287 "!{$trac}.trac.wordpress.org/ticket/(?P<id>\d+)!i", 288 289 // Then any trac instance. 286 290 '!(?P<trac>[a-z]+).trac.wordpress.org/ticket/(?P<id>\d+)!i', 291 292 // Now for just plain ticket references without a trac instance. 287 293 '!(?:^|\s)#WP(\d+)!', // #WP1234 288 294 '!(?:^|\s)#(\d{4,5})!', // #1234 289 295 '!Ticket[ /-](\d+)!i', 296 290 297 // diff filenames. 291 298 '!\b(\d+)(\.\d)?\.(?:diff|patch)!i', 292 // Formats of common branches 299 300 // Formats of common branches. 293 301 '!((?P<trac>core|meta|bbpress|buddypress|themes)|WordPress|fix|trac)[-/](?P<id>\d+)!i', 302 294 303 // Starts or ends with a ticketish number 295 304 // These match things it really shouldn't, and are a last-ditch effort. … … 313 322 $trac = $m['trac']; 314 323 } 315 316 $trac = $trac_redirects[ $trac ] ?? $trac;317 324 318 325 return [ $trac, $id ];
Note: See TracChangeset
for help on using the changeset viewer.