From 2d3c9eb63c465c2f5318355a33dd5b4af0c99b2a Mon Sep 17 00:00:00 2001 From: Pierre NAPOLETANO <56818795+PierreNAPOLETANO@users.noreply.github.com> Date: Tue, 11 Mar 2025 15:26:43 +0100 Subject: [PATCH] Update Slave.php --- src/Slave.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Slave.php b/src/Slave.php index 2f9f058..762783c 100644 --- a/src/Slave.php +++ b/src/Slave.php @@ -29,12 +29,11 @@ public function status() { } else { try { $sss = $this->connection()->query('SHOW SLAVE STATUS')->fetch(); - if ($sss['Slave_IO_Running'] === 'No' || $sss['Slave_SQL_Running'] === 'No') { - // slave is STOPPED - return $this->setSlaveStatus(false, null); - } else { - return $this->setSlaveStatus(true, $sss['Seconds_Behind_Master']); - } + + return $sss['Slave_IO_Running'] === 'No' || $sss['Slave_SQL_Running'] === 'No' + ? $this->setSlaveStatus(false, null) + : $this->setSlaveStatus(true, $sss['Seconds_Behind_Master']); + } catch (\Exception $e) { if (stripos($e->getMessage(), 'Access denied') !== false) { return $this->setSlaveStatus(true, 0); @@ -48,4 +47,4 @@ public function disable() { $this->weight = 0; $this->connection = null; } -} \ No newline at end of file +}