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

[6.x] Fix handleBeginTransactionException method calling pdo property instead of getPdo() method #31233

Merged
merged 2 commits into from
Jan 27, 2020
Merged

[6.x] Fix handleBeginTransactionException method calling pdo property instead of getPdo() method #31233

merged 2 commits into from
Jan 27, 2020

Conversation

kanidjar
Copy link
Contributor

Fix handleBeginTransactionException method calling pdo property instead of getPdo() method (#31230)

Description:

When connection to database is lost and transaction is retried, an exception is thrown.

[2020-01-24 15:00:16] production.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Closure::beginTransaction() in /var/www/html/vendor/illuminate/database/Concerns/ManagesTransactions.php:157
Stack trace:
#0 /var/www/html/vendor/illuminate/database/Concerns/ManagesTransactions.php(125): Illuminate\Database\Connection->handleBeginTransactionException(Object(PDOException))
#1 /var/www/html/vendor/illuminate/database/Concerns/ManagesTransactions.php(105): Illuminate\Database\Connection->createTransaction()
#2 /var/www/html/vendor/illuminate/database/Concerns/ManagesTransactions.php(23): Illuminate\Database\Connection->beginTransaction()
#3 /var/www/html/vendor/illuminate/database/DatabaseManager.php(349): Illuminate\Database\Connection->transaction(Object(Closure))
#4 /var/www/html/vendor/illuminate/support/Facades/Facade.php(261): Illuminate\Database\DatabaseManager->__call('transaction', Array)
#5 /var/www/html/app/Services/PriceService.php(55): Illuminate\Support\Facades\Facade::__callStatic('transaction', Array)

The exception is thrown because of line 157 calling $this->pdo instead of $this->getPdo()

Same bug was detected in Laravel 5.3 but was not linked to the same file.

#15927

Steps To Reproduce:

Lose connection to database during transaction creation (hard to reproduce but easy to fix)

@kanidjar kanidjar changed the title Fix handleBeginTransactionException method calling pdo property instead of getPdo() method (#31230) [6.x] Fix handleBeginTransactionException method calling pdo property instead of getPdo() method (#31230) Jan 24, 2020
@kanidjar kanidjar changed the title [6.x] Fix handleBeginTransactionException method calling pdo property instead of getPdo() method (#31230) [6.x] Fix handleBeginTransactionException method calling pdo property instead of getPdo() method Jan 24, 2020
@GrahamCampbell
Copy link
Member

Please revert the other changes to the file.

@kanidjar
Copy link
Contributor Author

@GrahamCampbell Done

@L3o-pold
Copy link

@GrahamCampbell can we merge this into the next release?

@GrahamCampbell
Copy link
Member

If this is merged before early afternoon (UK time) tomorrow, then it will likely be included in tomorrow's release.

@GrahamCampbell
Copy link
Member

It is much more likely to be merged if you add tests that cover this code, that fail before this PR, and pass afterwards.

Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other calls to the pdo property are also covered with getPdo so this seems okay 👍

@taylorotwell taylorotwell merged commit b5f3d22 into laravel:6.x Jan 27, 2020
@kanidjar kanidjar deleted the fix/handle-begin-transaction-exception branch January 27, 2020 15:16
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.

5 participants