Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pr-php-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- examples/composer
- examples/db-client
- examples/db-client-mysql
- examples/db-client-mysql57
- examples/php-extensions
- examples/xdebug
lando-version:
Expand Down
12 changes: 6 additions & 6 deletions builders/php.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ const detectDatabaseClient = (options, debug = () => {}) => {

for (const service of Object.values(services)) {
const type = service?.type || '';
// Match mysql:X or recipe-mysql:X (e.g., backdrop-mysql:8.0, drupal-mysql:8.4)
const mysqlMatch = type.match(/(?:^|-)mysql:(\d+(?:\.\d+)?)/);
if (mysqlMatch && !mysqlVersion) mysqlVersion = mysqlMatch[1];
// Match mariadb:X or recipe-mariadb:X (e.g., backdrop-mariadb:10.6, drupal-mariadb:11.4)
const mariaMatch = type.match(/(?:^|-)mariadb:(\d+(?:\.\d+)?)/);
if (mariaMatch && !mariaVersion) mariaVersion = mariaMatch[1];
// Match mysql or mysql:X, including recipe prefixes (e.g., backdrop-mysql, backdrop-mysql:8.0)
const mysqlMatch = type.match(/(?:^|-)mysql(?::(\d+(?:\.\d+)?))?(?:$|[^a-z])/);
if (mysqlMatch && !mysqlVersion) mysqlVersion = mysqlMatch[1] || '8.0';
// Match mariadb or mariadb:X, including recipe prefixes (e.g., backdrop-mariadb:10.6)
const mariaMatch = type.match(/(?:^|-)mariadb(?::(\d+(?:\.\d+)?))?(?:$|[^a-z])/);
if (mariaMatch && !mariaVersion) mariaVersion = mariaMatch[1] || '11.4';
}

if (mariaVersion && mysqlVersion) {
Expand Down
22 changes: 22 additions & 0 deletions examples/db-client-mysql57/.lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: lando-php-db-client-mysql57

services:
# Test MySQL 5.7 auto-detection with an appserver (not cli)
# Reproduces SSL errors when mysql commands run via services.run or events
appserver:
type: php:8.4
via: apache
run:
- mysql -h database -u testuser -ptestpass testdb -e "SELECT 1 AS connection_test"
run_as_root:
- mysql -h database -u root testdb -e "SELECT 1 AS root_connection_test"

database:
type: mysql:5.7
creds:
user: testuser
password: testpass
database: testdb

plugins:
"@lando/php": ../..
46 changes: 46 additions & 0 deletions examples/db-client-mysql57/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Database Client MySQL 5.7 SSL Test

This example tests that `db_client: auto` correctly handles MySQL 5.7 when using
an Apache appserver with mysql commands in `services.run` (matching a real-world
recipe scenario where SSL errors occur).

## Start up tests

Run the following commands to get up and running with this example.

```bash
# Should start up successfully with mysql run commands completing without SSL errors
lando poweroff
lando start
```

## Verification commands

Run the following commands to validate things are rolling as they should.

```bash
# Auto-detection installs MySQL client (not MariaDB)
lando exec appserver -- mysql --version | grep -q "mysql"
lando exec appserver -- mysql --version | grep -qi "Ver 8.0"
lando exec appserver -- mysql --version | grep -qiv "MariaDB"
```

```bash
# MySQL client can connect to MySQL 5.7 database without SSL errors
lando exec appserver -- mysql -h database -u testuser -ptestpass testdb -e "SELECT 1"
```

```bash
# mysqldump works against MySQL 5.7 without SSL errors
lando exec appserver -- mysqldump -h database -u testuser -ptestpass testdb --no-data > /dev/null
```

## Destroy tests

Run the following commands to trash this app like nothing ever happened.

```bash
# Should be destroyed with success
lando destroy -y
lando poweroff
```
5 changes: 5 additions & 0 deletions scripts/mysql-client-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ mkdir -p /etc/mysql/conf.d
cat > /etc/mysql/conf.d/lando.cnf << 'MYCNF'
[client]
default-character-set=utf8mb4
# Use PREFERRED so SSL is used when available but self-signed certs
# (e.g. MySQL 5.7 defaults) don't cause verification failures.
# Preserves SSL for servers that support it
ssl-mode=PREFERRED

[mysqldump]
# Prevent column-statistics errors with newer mysqldump
skip-column-statistics
ssl-mode=PREFERRED
MYCNF

if ! mysql --version 2>/dev/null; then
Expand Down
Loading