Skip to content

Commit

Permalink
Merge pull request #110 from zf1s/fix-zend-queue-php8
Browse files Browse the repository at this point in the history
[zend-queue] prevent TypeError on md5 of non-string message
  • Loading branch information
falkenhawk authored Oct 1, 2021
2 parents 12e0967 + 5ebe6f2 commit 55f1b5e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/zend-queue/library/Zend/Queue/Adapter/Activemq.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ public function send($message, Zend_Queue $queue=null)
$queue = $this->_queue;
}

$message = (string)$message;

$frame = $this->_client->createFrame();
$frame->setCommand('SEND');
$frame->setHeader('destination', $queue->getName());
Expand All @@ -312,7 +314,7 @@ public function send($message, Zend_Queue $queue=null)
$frame->setHeader('persistent', $this->_options['driverOptions']['persistent']);
}

$frame->setBody((string) $message);
$frame->setBody($message);
$this->_client->send($frame);

$data = array(
Expand Down
4 changes: 4 additions & 0 deletions packages/zend-queue/library/Zend/Queue/Adapter/Array.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ public function send($message, Zend_Queue $queue=null)
throw new Zend_Queue_Exception('Queue does not exist:' . $queue->getName());
}

if (!is_string($message)) {
throw new Zend_Queue_Exception('$message must be a string');
}

// create the message
$data = array(
'message_id' => md5(uniqid(rand(), true)),
Expand Down
2 changes: 1 addition & 1 deletion packages/zend-queue/library/Zend/Queue/Adapter/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public function send($message, Zend_Queue $queue = null)
$msg->queue_id = $this->getQueueId($queue->getName());
$msg->created = time();
$msg->body = $message;
$msg->md5 = md5($message);
$msg->md5 = md5((string)$message);
// $msg->timeout = ??? @TODO

try {
Expand Down

0 comments on commit 55f1b5e

Please sign in to comment.