Making WordPress.org

Changeset 11363


Ignore:
Timestamp:
12/13/2021 07:06:14 AM (3 years ago)
Author:
dd32
Message:

SVN Watching: Some tweaks to the matching rules.

See #5978.

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  
    1919            "^props(?! to ) {$props_greedy}.?$", // Super basic initial primary matcher, trumps even the next one.
    2020            "{$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 ..."
    2222            "{$sol}props([:]| to ) {$props_greedy}{$eol}",
    2323            "([0-9]|\pP)\s+props([:]|\s+to)? {$props_one}( in .+)?(,|{$eol})",
     
    2525
    2626            // These are starting to get real old... like three-digit core commit old..
     27            "with help from {$props}{$real_eol}",
    2728            "\S\sprops([:]|\s+to)? {$props_short}{$eol}", // Inline props
    2829            "\scredit(?! card)([:]|\sto)? {$props_short}", // Credit: ... or Credit to ...
     
    3536        // They're intended to catch additional inline mentions.
    3637        'multiple' => [
    37             "\sunprops {$props_one}",
     38            "{$sol}unprops:? {$props_greedy}{$eol}",
    3839            "{$sol}(dev)?reviewed[- ]by {$props}{$eol}",
    3940            "\sthanks {$props_one}",
     
    146147
    147148            // 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 );
    149150
    150151            // Does it start with a expected character, but have space followed by rand punctuation?
     
    218219 * Find a user ID for the user being prop'd.
    219220 */
    220 function find_user_id( $prop, $svn = array() ) {
     221function find_user_id( $prop ) {
    221222    global $wpdb;
     223
     224    if ( ! $prop ) {
     225        return false;
     226    }
    222227
    223228    // Profile URL - This is primarily used via the Admin UI to assign ownership of a prop.
    224229    if (
    225         preg_match( '!^https?://profiles.wordpress.org/(?P<user>[^/]+)/?$!', $user, $m ) &&
     230        preg_match( '!^https?://profiles.wordpress.org/(?P<user>[^/]+)/?$!', $prop, $m ) &&
    226231        ( $user = get_user_by( 'slug', $m['user'] ) )
    227232    ) {
     
    258263    // This works great to catch typo's, correct it manually once and it'll be caught next time.
    259264    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'];
    261269        if (
    262270            $props_table &&
    263             ( $id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM {$props_table} WHERE prop_name = %s LIMIT 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 ) ) )
    264272        ) {
    265273            return (int) $id;
     
    268276
    269277    // GitHub?
    270     $github = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM wporg_github_users WHERE github_user = %s LIMIt 1", $prop ) );
     278    $github = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM wporg_github_users WHERE github_user = %s LIMIT 1", $prop ) );
    271279    if ( $github ) {
    272280        return (int) $github;
    273281    }
    274282
     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
    275301    return false;
    276302}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/svn.php

    r11362 r11363  
    116116                ];
    117117
    118                 $user_id = find_user_id( $prop, $svn );
     118                $user_id = find_user_id( $prop );
    119119                if ( $user_id ) {
    120120                    $data['user_id'] = $user_id;
Note: See TracChangeset for help on using the changeset viewer.