From 379d6dca5664a8c903f652a018561d520b4a720c Mon Sep 17 00:00:00 2001 From: Filipe Oliveira Date: Tue, 21 Jul 2026 12:11:28 +0100 Subject: [PATCH 1/4] Add paused and wrapupTime fields to static member config lines Asterisk's member => line accepts these as the 6th/7th positional fields after ringinuse. Needed by core so linear-strategy static members (delivered as flat-file lines, not realtime queue_members rows) can still carry their paused state. --- src/Clearvox/Asterisk/Queue/Member.php | 89 ++++++++++++++++++-- tests/Clearvox/Asterisk/Queue/MemberTest.php | 36 ++++++++ 2 files changed, 116 insertions(+), 9 deletions(-) diff --git a/src/Clearvox/Asterisk/Queue/Member.php b/src/Clearvox/Asterisk/Queue/Member.php index 0a034a0..870f9c4 100644 --- a/src/Clearvox/Asterisk/Queue/Member.php +++ b/src/Clearvox/Asterisk/Queue/Member.php @@ -28,18 +28,32 @@ class Member */ protected $ringInUse; + /** + * @var int + */ + protected $wrapupTime; + + /** + * @var bool + */ + protected $paused; + public function __construct( $interface, $penalty = null, $memberName = null, $stateInterface = null, - $ringInUse = null + $ringInUse = null, + $wrapupTime = null, + $paused = null ) { $this->interface = $interface; $this->penalty = $penalty; $this->memberName = $memberName; $this->stateInterface = $stateInterface; $this->ringInUse = $ringInUse; + $this->wrapupTime = $wrapupTime; + $this->paused = $paused; } public function getInterface() @@ -119,31 +133,88 @@ public function setRingInUse($ringInUse) return $this; } + /** + * @return null + */ + public function getWrapupTime() + { + return $this->wrapupTime; + } + + /** + * @param null $wrapupTime + * @return Member + */ + public function setWrapupTime($wrapupTime) + { + $this->wrapupTime = $wrapupTime; + return $this; + } + + /** + * @return null + */ + public function getPaused() + { + return $this->paused; + } + + /** + * @param boolean $paused + * @return Member + */ + public function setPaused($paused) + { + $this->paused = (boolean)$paused; + return $this; + } + public function toString() { - if(!is_null($this->ringInUse)) { - $line[0] = ($this->ringInUse ? 'yes' : 'no'); + // Asterisk's static member fields, in positional order, are: + // interface,penalty,membername,state_interface,ringinuse,wrapuptime,paused + // Fields below the highest one actually set must be emitted (even if empty) + // to keep every later field in its correct position. + if (!is_null($this->paused)) { + $line[0] = ($this->paused ? '1' : '0'); $line[1] = null; $line[2] = null; $line[3] = null; + $line[4] = null; + $line[5] = null; } - if (!is_null($this->stateInterface)) { - $line[1] = $this->stateInterface; + if (!is_null($this->wrapupTime)) { + $line[1] = $this->wrapupTime; $line[2] = null; $line[3] = null; + $line[4] = null; + $line[5] = null; } - if (!is_null($this->memberName)) { - $line[2] = $this->memberName; + if(!is_null($this->ringInUse)) { + $line[2] = ($this->ringInUse ? 'yes' : 'no'); $line[3] = null; + $line[4] = null; + $line[5] = null; + } + + if (!is_null($this->stateInterface)) { + $line[3] = $this->stateInterface; + $line[4] = null; + $line[5] = null; + } + + if (!is_null($this->memberName)) { + $line[4] = $this->memberName; + $line[5] = null; } if (!is_null($this->penalty)) { - $line[3] = $this->penalty; + $line[5] = $this->penalty; } - $line[4] = $this->interface; + $line[6] = $this->interface; return 'member => ' . implode(',', array_reverse($line)); } diff --git a/tests/Clearvox/Asterisk/Queue/MemberTest.php b/tests/Clearvox/Asterisk/Queue/MemberTest.php index c3dfbc4..719cdc1 100644 --- a/tests/Clearvox/Asterisk/Queue/MemberTest.php +++ b/tests/Clearvox/Asterisk/Queue/MemberTest.php @@ -32,4 +32,40 @@ public function testToString() $this->member->toString() ); } + + public function testToStringWithPausedOnly() + { + $this->member->setPaused(true); + + $this->assertEquals( + 'member => Local/1000,,,,,,1', + $this->member->toString() + ); + } + + public function testToStringWithPausedFalse() + { + $this->member->setPaused(false); + + $this->assertEquals( + 'member => Local/1000,,,,,,0', + $this->member->toString() + ); + } + + public function testToStringWithAllFields() + { + $this->member + ->setMemberName('John Smith') + ->setPenalty(10) + ->setRingInUse(true) + ->setStateInterface('SIP/2000') + ->setWrapupTime(30) + ->setPaused(true); + + $this->assertEquals( + 'member => Local/1000,10,John Smith,SIP/2000,yes,30,1', + $this->member->toString() + ); + } } \ No newline at end of file From cf9a9ab6b651090dd9cc8a1d0d2fbe22cb849e3e Mon Sep 17 00:00:00 2001 From: Filipe Oliveira Date: Tue, 21 Jul 2026 13:26:31 +0100 Subject: [PATCH 2/4] Preserve null in setPaused(), add wrapupTime-only test coverage setPaused() cast every input to bool, so setPaused(null) silently became setPaused(false) instead of unsetting the field like the constructor's $paused = null does. Also adds the wrapupTime-only cascading-null case flagged as untested. --- src/Clearvox/Asterisk/Queue/Member.php | 4 ++-- tests/Clearvox/Asterisk/Queue/MemberTest.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Clearvox/Asterisk/Queue/Member.php b/src/Clearvox/Asterisk/Queue/Member.php index 870f9c4..c2f1639 100644 --- a/src/Clearvox/Asterisk/Queue/Member.php +++ b/src/Clearvox/Asterisk/Queue/Member.php @@ -160,12 +160,12 @@ public function getPaused() } /** - * @param boolean $paused + * @param boolean|null $paused Null unsets (omits the field), matching the constructor. * @return Member */ public function setPaused($paused) { - $this->paused = (boolean)$paused; + $this->paused = is_null($paused) ? null : (boolean)$paused; return $this; } diff --git a/tests/Clearvox/Asterisk/Queue/MemberTest.php b/tests/Clearvox/Asterisk/Queue/MemberTest.php index 719cdc1..88a24b7 100644 --- a/tests/Clearvox/Asterisk/Queue/MemberTest.php +++ b/tests/Clearvox/Asterisk/Queue/MemberTest.php @@ -68,4 +68,23 @@ public function testToStringWithAllFields() $this->member->toString() ); } + + public function testToStringWithWrapupTimeOnly() + { + $this->member->setWrapupTime(30); + + $this->assertEquals( + 'member => Local/1000,,,,,30', + $this->member->toString() + ); + } + + public function testSetPausedNullUnsetsTheField() + { + $this->member->setPaused(true); + $this->member->setPaused(null); + + $this->assertNull($this->member->getPaused()); + $this->assertEquals('member => Local/1000', $this->member->toString()); + } } \ No newline at end of file From e90002f64d2fecf23efda9b7721368f5b5302681 Mon Sep 17 00:00:00 2001 From: filip3oliveira Date: Tue, 21 Jul 2026 13:45:31 +0100 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/Clearvox/Asterisk/Queue/Member.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Clearvox/Asterisk/Queue/Member.php b/src/Clearvox/Asterisk/Queue/Member.php index c2f1639..6e311fe 100644 --- a/src/Clearvox/Asterisk/Queue/Member.php +++ b/src/Clearvox/Asterisk/Queue/Member.php @@ -29,12 +29,12 @@ class Member protected $ringInUse; /** - * @var int + * @var int|null */ protected $wrapupTime; /** - * @var bool + * @var bool|null */ protected $paused; @@ -134,7 +134,7 @@ public function setRingInUse($ringInUse) } /** - * @return null + * @return int|null */ public function getWrapupTime() { @@ -142,7 +142,7 @@ public function getWrapupTime() } /** - * @param null $wrapupTime + * @param int|null $wrapupTime * @return Member */ public function setWrapupTime($wrapupTime) @@ -152,7 +152,7 @@ public function setWrapupTime($wrapupTime) } /** - * @return null + * @return bool|null */ public function getPaused() { From 14ff417a275e577963984f09acacf13adb6eb2c7 Mon Sep 17 00:00:00 2001 From: filip3oliveira Date: Tue, 21 Jul 2026 13:56:34 +0100 Subject: [PATCH 4/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/Clearvox/Asterisk/Queue/Member.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Clearvox/Asterisk/Queue/Member.php b/src/Clearvox/Asterisk/Queue/Member.php index 6e311fe..4f8e3c0 100644 --- a/src/Clearvox/Asterisk/Queue/Member.php +++ b/src/Clearvox/Asterisk/Queue/Member.php @@ -52,8 +52,8 @@ public function __construct( $this->memberName = $memberName; $this->stateInterface = $stateInterface; $this->ringInUse = $ringInUse; - $this->wrapupTime = $wrapupTime; - $this->paused = $paused; + $this->wrapupTime = is_null($wrapupTime) ? null : (int)$wrapupTime; + $this->paused = is_null($paused) ? null : (boolean)$paused; } public function getInterface()