Welcome Guest, Not a member yet? Register   Sign In
Bug in postgre drivers..
#1

Hi..
 When setting up connect_timeout to postgres I noticed a bug that would cause an error..

Lines 132 to 138 of system\database\drivers\postgre\postgre_driver.php are as follows
PHP Code:
foreach (array('connect_timeout''options''sslmode''service') as $key)
{
    if (isset(
$this->$key) && is_string($this->key) && $this->key !== '')
    {
        
$this->dsn .= $key."='".$this->key."' ";
    }


so if you put a
'connect_timeout' => '5',
into your database config the driver will fail.

Replacing $this->key with $this->$key will fix the issue. For reference...
PHP Code:
foreach (array('connect_timeout''options''sslmode''service') as $key)
{
    if (isset(
$this->$key) && is_string($this->$key) && $this->$key !== '')
    {
        
$this->dsn .= $key."='".$this->$key."' ";
    }


Just in case anyone else notices this issue.
Reply
#2

(This post was last modified: 04-27-2017, 11:20 PM by Paradinight.)

(04-27-2017, 02:42 AM)hugo_rune Wrote: Hi..
 When setting up connect_timeout to postgres I noticed a bug that would cause an error..

Lines 132 to 138 of system\database\drivers\postgre\postgre_driver.php are as follows
PHP Code:
foreach (array('connect_timeout''options''sslmode''service') as $key)
{
 if (isset(
$this->$key) && is_string($this->key) && $this->key !== '')
 {
 
$this->dsn .= $key."='".$this->key."' ";
 }


so if you put a
'connect_timeout' => '5',
into your database config the driver will fail.

Replacing $this->key with $this->$key will fix the issue. For reference...
PHP Code:
foreach (array('connect_timeout''options''sslmode''service') as $key)
{
 if (isset(
$this->$key) && is_string($this->$key) && $this->$key !== '')
 {
 
$this->dsn .= $key."='".$this->$key."' ";
 }


Just in case anyone else notices this issue.

https://github.com/bcit-ci/CodeIgniter/b...r.php#L131
PHP Code:
/* We don't have these options as elements in our standard configuration
* array, but they might be set by parse_url() if the configuration was
* provided via string. Example:
*
* postgre://username:password@localhost:5432/database?connect_timeout=5&sslmode=1
*/
foreach (array('connect_timeout''options''sslmode''service') as $key)
{
    if (isset(
$this->$key) && is_string($this->$key) && $this->$key !== '')
    {
        
$this->dsn .= $key."='".$this->$key."' ";
    }

I do not know why it was wrong in you code, but on the git repo is it right.

edit:
it was fixed in the 3.1.4 Version. https://github.com/bcit-ci/CodeIgniter/issues/5057
Update to the current version.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB