|
6 | 6 | type PHPRequest, |
7 | 7 | type PathAlias, |
8 | 8 | type RemoteAPI, |
9 | | - type SupportedPHPVersion, |
| 9 | + type AllPHPVersion, |
10 | 10 | } from '@php-wasm/universal'; |
11 | 11 | import { |
12 | 12 | PHPResponse, |
@@ -46,6 +46,8 @@ import type { PlaygroundCliBlueprintV2Worker } from './blueprints-v2/worker-thre |
46 | 46 | import type { XdebugOptions } from '@php-wasm/node'; |
47 | 47 | /* eslint-disable no-console */ |
48 | 48 | import { |
| 49 | + AllPHPVersions, |
| 50 | + isLegacyPHPVersion, |
49 | 51 | SupportedPHPVersions, |
50 | 52 | FileLockManagerInMemory, |
51 | 53 | } from '@php-wasm/universal'; |
@@ -118,7 +120,7 @@ export async function parseOptionsAndRunCLI(argsToParse: string[]) { |
118 | 120 | describe: 'PHP version to use.', |
119 | 121 | type: 'string', |
120 | 122 | default: RecommendedPHPVersion, |
121 | | - choices: SupportedPHPVersions, |
| 123 | + choices: AllPHPVersions, |
122 | 124 | }, |
123 | 125 | wp: { |
124 | 126 | describe: 'WordPress version to use.', |
@@ -373,7 +375,7 @@ export async function parseOptionsAndRunCLI(argsToParse: string[]) { |
373 | 375 | describe: 'PHP version to use.', |
374 | 376 | type: 'string', |
375 | 377 | default: RecommendedPHPVersion, |
376 | | - choices: SupportedPHPVersions, |
| 378 | + choices: AllPHPVersions, |
377 | 379 | }, |
378 | 380 | wp: { |
379 | 381 | describe: 'WordPress version to use.', |
@@ -662,14 +664,24 @@ export async function parseOptionsAndRunCLI(argsToParse: string[]) { |
662 | 664 | const hasDebugDefine = (name: string) => { |
663 | 665 | return name in define || name in defineBool || name in defineNumber; |
664 | 666 | }; |
665 | | - if (!hasDebugDefine('WP_DEBUG')) { |
666 | | - define['WP_DEBUG'] = 'true'; |
667 | | - } |
668 | | - if (!hasDebugDefine('WP_DEBUG_LOG')) { |
669 | | - define['WP_DEBUG_LOG'] = 'true'; |
670 | | - } |
671 | | - if (!hasDebugDefine('WP_DEBUG_DISPLAY')) { |
672 | | - define['WP_DEBUG_DISPLAY'] = 'false'; |
| 667 | + // Don't default WP_DEBUG* on for legacy PHP: old WordPress |
| 668 | + // (pre-2.3) prints E_NOTICE output before headers are sent, |
| 669 | + // which corrupts redirects and breaks the installer. The web |
| 670 | + // worker path applies the same gate in |
| 671 | + // @wp-playground/client/src/blueprints-v1-handler.ts. |
| 672 | + const phpVersionForDebug = (args['php'] || |
| 673 | + RecommendedPHPVersion) as AllPHPVersion; |
| 674 | + const isLegacyPhpForDebug = isLegacyPHPVersion(phpVersionForDebug); |
| 675 | + if (!isLegacyPhpForDebug) { |
| 676 | + if (!hasDebugDefine('WP_DEBUG')) { |
| 677 | + define['WP_DEBUG'] = 'true'; |
| 678 | + } |
| 679 | + if (!hasDebugDefine('WP_DEBUG_LOG')) { |
| 680 | + define['WP_DEBUG_LOG'] = 'true'; |
| 681 | + } |
| 682 | + if (!hasDebugDefine('WP_DEBUG_DISPLAY')) { |
| 683 | + define['WP_DEBUG_DISPLAY'] = 'false'; |
| 684 | + } |
673 | 685 | } |
674 | 686 |
|
675 | 687 | const cliArgs = { |
@@ -736,9 +748,7 @@ export async function parseOptionsAndRunCLI(argsToParse: string[]) { |
736 | 748 | currentError = currentError.cause as Error; |
737 | 749 | } while (currentError instanceof Error); |
738 | 750 | console.error( |
739 | | - '\x1b[1m' + |
740 | | - messageChain.join(' caused by: ') + |
741 | | - '\x1b[0m' |
| 751 | + '\x1b[1m' + messageChain.join(' caused by: ') + '\x1b[0m' |
742 | 752 | ); |
743 | 753 | } |
744 | 754 | } else { |
@@ -811,7 +821,7 @@ export interface RunCLIArgs { |
811 | 821 | mount?: Mount[]; |
812 | 822 | 'mount-before-install'?: Mount[]; |
813 | 823 | outfile?: string; |
814 | | - php?: SupportedPHPVersion; |
| 824 | + php?: AllPHPVersion; |
815 | 825 | port?: number; |
816 | 826 | 'site-url'?: string; |
817 | 827 | quiet?: boolean; |
@@ -990,6 +1000,15 @@ export async function runCLI(args: RunCLIArgs): Promise<RunCLIServer | void> { |
990 | 1000 | args.memcached = await jspi(); |
991 | 1001 | } |
992 | 1002 |
|
| 1003 | + // Disable all extensions for legacy PHP versions — they're not available. |
| 1004 | + const isLegacyPhp = isLegacyPHPVersion(args.php || RecommendedPHPVersion); |
| 1005 | + if (isLegacyPhp) { |
| 1006 | + args.intl = false; |
| 1007 | + args.redis = false; |
| 1008 | + args.memcached = false; |
| 1009 | + args.xdebug = false; |
| 1010 | + } |
| 1011 | + |
993 | 1012 | // Setup phpMyAdmin if enabled. |
994 | 1013 | if (args.phpmyadmin) { |
995 | 1014 | if (true === args.phpmyadmin) { |
@@ -1098,10 +1117,11 @@ export async function runCLI(args: RunCLIArgs): Promise<RunCLIServer | void> { |
1098 | 1117 | vfsPath: '/', |
1099 | 1118 | }; |
1100 | 1119 |
|
| 1120 | + const phpVer = args.php || RecommendedPHPVersion; |
1101 | 1121 | const isPHP85orHigher = |
1102 | | - SupportedPHPVersions.indexOf( |
1103 | | - args.php || RecommendedPHPVersion |
1104 | | - ) <= SupportedPHPVersions.indexOf('8.5'); |
| 1122 | + SupportedPHPVersions.includes(phpVer as any) && |
| 1123 | + SupportedPHPVersions.indexOf(phpVer as any) <= |
| 1124 | + SupportedPHPVersions.indexOf('8.5'); |
1105 | 1125 |
|
1106 | 1126 | // And, if PHP >= 8.5, add the new Xdebug config. |
1107 | 1127 | if (isPHP85orHigher) { |
|
0 commit comments