phergie / phergie-irc-bot-react

IRC bot built on React
BSD 2-Clause "Simplified" License
81 stars 26 forks source link

Do not filter non-empty IRC command parameters which cast to boolean false #53

Closed Renegade334 closed 5 years ago

Renegade334 commented 5 years ago
EventQueue::ircPrivmsg('#channel', '0');

currently yields:

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function Phergie\Irc\Client\React\WriteStream::ircPrivmsg(), 1 passed and exactly 2 expected in /truncated/vendor/phergie/phergie-irc-client-react/src/WriteStream.php:432
Stack trace:
#0 [internal function]: Phergie\Irc\Client\React\WriteStream->ircPrivmsg('#channel')
#1 /truncated/vendor/phergie/phergie-irc-bot-react/src/Bot.php(533): call_user_func_array(Array, Array)
#2 /truncated/vendor/phergie/phergie-irc-bot-react/src/Bot.php(498): Phergie\Irc\Bot\React\Bot->processOutgoingEvents(Object(Phergie\Irc\Connection), Object(Phergie\Irc\Client\React\WriteStream))
#3 /truncated/vendor/phergie/phergie-irc-bot-react/src/Bot.php(466): Phergie\Irc\Bot\React\Bot->processClientEvent('irc.sent', Array, Object(Phergie\Irc\Connection), Object(Phergie\Irc\Client\React\WriteStream))
#4 /truncated/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(123): Phergie\Irc\Bot\React\Bot->Phergie\Irc\Bot\React\{closure}(' in /truncated/vendor/phergie/phergie-irc-client-react/src/WriteStream.php on line 432

due to the following line in EventQueue::queueRequest:

$event->setParams(array_filter($params));

which filters any string that casts to boolean false.

Using the callback strlen mitigates against this, by filtering out empty variables and zero-length strings, but not '0'.

svpernova09 commented 5 years ago

Thanks for the fix!