8000 Call to a member function beginTransaction() on null · Issue #964 · mongodb/laravel-mongodb · GitHub
[go: up one dir, main page]

Skip to content

Call to a member function beginTransaction() on null #964

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

Closed
sachinvrg opened this issue Sep 21, 2016 · 17 comments
Closed

Call to a member function beginTransaction() on null #964

sachinvrg opened this issue Sep 21, 2016 · 17 comments
Labels

Comments

@sachinvrg
Copy link

When I fire php artisan queue:work command , it throws following error
PHP Fatal error: Call to a member function beginTransaction() on null in /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 576
PHP Stack trace:
PHP 1. {main}() /var/www/html/push_admin/setupl/artisan:0
PHP 2. Illuminate\Foundation\Console\Kernel->handle() /var/www/html/push_admin/setupl/artisan:36
PHP 3. Symfony\Component\Console\Application->run() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107
PHP 4. Symfony\Component\Console\Application->doRun() /var/www/html/push_admin/setupl/vendor/symfony/console/Application.php:117
PHP 5. Symfony\Component\Console\Application->doRunCommand() /var/www/html/push_admin/setupl/vendor/symfony/console/Application.php:186
PHP 6. Illuminate\Console\Command->run() /var/www/html/push_admin/setupl/vendor/symfony/console/Application.php:794
PHP 7. Symfony\Component\Console\Command\Command->run() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Console/Command.php:155
PHP 8. Illuminate\Console\Command->execute() /var/www/html/push_admin/setupl/vendor/symfony/console/Command/Command.php:256
PHP 9. Illuminate\Container\Container->call() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Console/Command.php:169
PHP 10. call_user_func_array:{/var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Container/Container.php:507}() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Container/Container.php:507
PHP 11. Illuminate\Queue\Console\WorkCommand->fire() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Container/Container.php:507
PHP 12. Illuminate\Queue\Console\WorkCommand->runWorker() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:79
PHP 13. Illuminate\Queue\Worker->pop() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:126
PHP 14. Illuminate\Queue\Worker->getNextJob() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:149
PHP 15. Illuminate\Queue\DatabaseQueue->pop() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:180
PHP 16. Illuminate\Database\Connection->beginTransaction() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php:162

[Symfony\Component\Debug\Exception\FatalErrorException]
Call to a member function beginTransaction() on null

Anybody have any idea about it? Please help!!!

@sachinvrg
Copy link
Author

@parth-vora-7
Copy link

Hello,

I'm also getting this same error.

[2016-11-12 20:18:45] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to a member function beginTransaction() on null' in C:\wamp\www\blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:611
Stack trace:
#0 {main}

Can anybody please help me?

Thanks,

@parth-vora-7
Copy link

@sachinvrg , Have you configured queue properly as described over here:
https://github.com/jenssegers/laravel-mongodb#queues

I have found the issue with my project.
I had not followed the queue configuration of the package.
Just follow the proper instruction and it works very well.

@janhartigan
Copy link
janhartigan commented Dec 6, 2016

The specific issue that it's complaining about is that it's trying to get the PDO on a database connection that doesn't have it.

https://github.com/laravel/framework/blob/d1a4f3fc7951c04ff91855511ed8c73b1a98e533/src/Illuminate/Database/Connection.php#L612

The getPdo() method returns null in the case of the mongodb driver connection. You may have to avoid using the database queue driver if you use this package, or you can overload the beginTransaction method to simply do nothing.

@ahkui
Copy link
ahkui commented Jan 12, 2018

override this in authcontroller protected function incrementLoginAttempts(Request $request){}

@prashant-pokhriyal
Copy link

@janhartigan , where to overload beginTransaction method?

@phillmorgan28
Copy link

Having this issue on Laravel 5.8 (latest) when attempting to connect through API.

