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

Blueprints: Write sunrise.php to /internal in enableMultisite step #1401

Merged
merged 7 commits into from
May 15, 2024

Conversation

adamziel
Copy link
Collaborator

What is this PR doing?

Writes sunrise.php to the /internal directory instead of /wordpress to ensure setting up a multisite won't pollute local website when mounted.

Related to Boot Protocol

Testing Instructions

Confirm the CI checks pass.

adamziel added 5 commits May 15, 2024 14:41
…elated to redefining those constants

Changes the default meethod of defining PHP constants from rewriting
the `define()` calls in wp-config.php to pre-defining constants via
an `auto_prepend_file`.

 ## Problem solved by this PR

Playground needs to define some WordPress constants like SITE_URL or HOME_URL.
Unfortunately, the site loaded into Playground may already have a
conflicting `define()` call in its `wp-config.php`. Historically, we'va
avoided PHP warnings by rewriting the `define()` calls in the `wp-config.php` file.

It works quite well, but when the `wp-config.php` file is mounted from a
local directory, Playground would change its contents. This is typically
not what the user wants. These changes would show up in `git commit` and
would be annoying at best, or get accidentally commited to the
repository at worst.

 ## Implementation

Instead of rewriting the `wp-config.php`, this PR changes the default
behavior to defining the constants in a pre-loaded PHP file. This
triggers PHP warnings, but we're silencing them using a custom
error handler. As a result, Playground constants take precedence
over custom define() calls in a way that doesn't trigger warnings.

This is an easy and hacky way of implementing this. A better solution
would be a PHP.wasm-level patch to enable "warning-less constants" that
can't be redefined but the conflicting `define()` call fails silently.

 ## Testing instructions

Confirm the unit tests pass
@adamziel adamziel added this to the Boot Protocol milestone May 15, 2024
@adamziel adamziel mentioned this pull request May 15, 2024
1 task
@adamziel
Copy link
Collaborator Author

The test failure is intermittent, let's merge

@adamziel adamziel merged commit a113920 into trunk May 15, 2024
4 of 5 checks passed
@adamziel adamziel deleted the preload-sunrise-php branch May 15, 2024 15:37
adamziel added a commit that referenced this pull request May 15, 2024
Prevents creating a `wp-config.php` file in WordPress document root. Instead, creates it one level higher as WordPress falls back to loading it from there.

Related to #1398. Similar to #1382 and #1401.

## Testing instructions

Run `bun packages/playground/cli/src/cli.ts server --login` and confirm it loads an installed WordPress.
adamziel added a commit that referenced this pull request May 15, 2024
Prevents creating a `wp-config.php` file in WordPress document root.
Instead, creates it one level higher as WordPress falls back to loading
it from there.

Related to
#1398. Similar
to #1382 and
#1401.

## Testing instructions

Run `bun packages/playground/cli/src/cli.ts server --login` and confirm
it loads an installed WordPress.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant