?
avatar Joe136
Joe136
22 Aug 2014

PostgreSQL-Driver doesn't support user defined ports

There is no definition of a port in the dsn string (used for pg_connect): https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/database/driver/postgresql.php#L119

I have compared it with ownCloud (where I know it works): https://github.com/owncloud/core/blob/master/lib/private/setup/postgresql.php#L21

I have (not well enough) tested the "// Fix database with port connection"-fix from ownCloud and it works with the default "localhost:1234" syntax. (But I don't know what happen if "port=false".)

      // Fix database with port connection
      $e_host = $this->options['host'];
      if(strpos($e_host, ':')) {
         list($e_host, $port)=explode(':', $e_host, 2);
      } else {
         $port=false;
      }

      // Build the DSN for the connection.
      $dsn = "host='$e_host' port='$port' dbname={$this->options['database']} user={$this->options['user']} password={$this->options['password']}";

Maybe someone finds a better solution.

avatar Joe136 Joe136 - open - 22 Aug 2014
avatar mbabker
mbabker - comment - 22 Aug 2014

You're on the right track I'd say. For MySQLi, we do something similar to extract the port out (see https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/database/driver/mysqli.php#L103-L165). Would you be interested in sending a pull request?

avatar Joe136 Joe136 - reference | - 23 Aug 14
avatar Joe136
Joe136 - comment - 23 Aug 2014

Okay, I've sended a pull request #4165. It's the code described above.

avatar brianteeman brianteeman - change - 23 Aug 2014
The description was changed
avatar brianteeman brianteeman - change - 25 Aug 2014
Category Postgresql
avatar brianteeman
brianteeman - comment - 27 Aug 2014

I am closing this in favour of #4165 so the conversation is in one place

avatar brianteeman brianteeman - change - 27 Aug 2014
The description was changed
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-08-27 10:19:54
avatar brianteeman brianteeman - close - 27 Aug 2014
avatar zero-24 zero-24 - close - 27 Aug 2014
avatar zero-24 zero-24 - change - 7 Jul 2015
Labels Added: ?

Add a Comment

Login with GitHub to post a comment