Call to a member function beginTransaction() on null {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function beginTransaction() on null at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:109) [stacktrace] #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(93): Illuminate\\Database\\Connection->createTransaction() #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(23): Illuminate\\Database\\Connection->beginTransaction() #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php(183): Illuminate\\Database\\Connection->transaction(Object(Closure)) #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php(122): Illuminate\\Cache\\DatabaseStore->incrementOrDecrement('97ae145b1055ad7...', 1, Object(Closure)) #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(331): Illuminate\\Cache\\DatabaseStore->increment('97ae145b1055ad7...', 1) #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Cache/RateLimiter.php(65): Illuminate\\Cache\\Repository->increment('97ae145b1055ad7...') #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(56): Illuminate\\Cache\\RateLimiter->hit('97ae145b1055ad7...', 60) #7 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Illuminate\\Http\\Request), Object(Closure), 60, '1') #8 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #9 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #10 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #11 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request)) #12 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route)) #13 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request)) #14 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request)) #15 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request)) #16 /var/www/html/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #17 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #18 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #19 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #20 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #21 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #22 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #23 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #24 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #25 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #26 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #27 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #28 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #29 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #30 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #31 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #32 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #33 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request)) #34 /var/www/html/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))

@gideonpeters
Copy link

@phillmorgan28 did you eventually resolve this?

@umimehar
Copy link

Anyone solved this problem? i am not using queue.

@paouriel
Copy link
paouriel commented Feb 17, 2020

This issue still persists. I've already configured my queue.php according here: Laravel MongoDB Queues

Already ran php artisan config:cache and this are the values for my queue.php

config('queue.connections.database')
[
     "driver" => "mongodb",
     "table" => "jobs",
     "queue" => "default",
     "retry_after" => 90,
]
config('queue.failed')
[
     "driver" => "mongodb",
     "database" => "mongodb",
     "table" => "failed_jobs",
]

Any other fix for this?

@divine
Copy link
Contributor
divine commented Feb 17, 2020

This issue still persists. I've already configured my queue.php according here: Laravel MongoDB Queues

Already ran php artisan config:cache and this are the values for my queue.php

config('queue.connections.database')

[
     "driver" => "mongodb",
     "table" => "jobs",
     "queue" => "default",
     "retry_after" => 90,
]

config('queue.failed')

[
     "driver" => "mongodb",
     "database" => "mongodb",
     "table" => "failed_jobs",
]

Any other fix for this?

@paouriel can't recreate, check that you've correct mongodb settings, probably you're not even connecting to db.

@paouriel
Copy link
paouriel commented Feb 18, 2020

@divine I managed to create a workaround for this. I've created a temporary command.
Here: Laravel MongoDB Transaction Fix

@divine
Copy link
Contributor
divine commented Feb 18, 2020

@divine I managed to create a workaround for this. I've created a temporary command.
Here: Laravel MongoDB Transaction Fix

This is really bad practice to modify vendor files. As I've said can't really recreate it.

Fork this library https://github.com/Smolevich/demo-mongo-application and add configuration as well as examples so it will be easy to recreate issues you're having.

@wajdijurry
Copy link

Any solution for this headache issue ?

@wajdijurry
Copy link

The specific issue that it's complaining about is that it's trying to get the PDO on a database connection that doesn't have it.

https://github.com/laravel/framework/blob/d1a4f3fc7951c04ff91855511ed8c73b1a98e533/src/Illuminate/Database/Connection.php#L612

The getPdo() method returns null in the case of the mongodb driver connection. You may have to avoid using the database queue driver if you use this package, or you can overload the beginTransaction method to simply do nothing.

Explain more please

@robertoarruda
Copy link

The problem still exists. @jenssegers, please reopen this issue.

@mongodb mongodb locked as off-topic and limited conversation to collaborators Sep 29, 2021
@divine
Copy link
Contributor
divine commented Sep 29, 2021

The problem still exists. @jenssegers, please reopen this issue.

See #1904

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

0