Making WordPress.org

Changeset 11588


Ignore:
Timestamp:
02/21/2022 08:18:07 AM (3 years ago)
Author:
dd32
Message:

Theme Directory: Add an email for failed theme imports from SVN.

Theme Check still runs on theme updates via SVN, and will reject themes that do not need requirements.

See #5899.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory
Files:
3 edited

Legend:

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

    r11511 r11588  
    5353     * @var string
    5454     */
    55     protected $tmp_dir = '';
     55    public $tmp_dir = '';
    5656
    5757    /**
     
    6060     * @var string
    6161     */
    62     protected $tmp_svn_dir = '';
     62    public $tmp_svn_dir = '';
    6363
    6464    /**
     
    6767     * @var string
    6868     */
    69     protected $theme_dir = '';
     69    public $theme_dir = '';
    7070
    7171    /**
     
    7474     * @var WP_Theme
    7575     */
    76     protected $theme;
     76    public $theme;
    7777
    7878    /**
     
    8181     * @var string
    8282     */
    83     protected $theme_slug = '';
     83    public $theme_slug = '';
    8484
    8585    /**
     
    8888     * @var WP_Post
    8989     */
    90     protected $theme_post;
     90    public $theme_post;
    9191
    9292    /**
     
    9595     * @var WP_User
    9696     */
    97     protected $author;
     97    public $author;
    9898
    9999    /**
     
    102102     * @var array
    103103     */
    104     protected $readme = array();
     104    public $readme = array();
    105105
    106106    /**
     
    109109     * @var object
    110110     */
    111     protected $trac_ticket;
     111    public $trac_ticket;
    112112
    113113    /**
     
    116116     * @var int
    117117     */
    118     protected $trac_changeset = 0;
     118    public $trac_changeset = 0;
    119119
    120120    /**
     
    123123     * @var Trac
    124124     */
    125     protected $trac;
     125    public $trac;
    126126
    127127    /**
     
    144144     * @var string
    145145     */
    146     protected $commit_msg = '';
     146    public $commit_msg = '';
    147147
    148148    /**
     
    17611761                            // When importing from SVN, include a 'Compare' link as the Changeset likely won't show a Diff unless the author did a `svn cp`.
    17621762                            'svn' === $this->importing_from && ! empty( $this->theme_post->max_version ) ?
    1763                             "<https://themes.trac.wordpress.org/changeset?old_path={$this->theme_slug}/{$this->theme_post->max_version}&new_path={$this->theme_slug}/{$this->theme->display( 'Version' )}|Compare>" :
     1763                            "<https://themes.trac.wordpress.org/changeset?old_path={$this->theme_slug}/{$this->theme_post->_last_live_version}&new_path={$this->theme_slug}/{$this->theme->display( 'Version' )}|Compare>" :
    17641764                            ''
    17651765                        ),
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/jobs/class-svn-import.php

    r11305 r11588  
    106106
    107107        if ( empty( $args['slug'] ) || empty( $args['version'] ) ) {
    108             trigger_error( 'Theme Import aborted, invalid input provided: ' . json_Encode( $args ), E_USER_WARNING );
     108            trigger_error( 'Theme Import aborted, invalid input provided: ' . json_encode( $args ), E_USER_WARNING );
    109109            return;
    110110        }
     
    115115            $args['slug'],
    116116            $args['version'],
    117             $args['changeset'] ?? false,
    118             $args['author'] ?? false,
    119             $args['msg'] ?? ''
     117            $args['changeset'],
     118            $args['author'],
     119            $args['msg']
    120120        );
    121121
    122         // TODO: Look at error result code, maybq re-queue in event of system issue, else email author with concerns (Theme Check, etc)
    123         //       CC emails to themes team in event of having to contact the author?
     122        if ( is_wp_error( $return ) ) {
    124123
    125         if ( is_wp_error( $return ) ) {
    126             throw new Exception( "Theme Import Failure: " . $return->get_error_code . ' ' . $return->get_error_message() );
     124            // Retry once in the event of a WordPress.org issue exporting from themes.svn.wordpress.org.
     125            if ( 'svn_error' === $return->get_error_code() ) {
     126                if ( empty( $args['retry'] ) ) {
     127                    $args['retry'] = $return;
     128                    wp_schedule_single_event( time() + HOUR_IN_SECONDS, 'theme_directory_svn_import', $args );
     129                    return;
     130                } else {
     131                    throw new Exception( 'Theme Import Failure: ' . $return->get_error_code() . ' ' . $return->get_error_message() );
     132                }
     133            }
     134
     135            // Otherwise email the author about this problem.
     136            wp_mail(
     137                // $uploader->author->user_email,
     138                get_user_by( 'login', 'dd32' )->user_email, // TODO, DEBUG for now.
     139                sprintf(
     140                    'Theme Import Failure: %s [%d] %s',
     141                    $uploader->theme_post->post_title,
     142                    $args['changeset'],
     143                    $args['msg']
     144                ),
     145                sprintf(
     146                    "Hi %s,\n\nYour theme update for %s %s has failed some checks. Please see the below errors.\n\n%s\n\n----\nWordPress Theme Directory",
     147                    $uploader->author->user_email . ' ' .
     148                    ( $uploader->author->display_name ?: $uploader->author->user_login ),
     149                    $uploader->theme->display('Title'),
     150                    $uploader->theme->display('Version'),
     151                    $return->get_error_message(),
     152                ),
     153                [
     154                    'From: "WordPress Theme Directory" <themes@wordpress.org>'
     155                ]
     156            );
    127157        }
    128158    }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r11248 r11588  
    532532        $post = get_post( $post_id );
    533533    }
     534
     535    // Keep track of the last live version.
     536    update_post_meta( $post_id, '_last_live_version', get_post_meta( $post_id, '_live_version', true ) );
    534537
    535538    // Update current version. Used to prioritize localized themes.
Note: See TracChangeset for help on using the changeset viewer.