Making WordPress.org

Changeset 13365

Timestamp:
03/20/2024 06:39:08 AM (4 months ago)
Author:
dd32
Message:

Plugin Directory: Blueprint import: Normalize installPlugin/installTheme by url to install-by-slug for WordPress.org items.

This avoids cases of the blueprint referencing an outdated version of the plugin, and attempting to install the plugin twice.

See #7487.

File:
1 edited

Legend:

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

    r13335 r13365  
    11561156            $has_self_install_step = false;
    11571157            if ( isset( $decoded_file[ 'steps' ] ) ) {
    1158                 foreach ( $decoded_file[ 'steps' ] as $i => $step ) {
    1159                     if ( 'installPlugin' === $step['step']
    1160                         && $plugin_slug === $step['pluginZipFile']['slug'] ) {
     1158                foreach ( $decoded_file[ 'steps' ] as &$step ) {
     1159                    // Normalize a "install plugin from url" to a install-by-slug.
     1160                    if (
     1161                        'installPlugin' === $step['step'] &&
     1162                        isset( $step['pluginZipFile']['url'] ) &&
     1163                        preg_match( '!^https?://downloads\.wordpress\.org/plugin/(?P<slug>[a-z0-9-_]+)(\.(?P<version>.+?))?\.zip($|[?])!i', $step['pluginZipFile']['url'], $m )
     1164                    ) {
     1165                        $step[ 'pluginZipFile' ] = [
     1166                            'resource' => 'wordpress.org/plugins',
     1167                            'slug'     => $m['slug']
     1168                        ];
     1169                    }
     1170
     1171                    // Normalise a "install theme from url" to a install-by-slug.
     1172                    if (
     1173                        'installTheme' === $step['step'] &&
     1174                        isset( $step['themeZipFile']['url'] ) &&
     1175                        preg_match( '!^https?://downloads\.wordpress\.org/theme/(?P<slug>[a-z0-9-_]+)(\.(?P<version>.+?))?\.zip($|[?])!i', $step['themeZipFile']['url'], $m )
     1176                    ) {
     1177                        $step[ 'themeZipFile' ] = [
     1178                            'resource' => 'wordpress.org/themes',
     1179                            'slug'     => $m['slug']
     1180                        ];
     1181                    }
     1182
     1183                    // Check if this is a "install this plugin" step.
     1184                    if (
     1185                        'installPlugin' === $step['step'] &&
     1186                        isset( $step['pluginZipFile']['slug'] ) &&
     1187                        $plugin_slug === $step['pluginZipFile']['slug']
     1188                    ) {
    11611189                        $has_self_install_step = true;
    11621190
    11631191                        if ( true != $step['options']['activate'] ) {
    1164                             $decoded_file[ 'steps' ][ $i ][ 'options' ][ 'activate' ] = true;
     1192                            $[ 'options' ][ 'activate' ] = true;
    11651193                        }
    11661194                    }
     
    11691197
    11701198            // Akismet is a special case because the plugin is bundled with WordPress.
    1171             if ( !$has_self_install_step && 'akismet' !== $plugin_slug ) {
     1199            if ( !$has_self_install_step && 'akismet' !== $plugin_slug ) {
    11721200                $decoded_file['steps'][] = array(
    11731201                    'step' => 'installPlugin',
Note: See TracChangeset for help on using the changeset viewer.