-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Queue driver 'sync' generates "Call to a member function prepare() on null" #444
Comments
Take a look here: #442 Please add me to your repository: I will help you. |
I think this is related to #446 |
Try to create your own class SwitchDatabaseTask implements SwitchTenantTask
{
use UsesMultitenancyConfig;
protected ?string $originalDefaultConnection;
protected ?array $originalTenantDatabase;
public function makeCurrent(Tenant $tenant): void
{
$this->originalDefaultConnection = config('database.default');
$this->originalTenantDatabase = config('database.connections.tenant.database');
$this->setup($tenant);
}
private function setup(Tenant $tenant)
{
config()->set([
'database.default' => $this->tenantDatabaseConnectionName(),
'database.connections.tenant.database' => $tenant->database,
]);
DB::purge($this->tenantDatabaseConnectionName());
}
public function forgetCurrent(): void
{
config([
'database.default' => $this->originalDefaultConnection,
'database.connections.tenant.database' => $this->originalTenantDatabase,
]);
DB::purge($this->tenantDatabaseConnectionName());
}
} Give me a feedback. Thanks |
I'm closing here because of inactivity, but please feel free to continue the discussion. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Laravel 10
Jetstream / Sanctum / Scout / Socialite
Laravel Multi Tenancy / Permission / Activity Log / Media library Pro / Query Builder
When calling a job with the
queue_driver=sync
the following error is thrown:Call to a member function prepare() on null
. The PDO is null. It looks like it doesnt know which (tenant) connection to use.When changing session driver to:
file
, it works. But this is not an option.When changing the queue driver to
redis
, the problem is solved.In
multitenancy.php
thequeues_are_tenant_aware_by_default
is set totrue
. Also defining the jobs in thetenant_aware_jobs
array does not work with driver 'sync'.Are the session_driver and the queues related? (For example, when using
session_driver=file
, is the tenant connection saved in this session file?).Summary:
sync queue
withsession file
it works. (but not an option)sync queue
withsession database
it failssync redis
withsession database
it works.Is this behaviour to be expected? Or is there something wrong in my application (settings).
The text was updated successfully, but these errors were encountered: