Skip to content

wasmerio/wcgi-wordpress-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WCGI WordPress Demo

This demo contains a WordPress website that can be run as a WCGI program by Wasmer.

Getting Started

To run this demo, you will need to install the Wasmer toolchain.

$ curl https://get.wasmer.io -sSfL | sh -s "v3.2.0-beta.2"

(version v3.2.0-beta.2 or more recent is required).

You can use wasmer run-unstable to run the website locally.

$ wasmer run-unstable . --mapdir=/db:db
INFO run: wasmer_wasix::runners::wcgi::runner: Starting the server address=127.0.0.1:8000 command_name="php"

Hacks / Adaptations

This codebase does the following hacks to Wordpress to have it full running:

  • Replace exit; or die; to exit(0); or die(0);: they are equivalent, but they don't work without the arguments on the php-cgi WASI counterpart
  • Call echo " "; before exit as any header sent before an exit will be skipped if no body is being written

Replaced wp-includes/class-wp-http.php, wp-includes/class-wp-http-streams.php, wp-includes/class-wp-http-curl.php to return WP_Error;

public function request( $url, $args = array() ) {
  if (defined("IS_WASI") && IS_WASI) {
    return new WP_Error( 'http_request_failed', __( "The HTTP request to $url failed." ) );
  }
  // ...
}

Replaced _maybe_update_plugins in wp-includes/update.php:

function _maybe_update_plugins() {
  if (defined("IS_WASI") && IS_WASI) {
    return [
      "last_checked" => time() - 5,
    ];
  }
  // ...
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE_APACHE.md
MIT
LICENSE_MIT.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published