YiiAMQP icon indicating copy to clipboard operation
YiiAMQP copied to clipboard

Do not get settings from main.php by default.

Open anmishael opened this issue 10 years ago • 2 comments

There is a bug in YiiAMQP\Client which do not allow to get settings from config file by default. In getConnectionConfig method there is $this->_connectionConfig = array( ... . Which add default hardcoded settings to the future connection. But we have already settings in public $server var. My suggestion is using main.php settings there:

public function getConnectionConfig()
    {
        if ($this->_connectionConfig === array()) {
            if($this->server) // Check if $server is not null etc.
                $this->_connectionConfig = $this->server; // Use it
            else $this->_connectionConfig = array(
                        'host' => 'localhost',
                        'port' => 5672,
                        'user' => 'guest',
                        'password' => 'guest',
                        'vhost' => '/',
                    );
        }
        return $this->_connectionConfig;
    }

anmishael avatar Nov 07 '14 14:11 anmishael

Thanks an Michael

Would you like to open a PR with this and I review?

Sent from my iPhone

On 8 Nov 2014, at 01:14, anmishael [email protected] wrote:

There is a bug in YiiAMQP\Client which do not allow to get settings from config file by default. In getConnectionConfig method there is $this->_connectionConfig = array( ... . Which add default hardcoded settings to the future connection. But we have already settings in public $server var. My suggestion is using main.php settings there: public function getConnectionConfig() { if ($this->_connectionConfig === array()) { if($this->server) // Check if $server is not null etc. $this->_connectionConfig = $this->server; // Use it else $this->_connectionConfig = array( 'host' => 'localhost', 'port' => 5672, 'user' => 'guest', 'password' => 'guest', 'vhost' => '/', ); } return $this->_connectionConfig; }

— Reply to this email directly or view it on GitHub.

mteichtahl avatar Nov 07 '14 14:11 mteichtahl

Add suggestion as patch-1

anmishael avatar Nov 07 '14 15:11 anmishael