Bug #78347 [NEW]: wrong socket path when host field is empty

From: Date: Mon, 29 Jul 2019 12:03:55 +0000
Subject: Bug #78347 [NEW]: wrong socket path when host field is empty
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221987@lists.php.net to get a copy of this message
From: l dot fuerderer at gmail dot com Operating system: Arch Linux PHP version: 7.3.7 Package: PDO MySQL Bug Type: Bug Bug description:wrong socket path when host field is empty Description: ------------ In my Arch Linux I activated PDO MySql in the php.ini to connect to Mariadb: extension=pdo_mysql And I changed the socket path: pdo_mysql.default_socket=/run/mysqld/mysqld.sock When I connect to the database giving an empty hostname, PHP tries to connect to /tmp/mysql.sock ignoring the php.ini setting. (I saw this using strace) Test script: --------------- <?php // the following two lines work new \PDO("mysql:", "http", ""); new \PDO("mysql:host=localhost", "http", ""); // this line fails new \PDO("mysql:host=", "http", ""); Expected result: ---------------- Three successful connections, no output. Actual result: -------------- PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /srv/http/databases.php:7 Stack trace: #0 /srv/http/databases.php(7): PDO->__construct('mysql:host=', 'http', '') #1 {main} thrown in /srv/http/databases.php on line 7 -- Edit bug report at https://bugs.php.net/bug.php?id=78347&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78347&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78347&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78347&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=78347&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78347&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78347&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78347&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78347&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78347&r=support Expected behavior: https://bugs.php.net/fix.php?id=78347&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78347&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78347&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78347&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78347&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=78347&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78347&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78347&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78347&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78347&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78347&r=mysqlcfg

« previous php.bugs (#221987) next »