PDO MySQL default socket bug - Proof of concept

There's been a long-standing bug with PHP's PDO MySQL driver where the pdo_mysql.default_socket configuration directive is completely ignored on Unix systems.

Operating environment

PHP Version
5.3.14
mysql.default_socket
/var/run/mysqld/mysqld.sock
mysqli.default_socket
/var/run/mysqld/mysqld.sock
pdo_mysql.default_socket
/var/run/mysqld/mysqld.sock

Connection Attempt #1

Attempting to create a connection using the following:

$db = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'pdotest', 'pdotest');

Result

Connection Successful

Connected to MySQL server version 5.1.37-1ubuntu5.5

Connection Attempt #2

Attempting to create a connection using the following:

$sock = ini_get('pdo_mysql.default_socket');
$db = new PDO("mysql:host=localhost;dbname=test;charset=utf8;unix_socket=$sock", 'pdotest', 'pdotest');

Result

Connection Successful

Connected to MySQL server version 5.1.37-1ubuntu5.5