From 50e07129c61469bc4d9e4f34f854b1cfb418c275 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 5 Aug 2024 16:18:51 +0200 Subject: [PATCH 1/2] Fix PHPCS errors --- src/Import_Command.php | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/Import_Command.php b/src/Import_Command.php index 34c4b9fa..83b9fee2 100644 --- a/src/Import_Command.php +++ b/src/Import_Command.php @@ -221,14 +221,12 @@ function ( $posts ) { add_filter( 'wp_import_post_comments', - function ( $comments, $post_id, $post ) { + function ( $comments ) { global $wpcli_import_counts; $wpcli_import_counts['current_comment'] = 0; $wpcli_import_counts['total_comments'] = count( $comments ); return $comments; - }, - 10, - 3 + } ); add_filter( @@ -249,7 +247,7 @@ function ( $post ) { add_action( 'wp_import_insert_post', - function ( $post_id, $original_post_id, $post, $postdata ) { + function ( $post_id ) { global $wpcli_import_counts; if ( is_wp_error( $post_id ) ) { WP_CLI::warning( '-- Error importing post: ' . $post_id->get_error_code() ); @@ -261,47 +259,43 @@ function ( $post_id, $original_post_id, $post, $postdata ) { WP_CLI\Utils\wp_clear_object_cache(); WP_CLI::log( '-- Cleared object cache.' ); } - }, - 10, - 4 + } ); add_action( 'wp_import_insert_term', - function ( $t, $import_term, $post_id, $post ) { + function ( $t, $import_term ) { WP_CLI::log( "-- Created term \"{$import_term['name']}\"" ); }, 10, - 4 + 2 ); add_action( 'wp_import_set_post_terms', - function ( $tt_ids, $term_ids, $taxonomy, $post_id, $post ) { + function ( $tt_ids, $term_ids, $taxonomy ) { WP_CLI::log( '-- Added terms (' . implode( ',', $term_ids ) . ") for taxonomy \"{$taxonomy}\"" ); }, 10, - 5 + 3 ); add_action( 'wp_import_insert_comment', - function ( $comment_id, $comment, $comment_post_id, $post ) { + function ( $comment_id ) { 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'] ) ) ); - }, - 10, - 4 + } ); add_action( 'import_post_meta', - function ( $post_id, $key, $value ) { + function ( $post_id, $key ) { WP_CLI::log( "-- Added post_meta $key" ); }, 10, - 3 + 2 ); } From 85f88fe08463c5d000cde46096645ddeac6a3b2c Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 6 Aug 2024 12:03:04 +0545 Subject: [PATCH 2/2] Require MySQL in feature tests --- features/import.feature | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/features/import.feature b/features/import.feature index ed180633..c9d011c8 100644 --- a/features/import.feature +++ b/features/import.feature @@ -9,7 +9,7 @@ Feature: Import content. Error: WordPress Importer needs to be installed. Try 'wp plugin install wordpress-importer --activate'. """ - @require-wp-5.2 + @require-wp-5.2 @require-mysql Scenario: Basic export then import Given a WP install And I run `wp site empty --yes` @@ -51,7 +51,7 @@ Feature: Import content. When I run `wp import {EXPORT_FILE} --authors=skip --skip=image_resize` Then STDOUT should not be empty - @require-wp-5.2 + @require-wp-5.2 @require-mysql Scenario: Export and import a directory of files Given a WP install And I run `mkdir export-posts` @@ -101,7 +101,7 @@ Feature: Import content. 100 """ - @require-wp-5.2 + @require-wp-5.2 @require-mysql Scenario: Export and import a directory of files with .wxr and .xml extensions. Given a WP install And I run `mkdir export` @@ -148,7 +148,7 @@ Feature: Import content. 2 """ - @require-wp-5.2 + @require-wp-5.2 @require-mysql Scenario: Export and import page and referencing menu item Given a WP install And I run `wp site empty --yes` @@ -225,7 +225,7 @@ Feature: Import content. 2 """ - @require-wp-5.2 + @require-wp-5.2 @require-mysql Scenario: Export and import page and referencing menu item in separate files Given a WP install And I run `wp site empty --yes` @@ -303,7 +303,7 @@ Feature: Import content. 2 """ - @require-wp-5.2 + @require-wp-5.2 @require-mysql Scenario: Indicate current file when importing Given a WP install And I run `wp plugin install --activate wordpress-importer`