From e2760cf7b6dc3dd74582ac5e0b9613a7d14ff0a0 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 30 Aug 2023 15:19:27 +0200 Subject: [PATCH 1/2] Update to wp-cli-tests v4 (which requires WPCS v3) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fceed8c8..a14021e6 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "wp-cli/entity-command": "^1.3 || ^2", "wp-cli/export-command": "^1 || ^2", "wp-cli/extension-command": "^1.2 || ^2", - "wp-cli/wp-cli-tests": "^3.1" + "wp-cli/wp-cli-tests": "^4" }, "config": { "process-timeout": 7200, From 98acf38459a52944fb91b961932b77aa88df5a76 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 30 Aug 2023 15:24:59 +0200 Subject: [PATCH 2/2] Fix all autofixable CS issues --- import-command.php | 2 +- src/Import_Command.php | 20 ++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/import-command.php b/import-command.php index 4df8bc1f..d3564aaa 100644 --- a/import-command.php +++ b/import-command.php @@ -4,7 +4,7 @@ return; } -$wpcli_import_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; +$wpcli_import_autoloader = __DIR__ . '/vendor/autoload.php'; if ( file_exists( $wpcli_import_autoloader ) ) { require_once $wpcli_import_autoloader; } diff --git a/src/Import_Command.php b/src/Import_Command.php index 34636a22..34c4b9fa 100644 --- a/src/Import_Command.php +++ b/src/Import_Command.php @@ -210,7 +210,7 @@ private function add_wxr_filters() { add_filter( 'wp_import_posts', - function( $posts ) { + function ( $posts ) { global $wpcli_import_counts; $wpcli_import_counts['current_post'] = 0; $wpcli_import_counts['total_posts'] = count( $posts ); @@ -221,7 +221,7 @@ function( $posts ) { add_filter( 'wp_import_post_comments', - function( $comments, $post_id, $post ) { + function ( $comments, $post_id, $post ) { global $wpcli_import_counts; $wpcli_import_counts['current_comment'] = 0; $wpcli_import_counts['total_comments'] = count( $comments ); @@ -233,7 +233,7 @@ function( $comments, $post_id, $post ) { add_filter( 'wp_import_post_data_raw', - function( $post ) { + function ( $post ) { global $wpcli_import_counts, $wpcli_import_current_file; $wpcli_import_counts['current_post']++; @@ -249,7 +249,7 @@ function( $post ) { add_action( 'wp_import_insert_post', - function( $post_id, $original_post_id, $post, $postdata ) { + function ( $post_id, $original_post_id, $post, $postdata ) { global $wpcli_import_counts; if ( is_wp_error( $post_id ) ) { WP_CLI::warning( '-- Error importing post: ' . $post_id->get_error_code() ); @@ -261,7 +261,6 @@ function( $post_id, $original_post_id, $post, $postdata ) { WP_CLI\Utils\wp_clear_object_cache(); WP_CLI::log( '-- Cleared object cache.' ); } - }, 10, 4 @@ -269,7 +268,7 @@ function( $post_id, $original_post_id, $post, $postdata ) { add_action( 'wp_import_insert_term', - function( $t, $import_term, $post_id, $post ) { + function ( $t, $import_term, $post_id, $post ) { WP_CLI::log( "-- Created term \"{$import_term['name']}\"" ); }, 10, @@ -278,7 +277,7 @@ function( $t, $import_term, $post_id, $post ) { add_action( 'wp_import_set_post_terms', - function( $tt_ids, $term_ids, $taxonomy, $post_id, $post ) { + function ( $tt_ids, $term_ids, $taxonomy, $post_id, $post ) { WP_CLI::log( '-- Added terms (' . implode( ',', $term_ids ) . ") for taxonomy \"{$taxonomy}\"" ); }, 10, @@ -287,7 +286,7 @@ function( $tt_ids, $term_ids, $taxonomy, $post_id, $post ) { add_action( 'wp_import_insert_comment', - function( $comment_id, $comment, $comment_post_id, $post ) { + function ( $comment_id, $comment, $comment_post_id, $post ) { global $wpcli_import_counts; $wpcli_import_counts['current_comment']++; WP_CLI::log( sprintf( '-- Added comment #%d (%s of %s)', $comment_id, number_format( $wpcli_import_counts['current_comment'] ), number_format( $wpcli_import_counts['total_comments'] ) ) ); @@ -298,13 +297,12 @@ function( $comment_id, $comment, $comment_post_id, $post ) { add_action( 'import_post_meta', - function( $post_id, $key, $value ) { + function ( $post_id, $key, $value ) { WP_CLI::log( "-- Added post_meta $key" ); }, 10, 3 ); - } /** @@ -448,7 +446,6 @@ private function create_authors_for_mapping( $author_data ) { ); } return $author_mapping; - } /** @@ -499,5 +496,4 @@ private function suggest_user( $author_user_login, $author_user_email = '' ) { return $closest; } - }