Fix: Skip sandbox line in MariaDB dump files during import #294
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses a compatibility issue introduced by a recent MariaDB security fix (MDEV-21178), which causes
wp db import
to fail when importing SQL dump files generated by newer versions of MariaDB.Background
To mitigate a serious security vulnerability, MariaDB added a new "sandbox mode" that disables potentially dangerous client-side commands. This mode is triggered by placing the following directive at the top of a dump file:
/*!999999\ - enable the sandbox mode */
While this is safe for newer MariaDB clients, it breaks compatibility with:
This directive causes a SQL syntax error when encountered during import:
ERROR 1064 (42000): You have an error in your SQL syntax...
This problem is being tracked in #258.
Solution
This patch introduces a safeguard into the import() method: