Add database client auto-detection and version matching#212
Add database client auto-detection and version matching#212AaronFeledy merged 3 commits intomainfrom
Conversation
✅ Deploy Preview for lando-php ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
103116a to
a10de5c
Compare
|
Bugbot Autofix prepared fixes for 2 of the 2 bugs found in the latest run.
Or push these changes by commenting: Preview (a328c4043c)diff --git a/examples/db-client/.lando.yml b/examples/db-client/.lando.yml
--- a/examples/db-client/.lando.yml
+++ b/examples/db-client/.lando.yml
@@ -5,6 +5,7 @@
php-mysql84:
type: php:8.4
via: cli
+ db_client: mysql:8.4
mysql84:
type: mysql:8.4
diff --git a/scripts/mariadb-compat-install.sh b/scripts/mariadb-compat-install.sh
--- a/scripts/mariadb-compat-install.sh
+++ b/scripts/mariadb-compat-install.sh
@@ -9,7 +9,8 @@
# Create wrapper scripts for each mysql* command that maps to mariadb* equivalent
for cmd in mysql mysqldump mysqladmin mysqlcheck mysqlimport mysqlshow; do
- mariadb_cmd="mariadb${cmd#mysql}"
+ suffix="${cmd#mysql}"
+ mariadb_cmd="mariadb${suffix:+-}${suffix}"
if command -v "$mariadb_cmd" &> /dev/null; then
cat > "/usr/local/bin/$cmd" << EOF |
- Fix mariadb-compat-install.sh to use hyphens in command names (mariadb-dump instead of mariadbdump) - Add explicit db_client: mysql:8.4 to php-mysql84 test service to avoid auto-detection issues in multi-database environments
|
|
||
| [mysqldump] | ||
| # Prevent column-statistics errors with newer mysqldump | ||
| skip-column-statistics |
There was a problem hiding this comment.
MariaDB config breaks mysqldump with unknown option
High Severity
The [mysqldump] section containing skip-column-statistics is written to lando.cnf by the MariaDB compat script. MariaDB's mariadb-dump tool reads this section (for backward compatibility with [mysqldump]) but does not recognize skip-column-statistics, which is a MySQL 8.0-only option. This causes mariadb-dump (and the mysqldump wrapper) to fail with an "unknown variable" error, breaking mysqldump for all MariaDB setups — the exact scenario the PR aims to fix.
| COPY --from=mysql-client-80 /usr/bin/mysqladmin /usr/local/mysql-client/8.0/mysqladmin | ||
| COPY --from=mysql-client-84 /usr/bin/mysql /usr/local/mysql-client/8.4/mysql | ||
| COPY --from=mysql-client-84 /usr/bin/mysqldump /usr/local/mysql-client/8.4/mysqldump | ||
| COPY --from=mysql-client-84 /usr/bin/mysqladmin /usr/local/mysql-client/8.4/mysqladmin |
There was a problem hiding this comment.
Copied MySQL binaries lack required shared library dependencies
High Severity
The COPY --from=mysql-client-80 and COPY --from=mysql-client-84 directives copy only the MySQL client binaries without their required shared libraries (notably libmysqlclient.so.21/.so.22). These binaries are dynamically linked and will fail at runtime with "cannot open shared object file" errors. The PHP image only has MariaDB's libmariadb.so.3 (from mariadb-client), which is not ABI-compatible with MySQL's libmysqlclient. The mysql-client-install.sh warning fallback (mysql --version || echo ...) masks this during build, but the feature is completely non-functional at runtime.




Summary
Addresses MariaDB/MySQL client compatibility issues (lando/lando#3833) by detecting database services and installing matching clients for PHP 8.3+.
Changes
mysql:X.Xormariadb:X.Xand installs the appropriate clientdb_clientconfig option:auto(default),false, or explicittype:versionmysql→mariadbwrappers to avoid deprecation warningsdisable-ssl-verify-server-certandskip-column-statisticsVersion Mapping
Testing
See
examples/db-client/for test scenarios.Notes
Resolves #167,
Note
Medium Risk
Touches service build-step generation and Docker image contents; mistakes could break
mysql/mysqldumpavailability or alter client behavior for PHP 8.3+ containers.Overview
Adds database client auto-detection and installation for PHP 8.3+ services.
builders/php.jsnow introduces adb_clientoption (defaultauto) that scans app services formysql:*/mariadb:*and injects a root build step to install a matching client, withfalseto opt out or an explicittype:versionoverride.To support version-matched installs, PHP 8.3–8.5 image Dockerfiles now bundle pre-fetched MySQL 8.0 and 8.4 client binaries, and new helper scripts (
install-db-client.sh,mysql-client-install.sh,mariadb-compat-install.sh) switch clients via symlinks/wrappers and write compatibility config. Docs and examples are updated, and example fixtures bump image tags from-6to-7plus a newexamples/db-clientscenario.Written by Cursor Bugbot for commit 9b8084c. This will update automatically on new commits. Configure here.