Closed
Description
Bug description
QueueTenancyBootstrapper will not recognize changes to Tenant Data until tenancy()->initialized is called.
- Tenant1 job arrives on the queue and is processed
- Tenant1 attribute data is updated.
- Tenant1 job arrives on the queue but since tenancy was already intialized the tenant data does not get updated for the currently initialized tenant
Looks to be the result of QueueTenancyBootstrapper::initializeTenancyForQueue code snippet (or setUpJobListener in 3.4.6)
if (tenancy()->initialized) {
if (tenant()->getTenantKey() === $tenantId) {
// Tenancy is already initialized for the tenant (e.g. dispatchNow was used)
return;
}
}
This prevents the tenancy initialization that occurs after this snippet.
Instead of return here what would be the implications of calling tenant()->end() ?
Unsure whether the If statement was only performance related. In the scenario above if Tenant2 job arrives and is processed prior to the 2nd Tenant1 job then when 2nd Tenant1 job is processed tenancy is intialized and correct attribute data is reflected.
Steps to reproduce
- Send job for Tenant1 to a queue
- Run Queue worker (and leave running) and output to log the data attribute you will change in point 3 below
- Edit Tenant1 data attribute
- Send job for Tenant1 to queue and output the data attirubte in point 3 below 3
- The old data attribute will appear
Expected behavior
- Send job for Tenant1 to a queue
- Run Queue worker (and leave running) and output to log the data attribute you will change in point 3 below
- Edit Tenant1 data attribute
- Send job for Tenant1 to queue and output the data attirubte in from point 3
- The new data attribute will appear
Laravel version
8
stancl/tenancy version
3.4.6 and 3.5.1