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

[Bug]: Getting ORM:class from $app creates new instance #752

Open
mm-sol opened this issue Aug 23, 2024 · 0 comments
Open

[Bug]: Getting ORM:class from $app creates new instance #752

mm-sol opened this issue Aug 23, 2024 · 0 comments
Assignees
Labels
type: bug Bug fix (fix)

Comments

@mm-sol
Copy link

mm-sol commented Aug 23, 2024

Describe the bug

When getting ORM:class from laravel $app container laravel creates new instance. It leads to hard to find&fix "duplicate key value violation" on entity when updating (because entity manager has different orm).
It's understandable that it shouldn't happen as everyone should use ORMInterface class, but mistakes happens.

Is this a regression?

Dunno

To Reproduce

  1. spl_object_hash($app->get(ORM::class))
  2. spl_object_hash($app->get(ORMInterface::class))
  3. compare
  4. hash mismatch

Expected behaviour

hash matches

Media prove

No response

Your environment

No response

Additional context

Fix:

Add code below to src/Bridge/Laravel/Providers/Registrators/RegisterORM.php:

$this->app->singleton(ORM::class, function ($app) { return $app->get(ORMInterface::class); });

Sorry for not making pull request with this, no time, deep in deadlines.

@mm-sol mm-sol added the type: bug Bug fix (fix) label Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Bug fix (fix)
Projects
None yet
Development

No branches or pull requests

2 participants