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

    XMLWordPrintable

Details

    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)
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: