Skip to content

Bail early when check/dump commands are missing - #339

Merged
swissspidy merged 1 commit into
mainfrom
fix/missing-db-binaries
Jul 30, 2026
Merged

Bail early when check/dump commands are missing#339
swissspidy merged 1 commit into
mainfrom
fix/missing-db-binaries

Conversation

@swissspidy

@swissspidy swissspidy commented Jul 30, 2026

Copy link
Copy Markdown
Member

Bails early with an error in db check, db optimize, db repair, and db export when get_sql_check_command() or get_sql_dump_command() returns an empty string because the binaries are missing.

Follow-up to wp-cli/wp-cli#6363.

Summary by CodeRabbit

  • Bug Fixes
    • Improved database check, optimization, repair, and export commands by validating that the required database utilities are available before execution.
    • Added clearer errors when required database command-line tools cannot be found.
    • Updated debug output handling to accurately reflect the executable paths used.

@swissspidy
swissspidy requested a review from a team as a code owner July 30, 2026 07:07
@github-actions github-actions Bot added command:db-check Related to 'db check' command command:db-export Related to 'db export' command command:db-optimize Related to 'db optimize' command command:db-repair Related to 'db repair' command scope:testing Related to testing labels Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Database check, optimize, repair, and export now validate resolved MySQL or MariaDB client binaries and invoke them directly. Acceptance tests update debug-output patterns to match direct executable paths.

Changes

Database client command resolution

Layer / File(s) Summary
Resolve and use client binaries
src/DB_Command.php
check, optimize, repair, and export validate resolved client binaries, report missing commands, and remove the /usr/bin/env wrapper.
Update debug command assertions
features/db-check.feature, features/db-export.feature
Debug scenarios match direct paths ending in mysqlcheck, mariadb-check, mysqldump, or mariadb-dump, including --no-defaults where applicable.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: bug, command:db

Suggested reviewers: schlessera, copilot, brianhenryie

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: exiting early when required check/dump binaries are missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/missing-db-binaries

Comment @coderabbitai help to get the list of available commands.

@swissspidy swissspidy added this to the 2.1.7 milestone Jul 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@features/db-check.feature`:
- Around line 157-163: Add Behat scenarios covering missing database-check
binaries: in features/db-check.feature lines 157-163, disable both mysqlcheck
and mariadb-check and assert the expected error. Also update
features/db-export.feature lines 143-149 with the corresponding scenario
disabling both dump binaries and asserting its expected error, following the
existing feature-test patterns.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 611f562b-5a0a-4687-a99c-355ee1304c80

📥 Commits

Reviewing files that changed from the base of the PR and between 81b2053 and 290516a.

📒 Files selected for processing (3)
  • features/db-check.feature
  • features/db-export.feature
  • src/DB_Command.php

Comment thread features/db-check.feature
Comment on lines +157 to +163
Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysqlcheck|mariadb-check) %s#

When I try `wp db check --debug`
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysqlcheck|mariadb-check) --no-defaults %s#
Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysqlcheck|mariadb-check) --no-defaults %s#

When I try `wp db check --no-defaults --debug`
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysqlcheck|mariadb-check) --no-defaults %s#
Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysqlcheck|mariadb-check) --no-defaults %s#

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Cover the new missing-binary error paths with Behat tests.

  • features/db-check.feature#L157-L163: add a scenario that disables both check binaries and asserts the expected error.
  • features/db-export.feature#L143-L149: add a scenario that disables both dump binaries and asserts the expected error.

As per coding guidelines, all new features and bug fixes must include Behat acceptance tests following existing feature-test patterns.

📍 Affects 2 files
  • features/db-check.feature#L157-L163 (this comment)
  • features/db-export.feature#L143-L149
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@features/db-check.feature` around lines 157 - 163, Add Behat scenarios
covering missing database-check binaries: in features/db-check.feature lines
157-163, disable both mysqlcheck and mariadb-check and assert the expected
error. Also update features/db-export.feature lines 143-149 with the
corresponding scenario disabling both dump binaries and asserting its expected
error, following the existing feature-test patterns.

Source: Coding guidelines

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/DB_Command.php 78.94% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy
swissspidy merged commit 04a9c25 into main Jul 30, 2026
67 checks passed
@swissspidy
swissspidy deleted the fix/missing-db-binaries branch July 30, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:db-check Related to 'db check' command command:db-export Related to 'db export' command command:db-optimize Related to 'db optimize' command command:db-repair Related to 'db repair' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant