-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
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".
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
PackageProxyContainer
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.
Left a comment, but code-wise, this is good to go.
And fail a couple of edge-cases bugs discovered via new tests
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).
Please check if the PR fulfills these requirements
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 ofPackage::built()
.Before
Package::built()
was introduced in 1.7.0 it was only safe to access a Package's container after having calledPackage::boot()
.Now, we can do
$package->build()->container()
without issues.The implementation of
PackageProxyContainer
was not updated when we introducedPackage::built()
, so we can still not access services from connected packages if they are not booted.This means using
built()
early andboot()
later, which is the reason why we introducedbuilt()
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.