Skip to content

Register the Mongo driver through the make function instead of resolving function #2715

Open
@zyz954489346

Description

@zyz954489346
  • Laravel-mongodb Version: 4.1
  • PHP Version: 8.3
  • Database Driver & Version: 4

Description:

Register the Mongo driver through the make function instead of resolving functiong

If db is instantiated in another package, then the callback function registered through resolving function will not be executed, which is a hidden BUG.

This problem does not occur stably, only if a package is sorted by the composer and executes its own provider before the laravel-mongodb provider, and exactly instantiates db.

The core code is:
image

 In my project, the following code exists in other packages, which can lead to problems. Because db is instantiated in advance:
image

Problems caused by,there is an error:
Unsupported driver [mongodb]. - InvalidArgumentException

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions