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 issue where 'shareInstances' resolve but fail to propagate #201

Merged
merged 2 commits into from
Mar 28, 2022

Conversation

lkrms
Copy link
Contributor

@lkrms lkrms commented Mar 17, 2022

See issue #200.

The first commit updates the relevant tests to demonstrate the issue encountered in my own testing.

And from the second commit message:

Because $share is passed by reference to matchParam(), and matchParam() removes matching objects from its $search array, instances may be removed from $share before it is passed to expand() or create(). Depending on the order of constructor parameters and the relative placement of shareInstances dependencies in the object tree, this may result in multiple instances of these dependencies being created.

Fixed by passing a copy of the $share array to matchParam().

…opagate

Because `$share` is passed by reference to `matchParam()`, and
`matchParam()` removes matching objects from its `$search` array,
instances may be removed from `$share` before it is passed to `expand()`
or `create()`. Depending on the order of constructor parameters and the
relative placement of `shareInstances` dependencies in the object tree,
this may result in multiple instances of these dependencies being
created.

Fixed by passing a copy of the `$share` array to `matchParam()`.
@TRPB TRPB merged commit e04c98d into Level-2:master Mar 28, 2022
@lkrms lkrms deleted the fix-share-instances branch August 21, 2022 15:42
cseufert added a commit to moddengine/Dice that referenced this pull request Oct 3, 2022
* Support nullable class type hints (Level-2#182)

* Remove PHP 8 deprecation warning

* Level-2#195 - stop some parameters getting counted twice

* Fix issue where 'shareInstances' resolve but fail to propagate (Level-2#201)

* Level-2#200 - Expand shareInstances test to replicate propagation issue

* Level-2#200 - Fix issue where 'shareInstances' resolve but fail to propagate

Because `$share` is passed by reference to `matchParam()`, and
`matchParam()` removes matching objects from its `$search` array,
instances may be removed from `$share` before it is passed to `expand()`
or `create()`. Depending on the order of constructor parameters and the
relative placement of `shareInstances` dependencies in the object tree,
this may result in multiple instances of these dependencies being
created.

Fixed by passing a copy of the `$share` array to `matchParam()`.

- Updated CI to use github actions

Co-authored-by: thisispiers <[email protected]>
Co-authored-by: Tom Butler <[email protected]>
Co-authored-by: Luke Arms <[email protected]>
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.

2 participants