Making WordPress.org


Ignore:
Timestamp:
02/03/2021 04:40:24 AM (4 years ago)
Author:
dd32
Message:

Theme Directory: Speed up the approval flow for new theme updates.

  1. Only a single comment is required to close the Trac ticket, See [10636], which reduces the Trac API calls from 3 to 2.
  2. Marks the new theme version as live immediately, reducing the time between upload and availability.
  3. Reduces the emails authors get when uploading a theme that's auto-approved from 2 to 1.

This may improve theme upload reliability for when Trac is under load.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-upload.php

    r10635 r10637  
    674674        $this->trac_ticket = new StdClass;
    675675
     676        $this->trac_ticket->resolution = '';
     677
    676678        // todo - check trac xml-rpc, maybe data needs to be escaped before sending it there.
    677679        $this->trac_ticket->summary = sprintf( 'THEME: %1$s – %2$s', $this->theme->display( 'Name' ), $this->theme->display( 'Version' ) );
     
    860862            // Note that this only applies to new ticket creation, so it won't happen on themes with existing outstanding tickets
    861863            if ( ! $theme_is_older_than_two_years && $this->trac_ticket->priority == 'theme update' ) {
    862                 $this->trac->ticket_update( $ticket_id, 'Theme Update for existing Live theme - automatically reviewed', array( 'action' => 'review' ), false );
    863                 $this->trac->ticket_update( $ticket_id, 'Theme Update for existing Live theme - automatically approved', array( 'action' => 'approve_and_live' ), false );
     864                $this->trac->ticket_update( $ticket_id, 'Theme Update for existing Live theme - automatically reviewed & approved', array( 'action' => 'new_no_review' ), false );
     865
     866                $this->trac_ticket->resolution = 'live';
    864867            }
    865868
     
    920923        }
    921924
    922         // Discard versions that are awaiting review.
    923         wporg_themes_update_version_status( $post_id, $this->theme->get( 'Version' ), 'new' );
    924 
    925925        // Add an additional row with the trac ticket ID, to make it possible to find the post by this ID later.
    926926        add_post_meta( $post_id, sanitize_key( '_trac_ticket_' . $this->theme->get( 'Version' ) ), $ticket_id );
     927
     928        // Discard versions that are awaiting review, and maybe set this upload as live.
     929        $version_status = 'new';
     930        if ( ! empty( $this->trac_ticket->resolution ) && 'live' === $this->trac_ticket->resolution ) {
     931            $version_status = 'live';
     932        }
     933        wporg_themes_update_version_status( $post_id, $this->theme->get( 'Version' ), $version_status );
    927934    }
    928935
     
    10111018    public function send_email_notification( $ticket_id ) {
    10121019        if ( ! empty( $this->theme_post ) ) {
     1020
     1021            if (
     1022                ! empty( $this->trac_ticket->resolution ) &&
     1023                'live' === $this->trac_ticket->resolution
     1024            ) {
     1025                // Do nothing. The update has been set as live. No nee to let them know it's been uploaded.
     1026                // wporg_themes_approve_version() will send a "Congratulations! It's live!" email momentarily.
     1027                return;
     1028            }
     1029
    10131030            /* translators: 1: theme name, 2: theme version */
    10141031            $email_subject = sprintf( __( '[WordPress Themes] %1$s, new version %2$s', 'wporg-themes' ),
Note: See TracChangeset for help on using the changeset viewer.