|
6 | 6 | PHPRequestHandler, |
7 | 7 | proxyFileSystem, |
8 | 8 | rotatePHPRuntime, |
| 9 | + getPhpIniEntries, |
9 | 10 | setPhpIniEntries, |
10 | 11 | } from '@php-wasm/universal'; |
11 | 12 | import { wordPressRewriteRules, getFileNotFoundActionForWordPress } from '@wp-playground/wordpress'; |
@@ -66,6 +67,8 @@ export default async function startWPNow( |
66 | 67 |
|
67 | 68 | const php = await requestHandler.getPrimaryPhp(); |
68 | 69 |
|
| 70 | + await applyOverrideUmaskWorkaround( php ); |
| 71 | + |
69 | 72 | prepareDocumentRoot( php, options ); |
70 | 73 |
|
71 | 74 | output?.log( `directory: ${ options.projectPath }` ); |
@@ -563,3 +566,23 @@ export async function moveDatabasesInSitu( projectPath: string ) { |
563 | 566 | fs.rmSync( wpContentPath, { recursive: true, force: true } ); |
564 | 567 | } |
565 | 568 | } |
| 569 | + |
| 570 | +/** |
| 571 | + * The default `umask` set by Emscripten is 0777 which is too restrictive. This has been updated |
| 572 | + * in https://github.com/emscripten-core/emscripten/pull/22589 but is not available in the stable |
| 573 | + * version of Emscripten yet. In the meantime, we'll apply a workaround by setting the umask via |
| 574 | + * `auto_prepend_file` PHP directive. |
| 575 | + * |
| 576 | + * Once the Emscripten update is available, a new version of Playground is released using the |
| 577 | + * updated Emscripten, and the Playground dependency is updated in the app, this workaround can be removed. |
| 578 | + */ |
| 579 | +async function applyOverrideUmaskWorkaround( php: PHP ) { |
| 580 | + const iniEntries = await getPhpIniEntries( php ); |
| 581 | + await setPhpIniEntries( php, { |
| 582 | + ...iniEntries, |
| 583 | + auto_prepend_file: '/internal/shared/studio/auto-prepend-file.php', |
| 584 | + } ); |
| 585 | + |
| 586 | + php.mkdir( '/internal/shared/studio' ); |
| 587 | + php.writeFile( '/internal/shared/studio/auto-prepend-file.php', '<?php umask(0022);' ); |
| 588 | +} |
0 commit comments