php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56608 Using uri: to specify location of connections details fails
Submitted: 2005-10-21 21:47 UTC Modified: 2005-10-23 00:10 UTC
From: curt@php.net Assigned: wez (profile)
Status: Closed Package: PDO (PECL)
PHP Version: Irrelevant OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: curt@php.net
New email:
PHP Version: OS:

 

 [2005-10-21 21:47 UTC] curt@php.net
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);



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-22 12:25 UTC] curt@php.net
Here is the patch without the line wrapping:
http://zirzow.dyndns.org/patches/pdo_dbh.fix_uri_invocation.php51.patch
 [2005-10-23 00:10 UTC] wez@php.net
Fixed in CVS; thanks for the patch Curt :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC