• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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
(04-27-2017, 03: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:[email protected]: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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.