Skip to content

Make filter callbacks private#313

Merged
swissspidy merged 1 commit intomainfrom
fix/public-methods
Mar 4, 2026
Merged

Make filter callbacks private#313
swissspidy merged 1 commit intomainfrom
fix/public-methods

Conversation

@swissspidy
Copy link
Member

This is a follow-up to #303

Avoids accidentally adding a wp core capture_version_check_error command 😅

@swissspidy swissspidy added this to the 2.1.24 milestone Mar 4, 2026
@swissspidy swissspidy requested a review from a team as a code owner March 4, 2026 10:34
Copilot AI review requested due to automatic review settings March 4, 2026 10:34
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@github-actions github-actions bot added command:core-version Related to 'core version' command scope:distribution Related to distribution labels Mar 4, 2026
@gemini-code-assist

This comment was marked as resolved.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR is a follow-up to #303 that prevents Core_Command’s HTTP hook callbacks from being accidentally exposed as WP-CLI subcommands by making the callback methods private and registering them via closures.

Changes:

  • Register pre_http_request and http_api_debug hooks using closures instead of [$this, 'method'].
  • Change capture_version_check_error() and capture_version_check_error_from_response() visibility from public to private.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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 successfully refactors the get_updates method to use closures for pre_http_request and http_api_debug hooks. This change correctly allows the capture_version_check_error and capture_version_check_error_from_response methods to be declared as private, improving encapsulation and preventing their accidental exposure as commands. The implementation correctly handles the addition and removal of these hooks using the closure variables, ensuring proper cleanup. This is a good improvement for the codebase's maintainability and adherence to object-oriented principles.

@swissspidy swissspidy merged commit 6e163fd into main Mar 4, 2026
67 checks passed
@swissspidy swissspidy deleted the fix/public-methods branch March 4, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:core-version Related to 'core version' command scope:distribution Related to distribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants