-
Notifications
You must be signed in to change notification settings - Fork 439
Closed
Labels
Description
Hello there, I got some troubles using a DSN string to configure my connection to rabbitMQ with the default %2f vhost name
Expected Behavior
<?php
include('vendor/autoload.php');
use Enqueue\AmqpTools\ConnectionConfig;
$dsn = "amqp://guest:guest@localhost:5672/%2f";
$config = (new ConnectionConfig($dsn))->parse();
var_dump($config->getVhost()); // string(1) "/"Actual Behavior
<?php
include('vendor/autoload.php');
use Enqueue\AmqpTools\ConnectionConfig;
$dsn = "amqp://guest:guest@localhost:5672/%2f";
$config = (new ConnectionConfig($dsn))->parse();
var_dump($config->getVhost()); // string(0) ""Steps to Reproduce the Problem
composer require enqueue/enqueue enqueue/amqp-lib- execute the given piece of code
Version:
| sw | vers |
|---|---|
| enqueue/amqp-lib | 0.9.2 |
| enqueue/amqp-tools | 0.9.2 |
| enqueue/dsn | 0.9.2 |
| enqueue/enqueue | 0.9.3 |
| enqueue/null | 0.9.2 |
| PHP | 7.2.12 |
I think the problem is here:
| 'vhost' => null !== $dsn->getPath() ? ltrim($dsn->getPath(), '/') : null, |
Since the given vhost is %f the path is urldecoded to // and the ltrim command remove everything, leaving an empty string.
I tried to patch (with success) like this:
'vhost' => null !== ($path = $dsn->getPath()) ?
(0 === strpos($path, '/') ? substr($path, 1) : $path)
: null,Is there anything I'm missing about this kind of configuration?