Making WordPress.org


Ignore:
Timestamp:
09/05/2022 05:14:31 AM (3 years ago)
Author:
dufresnesteven
Message:

wporg-developer: Sync with https://github.com/WordPress/wporg-developer/commit/790d402933d2725374de0d19e6bf6a576c8b15d2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/cli-commands.php

    r11949 r12050  
    102102        }
    103103
    104         // Determine importing user's ID. 
     104        // Determine importing user's ID.
    105105        $user = get_user_by( 'id', $user_id );
    106106        if ( ! $user ) {
     
    113113            'posts-to-posts' => 'posts-to-posts/posts-to-posts.php',
    114114        ];
    115 
    116         // Get the phpdoc-parser plugin if not installed.
    117         $all_plugins = get_plugins();
    118         if ( ! in_array( $plugins['phpdoc-parser'], array_keys( $all_plugins ) ) ) {
    119             WP_CLI::log( "Installing phpdoc-parser plugin..." );
    120             WP_CLI::runcommand( 'plugin install https://github.com/WordPress/phpdoc-parser/archive/master.zip' );
    121             touch( WP_PLUGIN_DIR . '/phpdoc-parser/.devhub-parser-installed' );
    122         }
    123 
    124         // Verify the phpdoc-parser plugin is available locally.
    125         wp_cache_set( 'plugins', [], 'plugins' ); // Reset cache of plugins.
    126         $all_plugins = get_plugins();
    127         if ( ! in_array( $plugins['phpdoc-parser'], array_keys( $all_plugins ) ) ) {
    128             WP_CLI::error( 'The PHPDoc-Parser plugin (from https://github.com/WordPress/phpdoc-parser) could not be automatically installed locally in ' . WP_PLUGIN_DIR . '/. Please do so manually.' );
    129         }
    130115
    131116        // Install phpdoc-parser plugin dependencies if not installed.
     
    189174
    190175        // 3. Run the parser.
     176        // If running locally, run a quick parse which skips DB replication-lag sleep()'s
     177        $quick = in_array( wp_get_environment_type(), array( 'local', 'development' ) ) ? '--quick' : '';
    191178        WP_CLI::log( 'Running the parser (this will take awhile)...' );
    192         WP_CLI::runcommand( "parser create {$path} --user={$user_id}" );
     179        WP_CLI::runcommand( "parser create {$path} --user={$user_id} {$quick}" );
    193180
    194181        // 4. Deactivate phpdoc-parser plugin.
     
    279266        }
    280267
    281         // Remove the phpdoc-parser plugin.
    282         // @todo Add argument to facilitate disabling this step, or do a git checkout and only delete if no local changes.
    283         $plugin = 'phpdoc-parser';
    284         $all_plugins = get_plugins();
    285         if ( in_array( $plugin . '/plugin.php', array_keys( $all_plugins ) ) ) {
    286             // Only delete the plugin if it was automatically installed via parse command.
    287             if ( file_exists( WP_PLUGIN_DIR . '/phpdoc-parser/.devhub-parser-installed' ) ) {
    288                 WP_CLI::log( "Deleting plugin {$plugin}..." );
    289                 WP_CLI::runcommand( "plugin delete {$plugin}" );
    290             } else {
    291                 WP_CLI::log( "Plugin {$plugin} present but was manually installed or looks to have customizations so it must be deleted manually, if so desired." );
    292             }
    293         } else {
    294             WP_CLI::log( "Plugin {$plugin} not present so it can't be deleted." );
    295         }
    296 
    297268        WP_CLI::success( 'Clean-up is complete.' );
    298269    }
Note: See TracChangeset for help on using the changeset viewer.