You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8b15530
Browse filesBrowse the repository at this point in the historyBrowse files
Drop the SQL mode probe; run wp db query under server modes
`wp db query`, `wp db import` and the internal `run_query()` adapted the
session SQL mode to match WordPress. Building that adaptation opened a
second MySQL connection to read `@@SESSION.sql_mode`, and that probe was
built without the caller's connection options (`--host`, `--defaults`,
SSL/TLS, sockets), so it connected to the wrong server and aborted the
command before the real query ran. This is the root cause of #311, and of
#237, #278, #288 and #218.
- `wp db query` no longer adapts the SQL mode. It runs under the server's
own modes, like the `mysql` client, so connection options are honored.
This is a behavior change and targets the next major version.
- `wp db import` and `run_query()` keep WordPress compatibility, but apply
it via the client's `--init-command` on the same connection rather than a
probe. This also covers dumps streamed from STDIN (#171).
- Add a `--skip-sql-mode-compat` flag to `wp db import` to opt out.
The incompatible modes are stripped from `@@SESSION.sql_mode` in a single
statement, with each mode comma-wrapped so a substring like `ANSI` cannot
corrupt `ANSI_QUOTES`.
* : When using an SQL file, do not include speed optimization such as disabling auto-commit and key checks.
900
897
*
898
+
* [--skip-sql-mode-compat]
899
+
* : Do not adapt the session SQL mode for WordPress compatibility. By default, `wp db import` strips the SQL modes that WordPress Core disables (such as `STRICT_TRANS_TABLES` and `NO_ZERO_DATE`) so that dumps containing legacy values like `0000-00-00` import cleanly. Pass this flag to import under the server's own SQL modes instead.
900
+
*
901
901
* [--defaults]
902
902
* : Loads the environment's MySQL option files. Default behavior is to skip loading them to avoid failures due to misconfiguration.
903
903
*
@@ -928,6 +928,14 @@ public function import( $args, $assoc_args ) {
928
928
self::get_mysql_args( $assoc_args )
929
929
);
930
930
931
+
// Adapt the session SQL mode to be WordPress-compatible via --init-command,
932
+
// so it runs on connect before any SQL is read. This covers both file and
933
+
// STDIN imports, and needs no separate probe connection.
0 commit comments