Skip to content

Commit

Permalink
Blueprints: Remove setPhpIniEntry step (#1288)
Browse files Browse the repository at this point in the history
Removes the `setPhpIniEntry` step. It doesn't work reliably – setting
PHP.ini entries must happen before the PHP is initialized, but
Blueprints are executed after PHP is initialized. The existing
Blueprints will continue to work – the Blueprints compiler will ignore
the `setPhpIniEntry` step and issue a console warning to notify the
developer.

To set php.ini entries, either customize the php.ini files or use an
mu-plugin.

 ## Testing instructions

Run a Blueprint with a setPhpIniEntry step, confirm the Playground still
runs the rest of the Blueprint.
  • Loading branch information
adamziel authored Apr 21, 2024
1 parent 134694b commit 289ec39
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 37 deletions.
23 changes: 22 additions & 1 deletion packages/playground/blueprints/src/lib/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ export function compileBlueprint(
): CompiledBlueprint {
blueprint = {
...blueprint,
steps: (blueprint.steps || []).filter(isStepDefinition),
steps: (blueprint.steps || [])
.filter(isStepDefinition)
.filter(isStepStillSupported),
};
// Convert legacy importFile steps to importWxr
for (const step of blueprint.steps!) {
Expand Down Expand Up @@ -414,6 +416,25 @@ function isStepDefinition(
return !!(typeof step === 'object' && step);
}

/**
* Determines if a step is still supported, or was it deprecated
* and removed.
*
* @param step The step definition to test.
* @returns Whether the step is still supported.
*/
function isStepStillSupported(
step: Record<string, any>
): step is StepDefinition {
if (step['step'] === 'setPhpIniEntry') {
console.warn(
`The "setPhpIniEntry" Blueprint is no longer supported and you can remove it from your Blueprint.`
);
return false;
}
return true;
}

interface CompileStepArgsOptions {
/** Optional semaphore to control access to a shared resource */
semaphore?: Semaphore;
Expand Down
1 change: 0 additions & 1 deletion packages/playground/blueprints/src/lib/steps/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export { activateTheme } from './activate-theme';
export { runPHP } from './run-php';
export { runPHPWithOptions } from './run-php-with-options';
export { runSql } from './run-sql';
export { setPhpIniEntry } from './set-php-ini-entry';
export { request } from './request';
export { enableMultisite } from './enable-multisite';
export { cp } from './cp';
Expand Down
3 changes: 0 additions & 3 deletions packages/playground/blueprints/src/lib/steps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { RmdirStep } from './rmdir';
import { RunSqlStep } from './run-sql';
import { MkdirStep } from './mkdir';
import { MvStep } from './mv';
import { SetPhpIniEntryStep } from './set-php-ini-entry';
import { RunPHPStep } from './run-php';
import { RunPHPWithOptionsStep } from './run-php-with-options';
import { RequestStep } from './request';
Expand Down Expand Up @@ -65,7 +64,6 @@ export type GenericStep<Resource> =
| RunPHPWithOptionsStep
| RunWpInstallationWizardStep
| RunSqlStep<Resource>
| SetPhpIniEntryStep
| SetSiteOptionsStep
| UnzipStep<Resource>
| UpdateUserMetaStep
Expand Down Expand Up @@ -96,7 +94,6 @@ export type {
RunWpInstallationWizardStep,
RunSqlStep,
WordPressInstallationOptions,
SetPhpIniEntryStep,
SetSiteOptionsStep,
UnzipStep,
UpdateUserMetaStep,
Expand Down
32 changes: 0 additions & 32 deletions packages/playground/blueprints/src/lib/steps/set-php-ini-entry.ts

This file was deleted.

0 comments on commit 289ec39

Please sign in to comment.