Skip to content
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

Consistent usage of ContainerAware #2761

Merged
merged 17 commits into from
Jan 14, 2025
Merged

Consistent usage of ContainerAware #2761

merged 17 commits into from
Jan 14, 2025

Conversation

mikkamp
Copy link
Contributor

@mikkamp mikkamp commented Jan 10, 2025

Changes proposed in this Pull Request:

This PR standardizes the usage of ContainerAware across various classes. This makes it more consistent with what was decided in issue #563

I've also fixed some of the AdminConditional loading to ensure that some of the classes are not loaded on the frontend.
I was considering adding is_admin() && ! wp_doing_ajax() to the AdminConditional. But for now I left it since there could be a possibility that coupon bulk editing or activating plugin is done through an ajax request, which might silently break some of the actions. So for now I've left it as we'd need to do some extensive testing to make sure we aren't missing any ajax requests.

When looking at a front end request we can thus see a small decrease in the time spent resolving classes.

Before:
image

After:
image

PR #2758 takes that a step further. We can still decrease it even more, but considering that it needs specific testing for each change, I think it's better to improve that through multiple separate PR's.

Closes #563

Detailed test instructions:

  1. Test some basic REST API requests while going through onboarding
  2. As well as going through some of the extension pages
  3. Confirm that none of the requests fail

Changelog entry

  • Tweak - Consistent usage of ContainerAware.

@mikkamp mikkamp self-assigned this Jan 10, 2025
@github-actions github-actions bot added the changelog: tweak Small change, that isn't actually very important. label Jan 10, 2025
Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 58.82353% with 7 lines in your changes missing coverage. Please review.

Project coverage is 67.0%. Comparing base (c8c1efa) to head (763cde0).
Report is 25 commits behind head on develop.

Files with missing lines Patch % Lines
...ernal/DependencyManagement/CoreServiceProvider.php 0.0% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             develop   #2761     +/-   ##
===========================================
- Coverage       67.0%   67.0%   -0.1%     
+ Complexity      4692    4684      -8     
===========================================
  Files            480     480             
  Lines          19601   19581     -20     
===========================================
- Hits           13141   13116     -25     
- Misses          6460    6465      +5     
Flag Coverage Δ
php-unit-tests 67.0% <58.8%> (-0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/API/Google/Middleware.php 95.7% <ø> (-<0.1%) ⬇️
src/API/Google/Settings.php 6.3% <ø> (-1.2%) ⬇️
src/API/Site/Controllers/Ads/ReportsController.php 93.8% <ø> (ø)
src/API/Site/Controllers/BaseReportsController.php 75.9% <ø> (-0.8%) ⬇️
...e/Controllers/MerchantCenter/ReportsController.php 91.8% <ø> (ø)
...trollers/MerchantCenter/ShippingTimeController.php 92.9% <ø> (-0.1%) ⬇️
src/API/Site/RESTControllers.php 100.0% <ø> (+14.3%) ⬆️
src/Admin/BulkEdit/BulkEditInitializer.php 66.7% <ø> (ø)
src/Ads/AccountService.php 98.7% <100.0%> (-<0.1%) ⬇️
src/ConnectionTest.php 0.0% <ø> (ø)
... and 5 more

... and 1 file with indirect coverage changes

@mikkamp mikkamp requested a review from a team January 10, 2025 17:59
Copy link
Member

@ianlin ianlin left a comment

Choose a reason for hiding this comment

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

Thanks for refactoring to use ContainerAware consistently and also add / fix the conditional loading for some classes . I have gone through the onboarding and tested all the pages within the extension, the requests were successful as normal.

@mikkamp mikkamp merged commit 733b466 into develop Jan 14, 2025
12 checks passed
@mikkamp mikkamp deleted the tweak/use-container-aware branch January 14, 2025 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: tweak Small change, that isn't actually very important.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor to prefer direct dependencies but allow ContainerAwareness
2 participants