From f5ea8a83f09c3d594452b4d8c491d98358ed80f8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 11 Nov 2021 11:35:58 +1100 Subject: [PATCH] Fixes for Sentinel timeouts --- app/Http/Controllers/ImportController.php | 4 ++-- app/Jobs/Import/CSVImport.php | 2 +- app/Listeners/Invoice/InvoiceCreatedNotification.php | 9 ++++----- app/Listeners/Quote/QuoteCreatedNotification.php | 3 +++ config/database.php | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index 507997d01717..bb0f320c6c9b 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -83,7 +83,7 @@ class ImportController extends Controller { $contents = file_get_contents( $file->getPathname() ); // Store the csv in cache with an expiry of 10 minutes - Cache::put( $hash . '-' . $entityType, base64_encode( $contents ), 3600 ); + Cache::put( $hash . '-' . $entityType, base64_encode( $contents ), 600 ); // Parse CSV $csv_array = $this->getCsvData( $contents ); @@ -111,7 +111,7 @@ class ImportController extends Controller { $contents = file_get_contents( $file->getPathname() ); // Store the csv in cache with an expiry of 10 minutes - Cache::put( $hash . '-' . $entityType, base64_encode( $contents ), 3600 ); + Cache::put( $hash . '-' . $entityType, base64_encode( $contents ), 600 ); } } diff --git a/app/Jobs/Import/CSVImport.php b/app/Jobs/Import/CSVImport.php index c893530b4e81..d4e0dcf56c0e 100644 --- a/app/Jobs/Import/CSVImport.php +++ b/app/Jobs/Import/CSVImport.php @@ -587,7 +587,7 @@ class CSVImport implements ShouldQueue { } private function getCsvData( $entityType ) { - $base64_encoded_csv = Cache::get( $this->hash . '-' . $entityType ); + $base64_encoded_csv = Cache::pull( $this->hash . '-' . $entityType ); if ( empty( $base64_encoded_csv ) ) { return null; } diff --git a/app/Listeners/Invoice/InvoiceCreatedNotification.php b/app/Listeners/Invoice/InvoiceCreatedNotification.php index 49f4af309518..8d1ed9b3864d 100644 --- a/app/Listeners/Invoice/InvoiceCreatedNotification.php +++ b/app/Listeners/Invoice/InvoiceCreatedNotification.php @@ -52,6 +52,10 @@ class InvoiceCreatedNotification implements ShouldQueue /* The User */ $user = $company_user->user; + + if(!$user) + continue; + /* This is only here to handle the alternate message channels - ie Slack */ // $notification = new EntitySentNotification($event->invitation, 'invoice'); @@ -71,11 +75,6 @@ class InvoiceCreatedNotification implements ShouldQueue } - /* Override the methods in the Notification Class */ - // $notification->method = $methods; - - // Notify on the alternate channels - // $user->notify($notification); } } } diff --git a/app/Listeners/Quote/QuoteCreatedNotification.php b/app/Listeners/Quote/QuoteCreatedNotification.php index 699b6eba88c2..0336bf036595 100644 --- a/app/Listeners/Quote/QuoteCreatedNotification.php +++ b/app/Listeners/Quote/QuoteCreatedNotification.php @@ -53,6 +53,9 @@ class QuoteCreatedNotification implements ShouldQueue /* The User */ $user = $company_user->user; + if(!$user) + continue; + /* This is only here to handle the alternate message channels - ie Slack */ // $notification = new EntitySentNotification($event->invitation, 'quote'); diff --git a/config/database.php b/config/database.php index 1333795cfc0f..dc9f80481864 100644 --- a/config/database.php +++ b/config/database.php @@ -207,7 +207,7 @@ return [ ['options' => [ 'replication' => 'sentinel', 'service' => env('REDIS_SENTINEL_SERVICE', 'mymaster'), - 'sentinel_timeout' => 1.0, + 'sentinel_timeout' => 2.0, 'parameters' => [ 'password' => env('REDIS_PASSWORD', null), 'database' => env('REDIS_DB', 0), @@ -226,7 +226,7 @@ return [ ['options' => [ 'replication' => 'sentinel', 'service' => env('REDIS_SENTINEL_SERVICE', 'mymaster'), - 'sentinel_timeout' => 1.0, + 'sentinel_timeout' => 2.0, 'parameters' => [ 'password' => env('REDIS_PASSWORD', null), 'database' => env('REDIS_CACHE_DB', 1),