Skip to content

No DB server port or socket from configuration.php set in pdo.php #73

@reetp

Description

@reetp

I discovered that this file:

admin/plugins/restapi/includes/pdo.php

does not check the server port specified in the config file.

My quick fix was:

--- pdo.php.old	2024-01-05 18:38:56.724455609 +0100
+++ pdo.php	2024-01-05 18:07:00.221162380 +0100
@@ -15,7 +15,8 @@
         $dbuser = $GLOBALS['database_user'];
         $dbpass = $GLOBALS['database_password'];
         $dbname = $GLOBALS['database_name'];
-        $dbh = new \PDO("mysql:host=$dbhost;dbname=$dbname;charset=UTF8;", $dbuser, $dbpass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8';"));
+        $dbport = $GLOBALS['database_port'];
+        $dbh = new \PDO("mysql:host=$dbhost;dbname=$dbname;port=$dbport;charset=UTF8;", $dbuser, $dbpass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8';"));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
 
         return $dbh;

It also doesn't appear to use a socket either even if specified in the config file eg this format:

$dsn = 'mysql:dbname=testdb;unix_socket=/path/to/socket';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions