From 188296d7f77dec0311938b871d9e33c6c68ce0fb Mon Sep 17 00:00:00 2001 From: chaz6chez Date: Tue, 24 Sep 2024 11:58:28 +0800 Subject: [PATCH] fix: TypeError: trim(): Argument #1 ($string) must be of type string, null given --- src/Traits/RegistrarMethods.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Traits/RegistrarMethods.php b/src/Traits/RegistrarMethods.php index 63279b0..9d1bc3a 100644 --- a/src/Traits/RegistrarMethods.php +++ b/src/Traits/RegistrarMethods.php @@ -21,6 +21,10 @@ trait RegistrarMethods { protected ?int $registrarTimerId = null; + protected ?string $registrarHostIp = null; + + protected ?int $registrarHostPort = null; + /** * @return RegistrarInterface|null */ @@ -79,7 +83,7 @@ public function registrarStop(Worker $worker): void */ public function registrarGetHostIp(): string { - return trim(shell_exec('curl -s ifconfig.me')); + return $this->registrarHostIp ?: ($this->registrarHostIp = trim(shell_exec('curl -s ifconfig.me'))); } /** @@ -88,7 +92,7 @@ public function registrarGetHostIp(): string public function registrarGetHostPort(): ?int { $serverName = static::getServerName(); - return config("plugin.workbunny.webman-push-server.app.$serverName.port"); + return $this->registrarHostPort ?: ($this->registrarHostPort = config("plugin.workbunny.webman-push-server.app.$serverName.port")); } /**