Making WordPress.org


Ignore:
Timestamp:
07/07/2021 06:43:06 AM (5 years ago)
Author:
dd32
Message:

Theme Directory: When a theme upload fails due to Trac ticket creation failures, automatically remove the SVN directory.

This should result in less cleanup when the upload handler or trac is having trouble.

Fixes #5812.

File:
1 edited

Legend:

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

    r11059 r11102  
    428428
    429429                if ( ! $ticket_id  ) {
     430                        // Since it's been added to SVN at this point, remove it from SVN to prevent future issues.
     431                        $this->remove_from_svn( 'Trac ticket creation failed.' );
     432
    430433                        /* translators: %s: mailto link */
    431434                        return sprintf( __( 'There was an error creating a Trac ticket for your theme, please report this error to %s', 'wporg-themes' ),
    … …  
    11111114
    11121115                return false;
     1116        }
     1117
     1118        /**
     1119         * Remove a theme version commited to SVN.
     1120         */
     1121        function remove_from_svn( $reason ) {
     1122                $svn_path = "{$this->theme_slug}/{$this->theme->display( 'Version' )}";
     1123                if ( ! $this->theme_slug || ! $this->theme->display( 'Version' ) || strlen( $svn_path ) < 3 ) {
     1124                        return false;
     1125                }
     1126
     1127                $import_msg = 'Removing theme %1$s - %2$s: %3$s';
     1128                $import_msg = escapeshellarg( sprintf( $import_msg, $this->theme->display( 'Name' ), $this->theme->display( 'Version' ), $reason ) );
     1129                $svn_path   = escapeshellarg( "https://themes.svn.wordpress.org/{$svn_path}" );
     1130                $password   = escapeshellarg( THEME_DROPBOX_PASSWORD );
     1131
     1132                $last_line = $this->exec_with_notify( self::SVN . " --non-interactive --username themedropbox --password {$password} -m {$import_msg} rm {$svn_path}" );
     1133
     1134                return (bool) preg_match( '/Committed revision (\d+)\./i', $last_line );
    11131135        }
    11141136
Note: See TracChangeset for help on using the changeset viewer.