WordPress / wordpress-playground

Run WordPress in the browser via WebAssembly PHP
https://w.org/playground/
GNU General Public License v2.0
1.62k stars 249 forks source link

Support SQLite at the network connection level #1341

Open adamziel opened 5 months ago

adamziel commented 5 months ago

The SQLite database integration plugin is great when you use $wpdb, but plugin authors call mysqli_connect and new PDO() all the time.

Playground could intercept the outgoing network traffic and pretend to have a running MySQL server just like the stream wrappers support pretends to be an HTTPS server. It would implement the MySQL connection protocol and run all the transmitted queries against SQLite.

adamziel commented 4 months ago

Npm package implementing a MySQL server text protocol:

https://sidorares.github.io/node-mysql2/docs/documentation/mysql-server

The binary protocol isn't supported — is it required by PHP, or is the text protocol enough?

adamziel commented 4 months ago

Another idea: this MySQL "fake server" written in Rust could perhaps be compiled to WASM and used to pipe the queries back to the SQLite plugin. Or, if that's difficult to instrument, maybe it could be ported to TypeScript or even PHP?

https://github.com/jonhoo/msql-srv