From 575a44124af2acec3accdcf2e758a137be1e1bb6 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 30 Aug 2023 15:19:25 +0200 Subject: [PATCH 1/4] 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 5ab921f9..a6eccae4 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "wp-cli/entity-command": "^1.3 || ^2", - "wp-cli/wp-cli-tests": "^3.1" + "wp-cli/wp-cli-tests": "^4" }, "config": { "process-timeout": 7200, From d3dbd58341f9aa3571cfb9a6f9a56aace4c9cdea Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 30 Aug 2023 15:24:57 +0200 Subject: [PATCH 2/4] Fix all autofixable CS issues --- db-command.php | 2 +- src/DB_Command.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db-command.php b/db-command.php index 2e3e54e1..d08f55bb 100644 --- a/db-command.php +++ b/db-command.php @@ -4,7 +4,7 @@ return; } -$wpcli_db_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; +$wpcli_db_autoloader = __DIR__ . '/vendor/autoload.php'; if ( file_exists( $wpcli_db_autoloader ) ) { require_once $wpcli_db_autoloader; } diff --git a/src/DB_Command.php b/src/DB_Command.php index 3161e7c2..3c192eeb 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -1114,7 +1114,7 @@ public function size( $args, $assoc_args ) { if ( $orderby ) { usort( $rows, - function( $a, $b ) use ( $order, $orderby ) { + function ( $a, $b ) use ( $order, $orderby ) { $orderby_array = 'asc' === $order ? array( $a, $b ) : array( $b, $a ); list( $first, $second ) = $orderby_array; From 0e22b44dbb48a14efff23e5f6279c56d3aaab8c5 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 30 Aug 2023 08:41:59 -0700 Subject: [PATCH 3/4] Avoid nested control structure --- src/DB_Command.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/DB_Command.php b/src/DB_Command.php index 3c192eeb..bc2165e2 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -1373,11 +1373,9 @@ public function search( $args, $assoc_args ) { if ( ! $text_columns ) { if ( $stats ) { $skipped[] = $table; - } else { - // Don't bother warning for term relationships (which is just 3 int columns). - if ( ! preg_match( '/_term_relationships$/', $table ) ) { - WP_CLI::warning( $primary_keys ? "No text columns for table '$table' - skipped." : "No primary key or text columns for table '$table' - skipped." ); - } + // Don't bother warning for term relationships (which is just 3 int columns). + } elseif ( ! preg_match( '/_term_relationships$/', $table ) ) { + WP_CLI::warning( $primary_keys ? "No text columns for table '$table' - skipped." : "No primary key or text columns for table '$table' - skipped." ); } continue; } From 7a892161cb8ad395d779fb189fefb8009ada9200 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 30 Aug 2023 08:44:06 -0700 Subject: [PATCH 4/4] Fix linting issue --- src/DB_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DB_Command.php b/src/DB_Command.php index bc2165e2..1086fdec 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -1373,7 +1373,7 @@ public function search( $args, $assoc_args ) { if ( ! $text_columns ) { if ( $stats ) { $skipped[] = $table; - // Don't bother warning for term relationships (which is just 3 int columns). + // Don't bother warning for term relationships (which is just 3 int columns). } elseif ( ! preg_match( '/_term_relationships$/', $table ) ) { WP_CLI::warning( $primary_keys ? "No text columns for table '$table' - skipped." : "No primary key or text columns for table '$table' - skipped." ); }