Making WordPress.org


Ignore:
Timestamp:
05/17/2024 06:14:37 AM (14 months ago)
Author:
dd32
Message:

Plugin Directory: Allow plugin slugs to be renamed during the approval stage.

This allows plugin reviewers to change the slug immediately after the plugin is approved, but before the author commits any code.

Fixes #6878.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php

    r13709 r13729  
    430430
    431431    /**
     432     * Rename a SVN path (or url).
     433     *
     434     * @static
     435     *
     436     * @param string $from    The path of the SVN folder to rename. May be a URL.
     437     * @param string $to      The new path of the SVN folder. May be a URL.
     438     * @param array  $options  Optional. A list of options to pass to SVN. Default: empty array.
     439     * @return array {
     440     *     @type bool        $result   The result of the operation.
     441     *     @type int         $revision The revision.
     442     *     @type false|array $errors   Whether any errors or warnings were encountered.
     443     * }
     444     */
     445    public static function rename( $from, $to, $options = array() ) {
     446        $options[] = 'non-interactive';
     447        $is_url    = ( preg_match( '#https?://#i', $from ) && preg_match( '#https?://#i', $to ) );
     448
     449        if ( $is_url ) {
     450            // Set the message if not provided.
     451            if ( ! isset( $options['message'] ) && ! isset( $options['m'] ) ) {
     452                $options['message'] = sprintf( "Rename %s to %s.", basename( $from ), basename( $to ) );
     453            }
     454
     455            if ( empty( $options['username'] ) ) {
     456                $options['username'] = PLUGIN_SVN_MANAGEMENT_USER;
     457                $options['password'] = PLUGIN_SVN_MANAGEMENT_PASS;
     458            }
     459        }
     460
     461        $esc_options = self::parse_esc_parameters( $options );
     462
     463        $esc_from = escapeshellarg( $from );
     464        $esc_to   = escapeshellarg( $to );
     465
     466        $output = self::shell_exec( "svn mv $esc_from $esc_to $esc_options 2>&1" );
     467        if ( $is_url && preg_match( '/Committed revision (?P<revision>\d+)[.]/i', $output, $m ) ) {
     468            $revision = (int) $m['revision'];
     469            $result   = true;
     470            $errors   = false;
     471        } else {
     472            $errors   = self::parse_svn_errors( $output );
     473            $revision = false;
     474
     475            if ( $is_url || $errors ) {
     476                $result = false;
     477            } else {
     478                $result = true;
     479            }
     480        }
     481
     482        return compact( 'result', 'revision', 'errors' );
     483    }
     484
     485    /**
    432486     * Parse and escape the provided SVN arguements for usage on the CLI.
    433487     *
Note: See TracChangeset for help on using the changeset viewer.