CMS should respect MySQL on custom port number for PDO

Bug #1342655 reported by Alex Harrington
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Xibo
Fix Released
Low
Dan Garner

Bug Description

Just after installation of Xibo Server when I went to http://xibo_server_location I got:
"Database connection problem. SQLSTATE[HY000] [2005] Unknown MySQL server host 'HOST:PORT' (1)"

I am using not standard port for my MySQL database host connection and I have defined that during Xibo Server installation when I was asked for DB host.

I digged down to the code and resolved my issue by correcting PDOConnect class - instead of constructing PDO object using:
  self::$conn = new PDO('mysql:host=' . $dbhost . ';dbname=' . $dbname . ';', $dbuser, $dbpass);
I changed it to:
  $hoststring = split(":", $dbhost, 2);
  self::$conn = new PDO('mysql:host=' . $hoststring[0] . ';port=' . $hoststring[1] . ';dbname=' . $dbname . ';', $dbuser, $dbpass);

Suggestion: in class PDOConnect during creation of PDO object $dbhost shall be checked if there is port included and if so it shall be used in PDO object constructor accordingly to http://php.net/manual/en/ref.pdo-mysql.connection.php.

Related branches

Changed in xibo:
milestone: none → 1.6.3
status: New → Confirmed
Dan Garner (dangarner)
Changed in xibo:
assignee: nobody → Dan Garner (dangarner)
importance: Undecided → Low
milestone: 1.6.3 → 1.6.2
status: Confirmed → Fix Committed
Dan Garner (dangarner)
Changed in xibo:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.