Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-9518

Postgres DBAL does not correctly create a new database connection when passing $new_link as true

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.0.8-RC1
    • 3.0.7-PL1
    • None
    • PHP 5.2.10-2ubuntu6.4 with Suhosin-Patch 0.9.7
      PostgreSQL 8.4.2

      Currently the postgres database abstraction layer directly passes the boolean value $new_link from dbal::sql_connect to the pg_connect() function.

      The manual however says that the second parameter has to be an integer and that the constant PGSQL_CONNECT_FORCE_NEW has to be passed to force a new connection.
      http://www.php.net/manual/en/function.pg-connect.php

      However, also passing 0 as the second paramater seems to cause problems.

      The following tests cause incorrect behaviour on my setup.

      var_dump(pg_connect($connect_string, false));	// resource(1, pgsql link)
      var_dump(pg_connect($connect_string, false));	// resource(1, pgsql link)
      var_dump(pg_connect($connect_string, true));	// resource(2, pgsql link)
      var_dump(pg_connect($connect_string, true));	// resource(2, pgsql link) <--
      var_dump(pg_connect($connect_string, false));	// resource(3, pgsql link) <--
      var_dump(pg_connect($connect_string, false));	// resource(3, pgsql link)
      

      var_dump(pg_connect($connect_string, 0));		// resource(1, pgsql link)
      var_dump(pg_connect($connect_string, 0));		// resource(1, pgsql link)
      var_dump(pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW));	// resource(2, pgsql link)
      var_dump(pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW));	// resource(3, pgsql link)
      var_dump(pg_connect($connect_string, 0));		// resource(4, pgsql link) <--
      var_dump(pg_connect($connect_string, 0));		// resource(4, pgsql link)
      

      The following generated the intended behaviour

      var_dump(pg_connect($connect_string));		// resource(1, pgsql link)
      var_dump(pg_connect($connect_string));		// resource(1, pgsql link)
      var_dump(pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW));	// resource(2, pgsql link)
      var_dump(pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW));	// resource(3, pgsql link)
      var_dump(pg_connect($connect_string));		// resource(3, pgsql link)
      var_dump(pg_connect($connect_string));		// resource(3, pgsql link)
      

            bantu Andreas Fischer [X] (Inactive)
            bantu Andreas Fischer [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: