New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add base RemoteSpecsEngine class, add logging for errors in all remote specs #44775
Conversation
Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test Results SummaryCommit SHA: 31d6e42
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
@@ -20,16 +20,13 @@ class EvaluateExtension { | |||
* @param object $extension The extension to evaluate. | |||
* @return object The evaluated extension. | |||
*/ | |||
public static function evaluate( $extension ) { | |||
private static function evaluate( $extension ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set to private since this can now produce fatal errors.
use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\EvaluateSuggestion; | ||
use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\PaymentGatewaySuggestionsDataSourcePoller as PaymentGatewaySuggestionsDataSourcePoller; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested well! 👍 Just left a question about the transient.
Select I'm just starting my business and continue
Sorry, I found that my previous PR test instructions were not accurate. I think to display the Square as shown in the screenshot, we need to select "I'm already selling"
and "I'm selling both online and offline."
(or I'm selling offline.
)
Additionally, if testing via the live branch, the plugin folder name would need to be changed from /srv/htdocs/wp-content/plugins/wc_beta_tester_live_branch_*
to /srv/htdocs/wp-content/plugins/woocommerce
for WCPay to appear in the set up payment task.
PaymentGatewaySuggestionsDataSourcePoller::get_instance()->set_specs_transient( array( $locale => DefaultPaymentGateways::get_all() ), 3 * HOUR_IN_SECONDS ); | ||
|
||
return EvaluateSuggestion::evaluate_specs( DefaultPaymentGateways::get_all() )['suggestions']; | ||
$specs_to_return = EvaluateSuggestion::evaluate_specs( DefaultPaymentGateways::get_all() )['suggestions']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't return the specs here, when suggestions are empty and errors exist, we will set the transient to $specs
in line 53. Is this an intentional change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching it! It's not intentional, the logic went over my head 😵
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review, @chihsuan!
I've updated the instructions to reflect actual use cases! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for refactoring!
Optional comment: since it's now extending a base class, I wonder if it would make sense to take it one step further and extract the common logic in get_suggestions?
Thanks, @rjchow!
I've been thinking that too! However, the get_suggestions is not identical for all remote spec engines (only 3 works similarly). I still think there can be a common denominator, but will require a small refactor, and out of the scope of this PR. |
Changes proposed in this Pull Request:
Closes #44248.
This PR:
evaluate
to private to ensure it's not called from outside since it's possible to fatalHow to test the changes in this Pull Request:
Test remote specs still work as expected
> 8.1
wp transient delete --all
Display suggestions within WooCommerce
is checked/wp-admin/admin.php?page=wc-admin&path=/setup-wizard
I'm already selling
andNo, I'm selling offline.
Australia — Australian Capital Territory
and continueTools > WCA Test Helper > Tools
, Runwc_admin_daily
job/wp-admin/admin.php?page=wc-admin&task=payments
Test logging
wp-config.php
, ensureWP_ENVIRONMENT_TYPE
is set tolocal
ordevelopment
RuleEvaluator.php
and addin_array( '', '', true );
to simulate errors in PHP 8+.WooCommerce > Status > Logs > Settings
(screenshot)Tools > WCA Test Helper > Tools > Run wc_admin_daily job
WooCommerce > Status > Logs
and look for logs namedremotespecsengine-errors
Changelog entry
Significance
Type
Message
Comment