Skip to content

Conversation

@afragen
Copy link
Contributor

@afragen afragen commented Jul 4, 2025

Refactor allows for calling of init() elsewhere. Yes, I have a WIP for making slug-did show as true for is_plugin_active(slug)

Signed-off-by: Andy Fragen <[email protected]>
*/
function run( $package_arr ) {
foreach ( $package_arr as $package ) {
function run() {
Copy link
Member

@costdev costdev Jul 5, 2025

Choose a reason for hiding this comment

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

Is there any scenario where we may want to call run( $packages ) like the function was before? Maybe for tests?

If so, it might be worth having:

function bootstrap() {
    add_action( 'init', __NAMESPACE__ . '\\init' );
}

function init() {
    run( get_packages() );
}

function get_packages() {
    ...
}

function run( $packages ) {
    ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that over complicating things? I'm having a difficult time understanding what you're trying to solve there.

Copy link
Member

@costdev costdev Jul 5, 2025

Choose a reason for hiding this comment

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

I was just noticing that previously, run() could be called from anywhere using any packages, which may come in useful at another point during runtime, and having get_packages() and run() being independent of each other may be best.

Since the PR removes the parameter from run(), they're now tightly coupled, to each other and to get_file_data(), which also makes testing a little more awkward and can't independently verify each function as well as before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would help make it more testable?

Copy link
Member

Choose a reason for hiding this comment

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

Keeping an open mind and looking at it again. If there was more going on, then there might be more benefit in separating them. But there's not much going on in run() that someone couldn't achieve in a few lines.

Since this was more a thought and not a blocker, I think it's fine to keep as-is and if we want to open stuff up later or there's an issue in testing, we can revisit it.

@afragen afragen requested a review from costdev July 5, 2025 18:38
@afragen afragen merged commit 6fcfc7f into fairpm:main Jul 5, 2025
46 checks passed
@afragen afragen deleted the updater-updates branch July 5, 2025 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants