Skip to content

Commit

Permalink
Importing regression fix – support old exported Playground ZIPs
Browse files Browse the repository at this point in the history
Closes #1543

Playground exports before changes from the Boot Protocol (#1398)
contained platform-level WordPress plugins and mu-plugins. The importer,
then, removed them and replaced them with the latest version freshly sourced
from the /wordpress directory.

However, after the Boot Protocol changes, Playground no longer includes any
platform-level plugins in the /wordpress directory. This means that
things like SQLite database integration were being removed from the
imported ZIP bundle but they were not restored.

This PR removes this "remove & restore" mechanism. If the ZIP comes with
its own SQLite database integration, that one will be used. If it
doesn't, then Playground will fall back to the platform-level plugin.

 ## Testing instructions

1. Export Playground as zip and import it again. Confirm this worked.
2. Run [this Blueprint that imports an older ZIP bundle](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/%22,%22preferredVersions%22:{%22php%22:%228.0%22,%22wp%22:%22latest%22},%22phpExtensionBundles%22:[%22kitchen-sink%22],%22features%22:{%22networking%22:true},%22steps%22:[{%22step%22:%22importWordPressFiles%22,%22wordPressFilesZip%22:{%22resource%22:%22url%22,%22url%22:%22https://kybernaut.cz/blueprints/pay-for-payment-playground.zip%22}},{%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22},{%22step%22:%22installPlugin%22,%22pluginZipFile%22:{%22resource%22:%22wordpress.org/plugins%22,%22slug%22:%22woocommerce-pay-for-payment%22},%22options%22:{%22activate%22:true}}]}) and confirm it works

CC @vyskoczilova
  • Loading branch information
adamziel committed Jul 3, 2024
1 parent c5f97ce commit e7e6a37
Showing 1 changed file with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { StepHandler } from '.';
import { unzip } from './unzip';
import { dirname, joinPaths, phpVar } from '@php-wasm/util';
import { joinPaths, phpVar } from '@php-wasm/util';
import { UniversalPHP } from '@php-wasm/universal';
import { wpContentFilesExcludedFromExport } from '../utils/wp-content-files-excluded-from-exports';
import { defineSiteUrl } from './define-site-url';

/**
Expand Down Expand Up @@ -59,28 +58,6 @@ export const importWordPressFiles: StepHandler<
});
importPath = joinPaths(importPath, pathInZip);

// Carry over any Playground-related files, such as the
// SQLite database plugin, from the current wp-content
// into the one that's about to be imported
const importedWpContentPath = joinPaths(importPath, 'wp-content');
const wpContentPath = joinPaths(documentRoot, 'wp-content');
for (const relativePath of wpContentFilesExcludedFromExport) {
// Remove any paths that were supposed to be excluded from the export
// but maybe weren't
const excludedImportPath = joinPaths(
importedWpContentPath,
relativePath
);
await removePath(playground, excludedImportPath);

// Replace them with files sourced from the live wp-content directory
const restoreFromPath = joinPaths(wpContentPath, relativePath);
if (await playground.fileExists(restoreFromPath)) {
await playground.mkdir(dirname(excludedImportPath));
await playground.mv(restoreFromPath, excludedImportPath);
}
}

// Carry over the database directory if the imported zip file doesn't
// already contain one.
const importedDatabasePath = joinPaths(
Expand Down

0 comments on commit e7e6a37

Please sign in to comment.