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

Fix status check in PackageProxyContainer #49

Merged
merged 5 commits into from
Aug 27, 2024

Conversation

gmazzap
Copy link
Contributor

@gmazzap gmazzap commented May 24, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Bug fix.

What is the current behavior? (You can also link to an open issue here)

A connected package's services can not be accessed if the package is "built"

What is the new behavior (if this is a feature change)?

A connected package's services can be accessed if the package is "built".

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No.

Other information:

The implementation of Package::connect() predates the implementation of Package::built().

Before Package::built() was introduced in 1.7.0 it was only safe to access a Package's container after having called Package::boot().

Now, we can do $package->build()->container() without issues.

The implementation of PackageProxyContainer was not updated when we introduced Package::built(), so we can still not access services from connected packages if they are not booted.

This means using built() early and boot() later, which is the reason why we introduced built() in the first place is "dangerous" because if someone connects a built package and tries to access its services they will get an exception.

I committed a test to master that tests there the bug, and this test is merged back into this branch to prove this is now solved.

gmazzap added 3 commits May 24, 2024 12:20
When status is STATUS_INITIALIZED or above, it is possible to access the
package container.

Right now, PackageProxyContainer only access the container after booting
which is wrong and make usage of build() "dangerous".
@gmazzap gmazzap requested review from Chrico and tfrommen May 24, 2024 10:38
Copy link

codecov bot commented May 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.42%. Comparing base (bd65297) to head (5c6b990).
Report is 6 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #49      +/-   ##
============================================
- Coverage     98.93%   98.42%   -0.52%     
- Complexity      234      238       +4     
============================================
  Files            10       10              
  Lines           566      570       +4     
============================================
+ Hits            560      561       +1     
- Misses            6        9       +3     
Flag Coverage Δ
unittests 98.42% <100.00%> (-0.52%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gmazzap gmazzap mentioned this pull request May 24, 2024
3 tasks
@gmazzap gmazzap changed the title Fix/status check in package proxy container Fix status check in PackageProxyContainer May 24, 2024
Copy link
Member

@tfrommen tfrommen left a comment

Choose a reason for hiding this comment

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

Left a comment, but code-wise, this is good to go.

src/Container/PackageProxyContainer.php Show resolved Hide resolved
gmazzap added a commit that referenced this pull request May 27, 2024
@gmazzap gmazzap merged commit d4ea195 into master Aug 27, 2024
63 of 64 checks passed
@gmazzap gmazzap deleted the fix/status-check-in-package-proxy-container branch August 27, 2024 07:55
gmazzap added a commit that referenced this pull request Aug 27, 2024
See #47

**To be merged after #49**

- Added the generic, statically-named `ACTION_MODULARITY_INIT` action hook
- Refactor hooks triggering, using a map between statuses ans actions, introducing two new statuses: `STATUS_INIT` and `SATUS_DONE`(which replaces the now deprecated `STATUS_BOOTED`)
- Deprecate `STATUS_MODULES_ADDED` (`STATUS_BOOTING` was already an alias)
- Refactor hook triggering for failed connection, moving it to a separate method. Behavior change: connecting an alreayd connected package still fires a failed action hook but does not throw anymore.
- Do not use `PackageProxyContainer` when the package to connect is initialized, considering its container is already available
- Allow for multiple consecutive calls to `Package::boot()` and `Package::build()` avoiding throwing unnecessary exceptions
- Add extensive inline documentation to explain the different parts of the bootstrapping flow
- Add a large amount of tests to cover both existing but untested scenarios as well as the new/updated behaviors
- Rework the "Package" and "Application flow" documentation chapters to make them more easily consumable, better account for latest additions (not limited to the changes in this commit).
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.

3 participants