Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-9518

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

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.7-PL1
    • Fix Version/s: 3.0.8-RC1
    • Labels:
      None
    • Environment:
      PHP 5.2.10-2ubuntu6.4 with Suhosin-Patch 0.9.7
      PostgreSQL 8.4.2

      Description

      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)
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            bantu Andreas Fischer
            Reporter:
            bantu Andreas Fischer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development