Changeset 12050 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/cli-commands.php
- Timestamp:
- 09/05/2022 05:14:31 AM (3 years ago)
- 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 102 102 } 103 103 104 // Determine importing user's ID. 104 // Determine importing user's ID. 105 105 $user = get_user_by( 'id', $user_id ); 106 106 if ( ! $user ) { … … 113 113 'posts-to-posts' => 'posts-to-posts/posts-to-posts.php', 114 114 ]; 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 }130 115 131 116 // Install phpdoc-parser plugin dependencies if not installed. … … 189 174 190 175 // 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' : ''; 191 178 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}" ); 193 180 194 181 // 4. Deactivate phpdoc-parser plugin. … … 279 266 } 280 267 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 297 268 WP_CLI::success( 'Clean-up is complete.' ); 298 269 }
Note: See TracChangeset
for help on using the changeset viewer.