Skip to content

Introduce wp db users command for user management#303

Open
Copilot wants to merge 9 commits intomainfrom
copilot/add-wp-db-users-command
Open

Introduce wp db users command for user management#303
Copilot wants to merge 9 commits intomainfrom
copilot/add-wp-db-users-command

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Implementation Plan

  • Analyze repository structure and existing commands
  • Create DB_Users_Command class with create subcommand
  • Add MySQL user creation with privileges
  • Update db-command.php to register the new command
  • Update composer.json with new command
  • Create Behat feature tests
  • Fix code style and static analysis issues
  • Refactor to extend DB_Command for better code reuse
  • Improve SQL escaping to prevent injection vulnerabilities
  • Simplify code by removing unnecessary wrapper methods
  • Pass all linting, code style, and static analysis checks
  • Perform code review and security checks
  • Make esc_sql_ident protected in parent class and use static calls
  • Remove assert calls per review feedback
  • Enhance SQL string escaping to handle all MySQL special characters
  • Remove redundant @var annotations and use explicit type casting

Summary

Implemented wp db users create command that allows database administrators to easily create MySQL user accounts with optional privileges on the WordPress database. The implementation extends DB_Command for consistency, follows WP-CLI patterns, and includes comprehensive tests. Latest changes remove redundant @var annotations as requested, using explicit type casting with PHPStan ignore comments where needed for the conditional return type from the parent method.

Original prompt

This section details on the original issue you should resolve

<issue_title>Introduce wp db users</issue_title>
<issue_description>One of the most common tasks database administrators need to do is create user accounts for applications with full privileges to the application's database. I propose that we make that super simple in wp-cli using syntax similar to:

wp db users create --user --host --pass --privilegeduser --privilegedpass

Name of the database user to create.
Hosts that are permitted to connect as .
New user's password.
Database user with sufficient privileges to execute the command.
Privileged user's password.

This create command could be augmented by including list, delete, etc.</issue_description>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber I'm open to considering something like this, if someone would like to open a pull request for it.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
db-command.php 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy

This comment was marked as resolved.

Copilot AI and others added 3 commits January 19, 2026 13:15
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…utput.txt

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Copilot AI changed the title [WIP] Introduce wp db users command for user management Introduce wp db users command for user management Jan 19, 2026
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI requested a review from swissspidy March 11, 2026 17:16
@swissspidy swissspidy marked this pull request as ready for review March 11, 2026 21:40
@swissspidy swissspidy requested a review from a team as a code owner March 11, 2026 21:40
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.

Introduce wp db users

3 participants