Skip to content

Conversation

@manhphuc
Copy link

This PR improves the SQL dump binary resolution logic used by wp db export.

What this change does

  • Adds safe, explicit support for overriding the dump client via the
    WP_CLI_MYSQLDUMP environment variable.
  • Correctly handles both:
    • absolute executable paths
    • plain command names resolved through PATH
  • Ignores invalid or non-executable absolute paths to avoid breaking wp db export.
  • Falls back reliably to the appropriate default:
    • mariadb-dump on MariaDB installs
    • mysqldump otherwise

Why this is useful

Many Docker-based or custom server environments provide only one of the dump
clients, or store it in a non-standard location. This update makes wp db export
more predictable and easier to configure across those setups.

Testing

The change was tested in multiple scenarios:

  1. Valid absolute override
    WP_CLI_MYSQLDUMP=/usr/bin/mysqldump → export succeeds, correct binary selected.

  2. Invalid absolute override
    Non-existent file → ignored, fallback selected correctly.

  3. No environment override
    MariaDB installation correctly defaults to mariadb-dump.

All scenarios produced valid export files and correct debug messages.


Happy to adjust anything if needed. Thanks for reviewing!

@manhphuc manhphuc requested a review from a team as a code owner December 10, 2025 10:46
@gemini-code-assist
Copy link

Summary of Changes

Hello @manhphuc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the wp db export command's ability to locate and utilize the correct SQL dump binary. By introducing support for the WP_CLI_MYSQLDUMP environment variable, it provides users with greater control and flexibility in specifying their preferred dump client. The changes ensure robust handling of various path types, intelligent error recovery for invalid overrides, and reliable fallbacks, making the wp db export functionality more adaptable and predictable across diverse server environments, especially those with non-standard dump client configurations.

Highlights

  • Environment Variable Override: Introduces explicit support for overriding the SQL dump client via the WP_CLI_MYSQLDUMP environment variable, allowing users to specify a custom binary.
  • Robust Path Handling: The system now correctly handles both absolute executable paths and plain command names (resolved through PATH), providing flexibility in how the dump client is specified.
  • Intelligent Fallback: Invalid or non-executable absolute paths provided via the environment variable are gracefully ignored, and the system reliably falls back to mariadb-dump for MariaDB installations or mysqldump otherwise.
  • New Helper Function: A new function, get_mysql_dump_binary(), has been added to encapsulate the logic for determining the appropriate SQL dump binary, improving code organization and maintainability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 0% with 33 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/utils.php 0.00% 33 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable enhancement by adding robust support for overriding the SQL dump binary via the WP_CLI_MYSQLDUMP environment variable. The implementation is solid and covers the described scenarios well. My feedback focuses on improving the code's readability and enhancing the debug logging for better maintainability and user experience.

@manhphuc
Copy link
Author

Thanks for the suggestions! I've applied the refactor to use early returns and added a debug message for the non-executable absolute-path case. I also updated the final log line to clearly indicate that it’s using the default dump command. Let me know if you'd like any further adjustments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant