Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override default umask in PHP #555

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion vendor/wp-now/src/wp-now.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
rotatePHPRuntime,
setPhpIniEntries,
} from '@php-wasm/universal';
import { wordPressRewriteRules, getFileNotFoundActionForWordPress } from '@wp-playground/wordpress';
import {
wordPressRewriteRules,
getFileNotFoundActionForWordPress,
setupPlatformLevelMuPlugins,
} from '@wp-playground/wordpress';
import path from 'path';
import { SQLITE_FILENAME } from './constants';
import { rootCertificates } from 'tls';
Expand Down Expand Up @@ -109,6 +113,11 @@ export default async function startWPNow(
await activatePluginOrTheme( php, options );
}

// Setup internal plugins needed for Playground
await setupPlatformLevelMuPlugins( php );
fluiddot marked this conversation as resolved.
Show resolved Hide resolved
// Add custom plugins needed for Studio sites
addDefaultUmaskPlugin( php, options.documentRoot );

rotatePHPRuntime( {
php,
cwd: requestHandler.documentRoot,
Expand Down Expand Up @@ -563,3 +572,15 @@ export async function moveDatabasesInSitu( projectPath: string ) {
fs.rmSync( wpContentPath, { recursive: true, force: true } );
}
}

function addDefaultUmaskPlugin( php: PHP, documentRoot: string ) {
php.writeFile(
'/internal/shared/mu-plugins/override-default-umask.php',
fluiddot marked this conversation as resolved.
Show resolved Hide resolved
`<?php
function set_default_umask()
{
umask(0022);
}
add_action('init', 'set_default_umask', -9999);`
fluiddot marked this conversation as resolved.
Show resolved Hide resolved
);
}
Loading