Making WordPress.org

Changeset 11371


Ignore:
Timestamp:
12/15/2021 02:47:05 AM (2 years ago)
Author:
dd32
Message:

SVN Watcher: Some performance improvements for the admin view & reports.

This reduces the queries by removing oEmbed processing of commit messages, caching users in bulk, avoiding PHP Notices, documenting some things, skipping the UI if revisions/props aren't imported for a SVN.

See #5978.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/admin/list-table.php

    r11370 r11371  
    125125            ORDER BY user_id IS NULL DESC, LENGTH(prop_name) DESC"
    126126        );
     127
     128        // Fill user caches, some commits have a lot of props, yay! :)
     129        $unique_user_ids = array_map( 'intval', array_filter( array_unique( wp_list_pluck( $props_list, 'user_id' ) ) ) );
     130        if ( $unique_user_ids ) {
     131            cache_users( $unique_user_ids );
     132        }
    127133
    128134        foreach ( $this->items as $i => $details ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/admin/reports-page.php

    r11370 r11371  
    1313    // Default to the latest version for core.
    1414    if ( $is_core && is_null( $version ) ) {
    15         $version = sprintf( '%.1f', WP_CORE_LATEST_RELEASE + 0.1 );
     15        $version = sprintf( '%.1f', floatval( WP_CORE_LATEST_RELEASE ) + 0.1 );
    1616    }
    1717
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/admin/ui.php

    r11369 r11371  
    2222
    2323    foreach ( $svns as $slug => $details ) {
     24        // No point showing this UI if we're not importing Props.
     25        if ( empty( $details['props_table'] ) ) {
     26            continue;
     27        }
     28
    2429        $name = sprintf( "%s Props", $details['name'] );
    2530        $hook = add_menu_page(
     
    3641        $hook = add_submenu_page(
    3742            'props-edit-' . $slug,
    38             'Reports', 'Reports',
     43            'Reports',
     44            'Reports',
    3945            'edit_posts',
    4046            'props-reports-' . $slug,
     
    5864
    5965    // Run the import upon loading the page if it hasn't run recently.
    60     if ( wp_next_scheduled( 'import_revisions_from_svn' ) < time() + 5*MINUTE_IN_SECONDS ) {
    61         ob_start();
     66    if ( get_site_transient( 'import_revisions_from_svn' ) < time() - 5*MINUTE_IN_SECONDS ) {
    6267        do_action( 'import_revisions_from_svn' );
    63         ob_end_clean();
    6468    }
    6569
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/svn.php

    r11363 r11371  
    77
    88add_action( 'import_revisions_from_svn', function() {
     9    set_site_transient( 'import_revisions_from_svn', time() );
     10
    911    foreach ( get_svns() as $svn ) {
    1012        import_revisions( $svn );
     
    3840    $svn_url     = $svn['url'];
    3941    $slug        = $svn['slug'];
    40     $db_table    = $svn['rev_table'];
     42    $db_table    = $svn['rev_table'] ?? false;
    4143    $props_table = $svn['props_table'] ?? false;
     44
     45    // If this SVN doesn't have a rev_table defined, it's not being imported currently.
     46    if ( ! $db_table ) {
     47        return false;
     48    }
    4249
    4350    $last_revision = $wpdb->get_var( "SELECT max(id) FROM {$db_table}" );
     
    7481            continue;
    7582        }
    76 
    77         echo "Importing {$id} \n";
    7883
    7984        $paths  = (array) $change->paths->path;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/trac-watch.php

    r11362 r11371  
    33/**
    44 * Plugin Name: WordPress.org Trac & SVN Watcher.
     5 * Description: This plugin imports Trac activity & SVN activity into WordPress.org databases. Trac actions for Profiles, and SVN activity for reporting, profiles, and make.w.org/* reporting.
     6 * Version: 1.0
     7 * Author: Dion Hulse
    58 */
    69
     
    6063        KEY `category` (`category`),
    6164        KEY `username` (`username`)
    62     ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
     65    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; // UTF8, but treated as latin1, due to historical profiles reasons.
    6366
    6467    $revisions_table = "CREATE TABLE IF NOT EXISTS `%s` (
     
    8689    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
    8790
    88     return; // TODO
    8991    foreach ( SVN\get_svns() as $prefix => $info ) {
    9092        $wpdb->query( sprintf( $trac_table, 'trac_' . $prefix ) );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/trac.php

    r11362 r11371  
    88function format_trac_markup( $message ) {
    99    $message = esc_html( $message );
     10
     11    // Convert some Trac markdown to HTML.
    1012    $message = preg_replace( '!`(.*?)`!i', '<code>$1</code>', $message );
    1113    $message = preg_replace( '!{{{(.*?)}}}!sm', '<code>$1</code>', $message );
    12 
    1314    $message = preg_replace( '!\[([^] ]+) ([^]]+)\]!i', '<a href="$1">$2</a>', $message );
    1415
    15     // Escape shortcodes, but that takes out changesets..
    16     // $message = str_replace( [ '[', ']'], [ '[[', ']]' ], $message );
     16    // Mark up the text, using functions we want, rather than `the_content` as it has many filters that don't strictly apply.
     17    $message = wptexturize( $message );
     18    $message = wpautop( $message );
     19    $message = make_clickable( $message );
    1720
    18     // Might need to disable this, or escape more things prior to it.
    19     $message = apply_filters( 'the_content', $message );
    20     $message = make_clickable( $message );
     21    // Link tickets and changesets.
     22    if ( function_exists( 'markup_wporg_links' ) ) {
     23        $message = markup_wporg_links( $message );
     24    }
     25
     26    // Ensure nothing funny is in the output.
     27    $message = wp_kses_post( $message );
    2128
    2229    return $message;
Note: See TracChangeset for help on using the changeset viewer.