Skip to content

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented Jul 4, 2025

For WOOMOB-760

Just one review is required.

Description

Refactors the PluginsService.waitForPluginInStorage method to use the stable plugin file path identifier instead of the potentially changing plugin display name. This change improves reliability when querying for plugins in storage by using the plugin's file path (e.g., "woocommerce/woocommerce.php") which is less likely to change compared to display names.

The plugin file path is the stable identifier used by WordPress internally and returned by the WooCommerce REST API /wp-json/wc/v3/system_status endpoint in the active_plugins.plugin field.

Steps to reproduce

  • Run POS to ensure plugin detection in the eligibility check still works as expected

Testing information

  • @jaclync tests that the correct ineligible UI is shown when the store is WC version 10.0+ and feature switch disabled

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@jaclync jaclync added type: task An internally driven task. feature: POS labels Jul 4, 2025
@jaclync jaclync added this to the 22.8 milestone Jul 4, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jul 4, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr15871-c6488a1
Version22.7
Bundle IDcom.automattic.alpha.woocommerce
Commitc6488a1
Installation URL51phob74jfc0g
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@jaclync jaclync requested review from iamgabrielma and staskus July 4, 2025 17:30
@iamgabrielma iamgabrielma self-assigned this Jul 7, 2025
Copy link
Contributor

@iamgabrielma iamgabrielma left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

/// - Parameters:
/// - siteID: The site ID to search for the plugin.
/// - plugin: The plugin's file path (e.g., "woocommerce/woocommerce.php" for WooCommerce).
/// - isActive: Whether to wait for the plugin to be active or inactive.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think the usage of "wait for" bit here could be miss leading, since we're not waiting but matching the current plugin state in storage. wdyt?

Suggested change
/// - isActive: Whether to wait for the plugin to be active or inactive.
/// - isActive: Whether to match a plugin that is currently active or inactive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this inaccurate comment, updated the comment in 5f83b82.

public func waitForPluginInStorage(siteID: Int64, pluginName: String, isActive: Bool) async -> SystemPlugin {
let predicate = \StorageSystemPlugin.siteID == siteID && \StorageSystemPlugin.name == pluginName && \StorageSystemPlugin.active == isActive
let nameDescriptor = NSSortDescriptor(keyPath: \StorageSystemPlugin.name, ascending: true)
public func waitForPluginInStorage(siteID: Int64, plugin: String, isActive: Bool) async -> SystemPlugin {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: How about updating the signature to pluginPath, or similar? Just to be more explicit about what we need to pass in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, renamed in c6488a1.

@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is assigned to the milestone 22.8. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@jaclync jaclync enabled auto-merge July 10, 2025 18:45
@jaclync jaclync merged commit 8c09e5f into trunk Jul 10, 2025
13 checks passed
@jaclync jaclync deleted the feat/WOOMOB-760-fetch-plugin-by-slug branch July 10, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: POS type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants