Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
fix: remove blueprint cleanup step (#603)
Browse files Browse the repository at this point in the history
This step is throwing a fatal error in production. I would rather
remove it than conditionally run it.
  • Loading branch information
nickcernis authored Jul 25, 2022
1 parent 40368c3 commit c06eff5
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 53 deletions.
7 changes: 1 addition & 6 deletions docs/wp-cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@ Imports an ACM blueprint from a URL or File Path.
### Synopsis

```
wp acm blueprint import <path> [--skip-cleanup]
wp acm blueprint import <path>
```

### Options

`<path>`
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

```
Expand Down
19 changes: 0 additions & 19 deletions includes/blueprints/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
}
16 changes: 0 additions & 16 deletions includes/wp-cli/class-blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

use function WPE\AtlasContentModeler\Blueprint\Import\{
check_versions,
cleanup,
get_manifest,
import_acm_relationships,
import_media,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.' );
}

Expand Down
12 changes: 0 additions & 12 deletions tests/integration/blueprints/test-blueprint-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use function WPE\AtlasContentModeler\Blueprint\Import\{
check_versions,
cleanup,
get_manifest,
import_acm_relationships,
import_media,
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit c06eff5

Please sign in to comment.