[11.x] Fix database reconnecting logic#53693
Conversation
|
Thanks for submitting a PR! Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
|
The only tests that seem to relate to the reconnecting logic are in To test that the default reconnector re-creates the connection in The test I'd like to add would be essentially something like this (just copied this from a codebase where I'm using Pest): config(['database.connections.testbench' => [
'driver' => 'mysql',
'host' => '127.0.0.1',
'username' => 'root',
'password' => 'invalid-credentials',
'database' => 'forge',
'prefix' => '',
]]);
$connection = DB::connection('testbench');
expect($connection->getRawPdo())->not()->toBeNull();
DB::purge('testbench');
expect($connection->getRawPdo())->toBeNull();
// normally triggered by a query but we're not establishing a connection to a real server here
$connection->reconnectIfMissingConnection();
// fails if I revert my patch
expect($connection->getRawPdo())->not()->toBeNull();
DB::purge('testbench'); |
|
Marking as ready for review, please let me know how I should add the test or feel free to just push it. |
|
@taylorotwell Do you want to add the regression test in some form? |
Fixes #53692.
Sending this as a draft for convenience so that this can move forward once I get confirmation that my idea of the fix is correct.
Before this is merged, a test should be added verifying that connections are now repaired by the reconnect() call.