From c06eff575b45cf4472892732d6b3bbcd4b241d05 Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Mon, 25 Jul 2022 18:04:37 +0200 Subject: [PATCH] fix: remove blueprint cleanup step (#603) This step is throwing a fatal error in production. I would rather remove it than conditionally run it. --- docs/wp-cli/index.md | 7 +------ includes/blueprints/import.php | 19 ------------------- includes/wp-cli/class-blueprint.php | 16 ---------------- .../blueprints/test-blueprint-import.php | 12 ------------ 4 files changed, 1 insertion(+), 53 deletions(-) diff --git a/docs/wp-cli/index.md b/docs/wp-cli/index.md index 1000ead5d..505bb2944 100644 --- a/docs/wp-cli/index.md +++ b/docs/wp-cli/index.md @@ -19,7 +19,7 @@ Imports an ACM blueprint from a URL or File Path. ### Synopsis ``` -wp acm blueprint import [--skip-cleanup] +wp acm blueprint import ``` ### Options @@ -27,11 +27,6 @@ wp acm blueprint import [--skip-cleanup] `` The URL or local path of the blueprint zip file, or local path to the blueprint folder containing the acm.json manifest file. Local paths must be absolute. -`[--skip-cleanup]` -Skips removal of the blueprint zip and manifest files after a -successful import. Useful when testing blueprints or to leave a -record of content and files that were installed. - ### Examples ``` diff --git a/includes/blueprints/import.php b/includes/blueprints/import.php index 991290bd9..491b83efd 100644 --- a/includes/blueprints/import.php +++ b/includes/blueprints/import.php @@ -550,22 +550,3 @@ function import_options( array $options ): void { update_option( $name, $value ); } } - -/** - * Deletes the blueprint zip file and manifest file. - * - * Leaves media files in place because they are linked to imported media. - * - * @param string $blueprint_zip_path Path to the blueprint zip file. - * @param string $blueprint_folder_path Path to the blueprint folder. - * @return void - */ -function cleanup( $blueprint_zip_path, $blueprint_folder_path ) { - if ( file_exists( $blueprint_zip_path ) ) { - wp_delete_file( $blueprint_zip_path ); - } - - if ( file_exists( $blueprint_folder_path . '/acm.json' ) ) { - wp_delete_file( $blueprint_folder_path . '/acm.json' ); - } -} diff --git a/includes/wp-cli/class-blueprint.php b/includes/wp-cli/class-blueprint.php index d55fd023f..3b9d56abd 100644 --- a/includes/wp-cli/class-blueprint.php +++ b/includes/wp-cli/class-blueprint.php @@ -17,7 +17,6 @@ use function WPE\AtlasContentModeler\Blueprint\Import\{ check_versions, - cleanup, get_manifest, import_acm_relationships, import_media, @@ -62,13 +61,6 @@ class Blueprint { * blueprint folder containing the acm.json manifest file. Local paths must * be absolute. * - * [--skip-cleanup] - * : Skips removal of the blueprint zip and manifest files after a - * successful import. Useful when testing blueprints or to leave a - * record of content and files that were installed. Has no effect - * if the `path` passed to `blueprint import` is a local directory - * and not a zip file. - * * ## EXAMPLES * * wp acm blueprint import https://example.com/path/to/blueprint.zip @@ -227,14 +219,6 @@ public function import( $args, $assoc_args ) { import_options( $manifest['wp-options'] ); } - if ( - ! ( $assoc_args['skip-cleanup'] ?? false ) - && ! $path_is_directory - ) { - \WP_CLI::log( 'Deleting zip and manifest.' ); - cleanup( $zip_file, $blueprint_folder ); - } - \WP_CLI::success( 'Import complete.' ); } diff --git a/tests/integration/blueprints/test-blueprint-import.php b/tests/integration/blueprints/test-blueprint-import.php index c05dc93f9..b372d0617 100644 --- a/tests/integration/blueprints/test-blueprint-import.php +++ b/tests/integration/blueprints/test-blueprint-import.php @@ -7,7 +7,6 @@ use function WPE\AtlasContentModeler\Blueprint\Import\{ check_versions, - cleanup, get_manifest, import_acm_relationships, import_media, @@ -305,17 +304,6 @@ public function test_unzip_blueprint_renamed() { self::assertTrue( is_readable( $upload_dir . '/acm-rabbits/acm.json' ) ); } - public function test_cleanup() { - $this->copy_media_to_wp_uploads(); - - $upload_dir = wp_upload_dir()['path']; - - cleanup( $upload_dir . '/acm-rabbits.zip', $upload_dir . '/blueprint-good/' ); - - self::assertFalse( is_readable( $upload_dir . '/acm-rabbits.zip' ) ); - self::assertFalse( is_readable( $upload_dir . '/blueprint-good/acm.json' ) ); - } - private function copy_media_to_wp_uploads() { global $wp_filesystem;