Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL support for non-standard ports #4152

Closed
Joe136 opened this issue Aug 22, 2014 · 3 comments
Closed

PostgreSQL support for non-standard ports #4152

Joe136 opened this issue Aug 22, 2014 · 3 comments

Comments

@Joe136
Copy link

Joe136 commented Aug 22, 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.

@mbabker
Copy link
Contributor

mbabker commented Aug 22, 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?

@Joe136
Copy link
Author

Joe136 commented Aug 23, 2014

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

@brianteeman
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants