|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-10-22 12:25 UTC] curt@php.net
[2005-10-23 00:10 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 16:00:01 2025 UTC |
Description: ------------ When creating a PDO object when using the uri invocation new PDO('uri:file:///path/to/file'); Ends up failing, because the uri passed to dsn_from_uri() includes 'uri:', which ends up being an invalid stream schema passed to php stream wrappers. Reproduce code: --------------- <?php try { $dbh = new PDO('uri:file:///path/to/file'); } catch (Exception $e) { die($e); } Patch (works with pecl, php51 and head): Index: ext/pdo/pdo_dbh.c =================================================================== RCS file: /repository/php-src/ext/pdo/pdo_dbh.c,v retrieving revision 1.82.2.11 diff -u -r1.82.2.11 pdo_dbh.c --- ext/pdo/pdo_dbh.c 3 Oct 2005 23:27:26 -0000 1.82.2.11 +++ ext/pdo/pdo_dbh.c 12 Oct 2005 20:40:33 -0000 @@ -252,7 +252,7 @@ if (!strncmp(data_source, "uri:", sizeof("uri:")-1)) { /* the specified URI holds connection details */ - data_source = dsn_from_uri(data_source, alt_dsn, sizeof(alt_dsn) TSRMLS_CC); + data_source = dsn_from_uri(data_source + (sizeof("uri:")-1), alt_dsn, sizeof(alt_dsn) TSRMLS_CC); if (!data_source) { zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "invalid data source URI"); ZVAL_NULL(object);