From 83e06908b0680c369fba1c1375679444cf76c24b Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 7 Oct 2021 23:32:05 +1100 Subject: [PATCH] Multiple exception bug fixes identified during testing --- app/Classes/Sock/SocketClient.php | 10 +++++++++- app/Http/Controllers/SystemController.php | 1 + app/Jobs/EchoareaImport.php | 2 +- app/Jobs/NodelistImport.php | 10 +++++++--- app/Models/Echomail.php | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/Classes/Sock/SocketClient.php b/app/Classes/Sock/SocketClient.php index b7d15f2..fa5a9e9 100644 --- a/app/Classes/Sock/SocketClient.php +++ b/app/Classes/Sock/SocketClient.php @@ -285,7 +285,15 @@ final class SocketClient { return ''; $buf = ''; - $rc = socket_recv($this->connection,$buf, $len,MSG_DONTWAIT); + try { + $rc = socket_recv($this->connection,$buf, $len,MSG_DONTWAIT); + + } catch (\Exception $e) { + Log::error(sprintf('%s: - socket_recv Exception [%s]',self::LOGKEY,$e->getMessage())); + + throw new SocketException($x=socket_last_error($this->connection),socket_strerror($x)); + } + if ($this->DEBUG) Log::debug(sprintf('%s: - Read [%d]',self::LOGKEY,$rc)); diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 51710d8..e8f0f7f 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -67,6 +67,7 @@ class SystemController extends Controller $oo = new Address; $oo->zone_id = $request->post('zone_id'); $oo->region_id = $request->post('region_id_new'); + $oo->host_id = 0; $oo->node_id = 0; $oo->point_id = 0; $oo->role = DomainController::NODE_RC; diff --git a/app/Jobs/EchoareaImport.php b/app/Jobs/EchoareaImport.php index 0cb2192..c9ddf3d 100644 --- a/app/Jobs/EchoareaImport.php +++ b/app/Jobs/EchoareaImport.php @@ -39,7 +39,7 @@ class EchoareaImport implements ShouldQueue { $this->file = $file; $this->do = $do; - $this->prefix = $prefix; + $this->prefix = $prefix ?: ''; $this->delete_file = $delete_file; $this->delete_recs = $delete_recs; } diff --git a/app/Jobs/NodelistImport.php b/app/Jobs/NodelistImport.php index 2082f37..08a8689 100644 --- a/app/Jobs/NodelistImport.php +++ b/app/Jobs/NodelistImport.php @@ -295,9 +295,13 @@ class NodelistImport implements ShouldQueue // We'll search and see if we already have that system } else { - $so = System::where('mailer_address',$address) - ->where('mailer_port',$port) - ->single(); + // If we dont have $address/port + $so = NULL; + + if ($address && $port) + $so = System::where('mailer_address',$address) + ->where('mailer_port',$port) + ->single(); if (! $so) $so = System::where('name',$system) diff --git a/app/Models/Echomail.php b/app/Models/Echomail.php index 1c1153e..917eb8f 100644 --- a/app/Models/Echomail.php +++ b/app/Models/Echomail.php @@ -86,7 +86,7 @@ final class Echomail extends Model implements Packet /* ATTRIBUTES */ - public function getKludgesAttribute(string $value): Collection + public function getKludgesAttribute(?string $value): Collection { return collect($this->castAttribute('kludges',$value)); }