From 185989b6a6d9d98384d70aecc18d9c7fde75b0bd Mon Sep 17 00:00:00 2001 From: Sherif Date: Thu, 19 Dec 2024 16:35:22 +0200 Subject: [PATCH 1/3] Update getting file paths and checksum and account for sha1 --- includes/class-gf-cli-tool.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/class-gf-cli-tool.php b/includes/class-gf-cli-tool.php index 808e003..5e8b364 100644 --- a/includes/class-gf-cli-tool.php +++ b/includes/class-gf-cli-tool.php @@ -82,16 +82,20 @@ public function verify_checksums( $args, $assoc_args ) { $has_errors = false; foreach ( $checksums as $checksum_string ) { - $checksum = substr( $checksum_string, 0, 32 ); - $file = str_replace( $checksum . ' ', '', $checksum_string ); + list( $checksum, $file ) = explode( ' ', $checksum_string ); $path = GFCommon::get_base_path() . DIRECTORY_SEPARATOR . $file; if ( ! file_exists( $path ) ) { WP_CLI::warning( "File doesn't exist: {$file}" ); $has_errors = true; continue; } - $md5_file = md5_file( $path ); - if ( $md5_file !== $checksum ) { + $hashed_file = ''; + if ( strlen( $checksum ) === 32 ) { + $hashed_file = md5_file( $path ); + } elseif ( strlen( $checksum) === 40 ) { + $hashed_file = sha1_file( $path ); + } + if ( $hashed_file !== $checksum ) { WP_CLI::warning( "File doesn't verify against checksum: {$file}" ); $has_errors = true; } From 667e49a0ed69b51ced5d3943df6ff2f63ad3f1c2 Mon Sep 17 00:00:00 2001 From: Sherif Date: Thu, 19 Dec 2024 16:36:04 +0200 Subject: [PATCH 2/3] Update changelog bump version --- change_log.txt | 3 +++ cli.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/change_log.txt b/change_log.txt index fa297f9..22a4611 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ += 1.8 = +- Fixed a bug where the verify checksums command fails even when it should succeed. + = 1.7 = - Fixed a bug that sometimes causes the form ID to be stored as a string. diff --git a/cli.php b/cli.php index 2ea4cde..ac069d9 100644 --- a/cli.php +++ b/cli.php @@ -3,7 +3,7 @@ Plugin Name: Gravity Forms CLI Plugin URI: https://gravityforms.com Description: Manage Gravity Forms with the WP CLI. -Version: 1.7 +Version: 1.8 Author: Rocketgenius Author URI: https://gravityforms.com License: GPL-2.0+ @@ -30,7 +30,7 @@ defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die(); // Defines the current version of the CLI add-on -define( 'GF_CLI_VERSION', '1.7' ); +define( 'GF_CLI_VERSION', '1.8' ); define( 'GF_CLI_MIN_GF_VERSION', '1.9.17.8' ); From 2cd35e9f2f75c265fffed12ddaebc48a684c6dc5 Mon Sep 17 00:00:00 2001 From: Sherif Date: Thu, 19 Dec 2024 22:21:26 +0200 Subject: [PATCH 3/3] missing space Co-authored-by: Richard Wawrzyniak --- includes/class-gf-cli-tool.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-gf-cli-tool.php b/includes/class-gf-cli-tool.php index 5e8b364..582d0e0 100644 --- a/includes/class-gf-cli-tool.php +++ b/includes/class-gf-cli-tool.php @@ -92,7 +92,7 @@ public function verify_checksums( $args, $assoc_args ) { $hashed_file = ''; if ( strlen( $checksum ) === 32 ) { $hashed_file = md5_file( $path ); - } elseif ( strlen( $checksum) === 40 ) { + } elseif ( strlen( $checksum ) === 40 ) { $hashed_file = sha1_file( $path ); } if ( $hashed_file !== $checksum ) {