Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit 17745ef

Browse files
authored
Merge pull request #53 from Renegade334/queue-filter-hotfix
Do not filter non-empty IRC command parameters which cast to boolean false
2 parents fb7525d + 336179b commit 17745ef

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/EventQueue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function queueRequest(UserEventInterface $event, $command, array $para
134134
{
135135
$event->setPrefix($this->prefix);
136136
$event->setCommand($command);
137-
$event->setParams(array_filter($params));
137+
$event->setParams(array_filter($params, 'strlen'));
138138
$this->queue->insert($event, $this->getPriority($command, $params));
139139
}
140140

tests/EventQueueTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,27 @@ public function testNonDestructiveIteration()
251251

252252
$this->assertEquals([ $event ], $contents);
253253
}
254+
255+
/**
256+
* Tests that non-empty parameter strings are not truncated.
257+
*/
258+
public function testRequestFilter()
259+
{
260+
$this->assertNull($this->queue->extract());
261+
262+
$this->queue->ircMode('#test', '+n', '');
263+
$this->queue->ircPrivmsg('TestUser', '0');
264+
265+
$event = $this->queue->extract();
266+
$this->assertInstanceOf('\Phergie\Irc\Event\EventInterface', $event);
267+
$this->assertEquals('MODE', $event->getCommand());
268+
$this->assertEquals([ '#test', '+n' ], $event->getParams());
269+
270+
$event = $this->queue->extract();
271+
$this->assertInstanceOf('\Phergie\Irc\Event\EventInterface', $event);
272+
$this->assertEquals('PRIVMSG', $event->getCommand());
273+
$this->assertEquals([ 'TestUser', '0' ], $event->getParams());
274+
275+
$this->assertNull($this->queue->extract());
276+
}
254277
}

0 commit comments

Comments
 (0)