Changeset 11363
- Timestamp:
- 12/13/2021 07:06:14 AM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/props.php
r11362 r11363 19 19 "^props(?! to ) {$props_greedy}.?$", // Super basic initial primary matcher, trumps even the next one. 20 20 "{$real_sol}props(?! to ) {$props_greedy}{$real_eol}", // Primary matcher, "Props abc, def". Excludes "props to " 21 "([,.] )props {$props}([,.] )", // Simple inline props matcher, ". props abc." / ", props abc, fixes ..."21 "([,.] )props {$props_greedy}{$eol}", // Simple inline props matcher, ". props abc." / ", props abc, fixes ..." 22 22 "{$sol}props([:]| to ) {$props_greedy}{$eol}", 23 23 "([0-9]|\pP)\s+props([:]|\s+to)? {$props_one}( in .+)?(,|{$eol})", … … 25 25 26 26 // These are starting to get real old... like three-digit core commit old.. 27 "with help from {$props}{$real_eol}", 27 28 "\S\sprops([:]|\s+to)? {$props_short}{$eol}", // Inline props 28 29 "\scredit(?! card)([:]|\sto)? {$props_short}", // Credit: ... or Credit to ... … … 35 36 // They're intended to catch additional inline mentions. 36 37 'multiple' => [ 37 " \sunprops {$props_one}",38 "{$sol}unprops:? {$props_greedy}{$eol}", 38 39 "{$sol}(dev)?reviewed[- ]by {$props}{$eol}", 39 40 "\sthanks {$props_one}", … … 146 147 147 148 // Trim trailing punctuation (if it starts without punctuation) 148 $u = preg_replace( '!^([a-z0-9].{4,} )[\pP\s]+$!iu', '$1', $u );149 $u = preg_replace( '!^([a-z0-9].{4,}?)[\pP\s]+?$!iu', '$1', $u ); 149 150 150 151 // Does it start with a expected character, but have space followed by rand punctuation? … … 218 219 * Find a user ID for the user being prop'd. 219 220 */ 220 function find_user_id( $prop , $svn = array()) {221 function find_user_id( $prop ) { 221 222 global $wpdb; 223 224 if ( ! $prop ) { 225 return false; 226 } 222 227 223 228 // Profile URL - This is primarily used via the Admin UI to assign ownership of a prop. 224 229 if ( 225 preg_match( '!^https?://profiles.wordpress.org/(?P<user>[^/]+)/?$!', $ user, $m ) &&230 preg_match( '!^https?://profiles.wordpress.org/(?P<user>[^/]+)/?$!', $prop, $m ) && 226 231 ( $user = get_user_by( 'slug', $m['user'] ) ) 227 232 ) { … … 258 263 // This works great to catch typo's, correct it manually once and it'll be caught next time. 259 264 foreach ( get_svns() as $svn ) { 260 $props_table = ['props_table'] ?? false; 265 if ( empty( $svn['props_table'] ) ) { 266 continue; 267 } 268 $props_table = $svn['props_table']; 261 269 if ( 262 270 $props_table && 263 ( $id = $wpdb->get_var( $ wpdb->prepare( "SELECT user_id FROM {$props_table} WHERE prop_name = %sLIMIT 1", $prop ) ) )271 ( $id = $wpdb->get_var( $sql = $wpdb->prepare( "SELECT user_id FROM {$props_table} WHERE prop_name = %s AND user_id IS NOT NULL LIMIT 1", $prop ) ) ) 264 272 ) { 265 273 return (int) $id; … … 268 276 269 277 // GitHub? 270 $github = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM wporg_github_users WHERE github_user = %s LIMI t1", $prop ) );278 $github = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM wporg_github_users WHERE github_user = %s LIMIT 1", $prop ) ); 271 279 if ( $github ) { 272 280 return (int) $github; 273 281 } 274 282 283 // Last resort, full name of someone who has been prop'd before? 284 // Display_Name isn't indexed, so can't be queried without a user list to reference against. 285 foreach ( get_svns() as $svn ) { 286 if ( empty( $svn['props_table'] ) ) { 287 continue; 288 } 289 290 $props_table = $svn['props_table']; 291 $user_id = $wpdb->get_var( $sql = $wpdb->prepare( 292 "SELECT u.ID FROM {$props_table} p JOIN {$wpdb->users} u ON p.user_id = u.ID WHERE u.display_name = %s LIMIT 1", 293 $prop 294 ) ); 295 296 if ( $user_id ) { 297 return $user_id; 298 } 299 } 300 275 301 return false; 276 302 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/svn.php
r11362 r11363 116 116 ]; 117 117 118 $user_id = find_user_id( $prop , $svn);118 $user_id = find_user_id( $prop ); 119 119 if ( $user_id ) { 120 120 $data['user_id'] = $user_id;
Note: See TracChangeset
for help on using the changeset viewer.