Skip to content

[Blueprints v2] Add support for "enableMultisite" step #136

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

Merged
merged 5 commits into from
Aug 6, 2025

Conversation

JanJakes
Copy link
Member

@JanJakes JanJakes commented Aug 1, 2025

Resolves #130.
Closes #131.

@adamziel
Copy link
Collaborator

adamziel commented Aug 4, 2025

It's a promising start @JanJakes, thank you! We could use a couple of unit tests here – LMK if you'd like to connect on how to build them.

@JanJakes
Copy link
Member Author

JanJakes commented Aug 4, 2025

@adamziel I'm just finishing the tests; I will push it soon. Should the behavior be as close to the v1 behavior as possible? For example, when a site is already multisite, should it fail with This already is a multisite installation., as v1 does?

@JanJakes JanJakes force-pushed the enable-multisite-step branch 2 times, most recently from be5de5c to d82f567 Compare August 4, 2025 13:52
@adamziel
Copy link
Collaborator

adamziel commented Aug 4, 2025

Should the behavior be as close to the v1 behavior as possible? For example, when a site is already multisite, should it fail with This already is a multisite installation, as v1 does?

For now, yes. It may be cumbersome in some cases but could prevent catastrophic failures in other cases.

@JanJakes
Copy link
Member Author

JanJakes commented Aug 4, 2025

There are some interesting test failures in the macOS and Win builds, while Ubuntu passes. It's likely related to how some $_SERVER variables are set by WP CLI. I'll check it out further.

@JanJakes JanJakes force-pushed the enable-multisite-step branch from 99bf6db to 1de041a Compare August 5, 2025 07:02
@JanJakes JanJakes requested a review from adamziel August 5, 2025 11:20
@JanJakes JanJakes marked this pull request as ready for review August 5, 2025 11:20
@JanJakes
Copy link
Member Author

JanJakes commented Aug 5, 2025

@adamziel This should be ready now. The test failures seem to be unrelated/flaky.

@adamziel
Copy link
Collaborator

adamziel commented Aug 5, 2025

Nitpick: Spaces vs tabs – the comments are visually less indented than the lines they refer to

CleanShot 2025-08-05 at 18 03 09@2x

Copy link
Collaborator

@adamziel adamziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good work @JanJakes! My only notes are about code formatting – feel free to merge once that's sorted out!

@JanJakes
Copy link
Member Author

JanJakes commented Aug 6, 2025

@adamziel There's one more thing that came to my mind: The populate_network() function calls wp_guess_url() and that relies on some $_SERVER variables like $_SERVER['HTTP_HOST'] and $_SERVER['REQUEST_URI'] being set. I think this affects which site URL the main site in the network will have set.

When using the CLI via php bin/blueprint.php exec, these may be required to be set based on the --site-url parameter. It seems that WP CLI does something like that, so we may mirror the behavior.

I will do some testing via the php bin/blueprint.php exec command and compare the behavior with WP CLI.

@JanJakes
Copy link
Member Author

JanJakes commented Aug 6, 2025

@adamziel OK, so particularly for the enable-multisite path, the $_SERVER values are not important as the populate_network path seems to be fetching the siteurl option for both the network and the initial blog.

That said, would it be safer to add something like the below to the subprocess script prefix? It's as per WP CLI.
Screenshot 2025-08-06 at 11 51 05

@adamziel
Copy link
Collaborator

adamziel commented Aug 6, 2025

@JanJakes would we be adding that just in case? Or did you run into an actual case where lacking those values is an issue? I'm worried about confusing WordPress into thinking we're running via a CGI SAPI when we're actually running as CLI.

@JanJakes
Copy link
Member Author

JanJakes commented Aug 6, 2025

@JanJakes would we be adding that just in case? Or did you run into an actual case where lacking those values is an issue? I'm worried about confusing WordPress into thinking we're running via a CGI SAPI when we're actually running as CLI.

@adam At this stage, it only seems to be a precaution. It doesn't affect the multisite step as it is, and likely not other steps we have now. What's a bit tricky, though, is that in many of the steps we call wp-load.php, and some of the WP functionality may rely on these constants. WP CLI sets these as per the --url parameter and we have a mandatory --site-url parameter that's actually passed to WP CLI for the WP installation but not set in this way in our steps.

PHP 7.2 and 7.3 tokenize "<?php" string without any additional tokens
as T_INLINE_HTML instead of T_OPEN_TAG. Let's just fix the tests.
@JanJakes JanJakes force-pushed the enable-multisite-step branch from 08df555 to 141e1bd Compare August 6, 2025 11:20
@JanJakes JanJakes merged commit 4218487 into trunk Aug 6, 2025
77 of 84 checks passed
@JanJakes JanJakes deleted the enable-multisite-step branch August 6, 2025 12:38
@JanJakes
Copy link
Member Author

JanJakes commented Aug 7, 2025

@adam At this stage, it only seems to be a precaution. It doesn't affect the multisite step as it is, and likely not other steps we have now. What's a bit tricky, though, is that in many of the steps we call wp-load.php, and some of the WP functionality may rely on these constants. WP CLI sets these as per the --url parameter and we have a mandatory --site-url parameter that's actually passed to WP CLI for the WP installation but not set in this way in our steps.

@adamziel Just for the record, I didn't add this. If you'd prefer to do it, I can create a new PR.

@adamziel
Copy link
Collaborator

adamziel commented Aug 7, 2025

I'm on the fence. I looked up why WP-CLI does that but the decisions are not well documented. It seems like that's just their way of supporting the --blog and --url CLI options, not something inherently required by WP:

Lacking these attributes didn't give me any troubles yet. At the same time, when I had them set, I occasionally saw WordPress trying to send the Location: header from a CLI script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Blueprints v2] Support enableMultisite step
2 participants