@@ -258,51 +258,19 @@ private static function bootstrapTenantApp(JobProcessing|JobRetryRequested $even
258258 return ;
259259 }
260260
261- // Save the landlord's config values so we can reset them later
262- if (self ::$ landlordValues === null ) {
263- foreach (TenantBootstrapper::$ landlordKeysToSave as $ key ) {
264- self ::$ landlordValues [$ key ] = $ _SERVER [$ key ] ?? '' ;
265- }
266- }
267-
268261 // Create a new tenant app instance
269262 $ _SERVER ['TENANT ' ] = $ tenantId ;
270- $ _ENV ['TENANT ' ] = $ tenantId ;
271263
272264 if (!isset (self ::$ tenantAppContainers [$ tenantId ])) {
273- $ tenantApp = require app ()->bootstrapPath ('app.php ' );
274- $ tenantApp ->instance ('landlordValues ' , self ::$ landlordValues );
275- $ tenantApp ->make (\Illuminate \Contracts \Console \Kernel::class)->bootstrap ();
276- self ::$ tenantAppContainers [$ tenantId ] = $ tenantApp ;
265+ self ::$ tenantAppContainers [$ tenantId ] = require base_path ('bootstrap/app.php ' );
277266 }
267+ self ::$ tenantAppContainers [$ tenantId ]->reactivateConsoleApp ();
278268
279269 // Change the job's app service container to the tenant app
280270 $ event ->job ->getRedisQueue ()->setContainer (self ::$ tenantAppContainers [$ tenantId ]);
281271 }
282272 }
283273
284- private static function resetTenantApp ($ event ): void
285- {
286- if (!method_exists ($ event ->job , 'getRedisQueue ' )) {
287- // Not a redis job
288- return ;
289- }
290-
291- unset($ _SERVER ['TENANT ' ]);
292- unset($ _ENV ['TENANT ' ]);
293-
294- if (!self ::$ landlordValues ) {
295- return ;
296- }
297-
298- // Restore the original values since the tenant boostrapper modified them
299- foreach (self ::$ landlordValues as $ key => $ value ) {
300- $ _SERVER [$ key ] = $ value ;
301- $ _ENV [$ key ] = $ value ;
302- putenv ("$ key= $ value " );
303- }
304- }
305-
306274 /**
307275 * Register app-level events.
308276 */
@@ -316,10 +284,6 @@ protected static function registerEvents(): void
316284 self ::bootstrapTenantApp ($ event );
317285 });
318286
319- Facades \Event::listen (JobAttempted::class, function (JobAttempted $ event ) {
320- self ::resetTenantApp ($ event );
321- });
322-
323287 // Listen to the events for our core screen
324288 // types and add our javascript
325289 Facades \Event::listen (ScreenBuilderStarting::class, function ($ event ) {
0 commit comments