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: Factories may not return shared instance #7868

Merged
merged 8 commits into from
Aug 29, 2023

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Aug 27, 2023

Description
If you call config(AuthJWT::class) (FQCN) and after that, call config('AuthJWT') (shortname),
the new instance is returned even if both are exactly the same class.
And the first shared instance is replaced with the next one.

See codeigniter4/shield#802

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

kenjis added 2 commits August 27, 2023 10:19
If the request class is the same, it is better to return the shared
instance.
If it is called by different aliase like `'App'` and `App::class`.
But if they are exactly the same FQCN, the shared instance should
be returned.
@kenjis kenjis added bug Verified issues on the current code behavior or pull requests that will fix them 4.4 labels Aug 27, 2023
@kenjis kenjis marked this pull request as draft August 27, 2023 01:32
@kenjis kenjis force-pushed the fix-factories-return-new-instance branch from 8b98540 to 1b88479 Compare August 27, 2023 02:28
@kenjis kenjis marked this pull request as ready for review August 27, 2023 02:31
@kenjis kenjis mentioned this pull request Aug 29, 2023
9 tasks
@kenjis kenjis merged commit bb0cd96 into codeigniter4:develop Aug 29, 2023
@kenjis kenjis deleted the fix-factories-return-new-instance branch August 29, 2023 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.4 bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants