-
-
Notifications
You must be signed in to change notification settings - Fork 410
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
PDOException thrown when creating a new tenant from Nova (PHP 8) #720
Comments
Is this related to tenant creation or just Nova? And if it's just Nova, how does it create tenants? |
I think it's just Nova, because when creating a tenant through a seeder or a simple route containing What do you mean how? All I know is that I'm using Nova the regular way, meaning that I have a Resource (CRUD) for my Tenant and when I use the creation form :
Thanks for your help |
What if you queue the DB creation? |
It works! The only issue I had was regarding my TenantObserver's Thanks for your help! |
Right, the issue then was probably Nova wrapping the create logic in a transaction, but Tenancy would also handle DB creation which now can't be inside a DB transaction |
I'm having this issue too. Was the solution to queue something somewhere? Can you explain how you fixed it @WillyReyno? |
@jwktje in For example: Events\TenantCreated::class => [
JobPipeline::make([
Jobs\CreateDatabase::class,
Jobs\MigrateDatabase::class,
])->send(function (Events\TenantCreated $event) {
return $event->tenant;
})->shouldBeQueued(true), // here
], I already had queues running on my project since we use them for various stuff, so that was the only thing to do for me. |
@WillyReyno Yup that fixed it. That's great! Thanks for the quick response. This makes a lot of sense. |
This method did not solve my problem. I still keep getting the same error when I create tenant from Nova. It does all the operations (such as creating a database, adding records) but throw exception |
Same problem here with Nova 4 |
just wrap the code in event() method in TenancyServiceProvider.php file. public function events()
|
That’s not how PHP works, the try {} will not do anything. |
Describe the bug
Since upgrading to PHP 8, the Tenant creation process does not work properly when triggered from a Nova resource.
We created a Tenant Resource in Laravel Nova which was working perfectly fine with PHP 7.4, the events were properly triggered, and we could use our new tenant app without any issue.
Now we are getting a
There is no active transaction
PDO ExceptionThe exception does not block the JobPipeline, the tenant is created in the central database, and the tenant database is also properly created & migrated.
I can also confirm the exception is not thrown when manually creating a Tenant with
new Tenant()
or within seeders.I don't know if the following can help, but here's what I found after a few searches :
Steps to reproduce
Using PHP 8 :
Setup
The text was updated successfully, but these errors were encountered: