What if WordPress could be launched as a stateful application? #16
EdmondDantes
started this conversation in
General
Replies: 1 comment 2 replies
-
|
How about enhance the functions to terminate the current coroutine instead of the whole process, except when it's the root coroutine. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Experiments with WordPress
After implementing memory model 2, which provides isolation for
GLOBALSandSUPERGLOBALS, it became interesting to see whether this level of isolation would be sufficient for WordPress to function correctly.A quick analysis of the WordPress code confirmed that this isolation is indeed enough for it to run safely inside coroutines.
But simply running WordPress with coroutines would be too plain and unexciting.
A more ambitious idea
What if WordPress could be launched as a stateful application, where:
To achieve this, several steps were required:
Of course, launching WordPress as a fully stateful application requires additional work.
For example:
exit(), which effectively terminates the entire server;define()without considering that the code may be executed multiple times in a long-lived runtime.These behaviors are natural for classic stateless PHP, but they become problematic in a coroutine-driven, stateful architecture.
For demonstration purposes, I decided to focus only on the main page.
To avoid modifying WordPress itself, I prepared a ready-made database, did not install any additional plugins, and simply used the code from the repository as is.
As result: https://github.com/true-async/wordpress-test/blob/main/app/entrypoint.php
3–4 hours of work and you have the WordPress front page running inside a single process, over and over again.
The WordPress code itself remains essentially unchanged.
Do not assume this is a production-ready application.
The issues with
exitandredirecthave not been addressed. Therefore, whenever something triggersexit, the process returns a 503 error and this is expected behavior at this stage.Beta Was this translation helpful? Give feedback.
All reactions