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

WordPress crashes when connecting to MySQL #237

Open
adamziel opened this issue Apr 17, 2024 · 5 comments
Open

WordPress crashes when connecting to MySQL #237

adamziel opened this issue Apr 17, 2024 · 5 comments
Labels
Bug Something isn't working VS Code wp-now

Comments

@adamziel
Copy link
Collaborator

adamziel commented Apr 17, 2024

@zzap's VS Code extension crashed when running a MySQL-connected WordPress. We've narrowed it down to the reproduction case below. It's probably also present in wp-now and Studio – CC @sejas @kozer @wojtekn. It's most likely Asyncify-related, here's a doc page on how to debug and fix those: https://wordpress.github.io/wordpress-playground/architecture/wasm-asyncify Even posting a stack trace here would go a long way.

<?php

$servername = "127.0.0.1";
$username = "username";
$password = "password";
$dbname = "myDb";

// Initialize mysqli instance
$mysqli = mysqli_init();

if (!$mysqli) {
    die('mysqli_init failed');
}

// Establish connection
if (!mysqli_real_connect($mysqli, $servername, $username, $password, $dbname)) {
    die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
echo 'Success... ' . $mysqli->host_info . "\n";

$mysqli->close();
@adamziel adamziel added Bug Something isn't working wp-now VS Code labels Apr 17, 2024
@adamziel adamziel added this to the Zero Crashes – Tools milestone Apr 17, 2024
@zzap
Copy link
Member

zzap commented Apr 17, 2024

Let me know if there's any additional info you need from me.

@wojtekn
Copy link
Collaborator

wojtekn commented Apr 17, 2024

@adamziel I've just tried that on my local in Studio and I couldn't reproduce it.

  1. Start database server:
docker run --name studio-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d circleci/mariadb:10.3.23
  1. Add and start site in Studio
  2. Open wp-config.php
  3. Replace the content with the following:
<?php
$servername = "127.0.0.1";
$username = "root";
$password = "my-secret-pw";
$dbname = "circle_test";

// Initialize mysqli instance
$mysqli = mysqli_init();

if (!$mysqli) {
	die('mysqli_init failed');
}

// Establish connection
if (!mysqli_real_connect($mysqli, $servername, $username, $password, $dbname)) {
	die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
echo 'Success... ' . $mysqli->host_info . "\n";

$mysqli->close();
die;;
  1. Refresh page and notice:
Success... 127.0.0.1 via TCP/IP

@adamziel
Copy link
Collaborator Author

Interesting! @zzap, what's your mysql version? Also @wojtekn would you also try vs code?

@zzap
Copy link
Member

zzap commented Apr 18, 2024

mysql Ver 8.0.36-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

@wojtekn
Copy link
Collaborator

wojtekn commented Apr 26, 2024

@adamziel it works well for me in Visual Studio Code, too:

Screenshot 2024-04-26 at 12 11 01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working VS Code wp-now
Projects
Status: No status
Development

No branches or pull requests

3 participants