Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0fbc919
let's try running our testsuite without sudo
Tyrael Aug 23, 2015
c2500a3
FIx bug #70433 - Uninitialized pointer in phar_make_dirstream when zi…
smalyshev Sep 29, 2015
e7df5b8
5.5.31 now
Sep 30, 2015
7ea11a9
Fixed bug #70681
nikic Oct 9, 2015
d116dfd
Fixed bug #70685
nikic Oct 10, 2015
fb21f91
prepare for 5.6.15RC1
Tyrael Oct 14, 2015
0ffb00c
Fixed bug #70828 (php-fpm 5.6 with opcache crashes when referencing a…
laruence Nov 2, 2015
eb5be90
Fixed bug #70852 Segfault getting NULL offset of an ArrayObject.
reeze Nov 5, 2015
5d08dc5
propare for 5.6.16RC1
Tyrael Nov 11, 2015
ee93f38
Fixed bug #68077 (LOAD DATA LOCAL INFILE / open_basedir restriction)
laruence Nov 16, 2015
ac98d43
Fixed bug #70944 (try{ } finally{} can create infinite chains of exce…
laruence Nov 20, 2015
564ecf7
Fixed bug #70957 (self::class can not be resolved with reflection for…
laruence Nov 23, 2015
1bc2137
Fixed bug #70958 (Invalid opcode while using ::class as trait method …
laruence Nov 23, 2015
26cfb82
5.6.18 will be next
Tyrael Dec 10, 2015
6f8b0d6
Fixed bug #71127 (Define in auto_prepend_file is overwrite)
laruence Dec 17, 2015
cea953f
Fix #70720
Dec 22, 2015
b5107b8
Extended zend_throw_exception_ex and created a pdo_throw_exception_ex…
kalaspuffar Oct 9, 2015
8ce3f1b
Added testcase for Bug #64705errorInfo property of PDOException is nu…
kalaspuffar Oct 9, 2015
6a189e7
Changed all drivers so they use pdo_throw_exception_ex instead of zen…
kalaspuffar Oct 9, 2015
2a47c62
Change so we set the code value to a long and keep the state in the e…
kalaspuffar Oct 12, 2015
4ddbca8
Change to check for a number as code for the exception
kalaspuffar Oct 12, 2015
04ab1ff
Removed compile error
kalaspuffar Oct 12, 2015
089360b
Try to resolve the TSRMLS_CC issues
kalaspuffar Oct 12, 2015
a3e479a
Changing the test case trying to get PDOTest::factory() to throw an e…
kalaspuffar Oct 12, 2015
6e9510b
Removed exception_ce parameter of pdo_throw_exception_ex not required…
kalaspuffar Oct 19, 2015
2b63160
Clean up rebase conflicts.
kalaspuffar Apr 11, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions ext/pdo/pdo_dbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,43 @@

static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_DC);

PDO_API zval *pdo_throw_exception_ex(pdo_error_type *pdo_err, long code TSRMLS_DC, const char *format, ...) /* {{{ */
{
va_list arg;
char *message;
zval *zexception, *info;
zend_class_entry *exception_ce;

va_start(arg, format);
zend_vspprintf(&message, 0, format, arg);
va_end(arg);

exception_ce = php_pdo_get_exception();

MAKE_STD_ZVAL(zexception);
object_init_ex(zexception, exception_ce);

zend_update_property_string(exception_ce, zexception, "message", sizeof("message")-1, message TSRMLS_CC);
zend_update_property_long(exception_ce, zexception, "code", sizeof("code")-1, code TSRMLS_CC);

MAKE_STD_ZVAL(info);
array_init(info);

add_next_index_string(info, *pdo_err, 1);
add_next_index_long(info, code);
add_next_index_string(info, message, 1);

efree(message);

zend_update_property(exception_ce, zexception, "errorInfo", sizeof("errorInfo")-1, info TSRMLS_CC);
zval_ptr_dtor(&info);

zend_throw_exception_internal(zexception TSRMLS_CC);

return zexception;
}
/* }}} */

void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate, const char *supp TSRMLS_DC) /* {{{ */
{
pdo_error_type *pdo_err = &dbh->error_code;
Expand Down
1 change: 1 addition & 0 deletions ext/pdo/php_pdo_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "php_pdo_driver.h"

PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC);
PDO_API zval *pdo_throw_exception_ex(pdo_error_type *pdo_err, long code TSRMLS_DC, const char *format, ...);

#define PDO_DBH_CLEAR_ERR() do { \
strlcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
Expand Down
47 changes: 47 additions & 0 deletions ext/pdo/tests/bug_64705.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
--TEST--
PDO Common: Bug #64705 errorInfo property of PDOException is null when PDO::__construct() fails
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded('pdo')) die('skip');
$dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
require_once $dir . 'pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
if(getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';

if(substr(getenv('PDOTEST_DSN'), 0, strlen('sqlite')) === 'sqlite') {
putenv('PDOTEST_DSN=sqlite:.');
} else if(substr(getenv('PDOTEST_DSN'), 0, strlen('odbc')) === 'odbc') {
putenv('PDOTEST_DSN=odbc:DRIVER=ibm-db2;HOSTNAME=localhost;PORT=50000;DATABASE=bad_database;PROTOCOL=TCPIP;UID=bad_user;PWD=bad_password;');
} else if(substr(getenv('PDOTEST_DSN'), 0, strlen('pgsql')) === 'pgsql') {
putenv('PDOTEST_DSN=pgsql:host=localhost;port=54321;dbname=bad_database_gDm9VNHRkIxQ');
}

putenv('PDOTEST_USER=bad_username_gDm9VNHRkIxQ');
putenv('PDOTEST_PASS=bad_password_gDm9VNHRkIxQ');

try {
$db = PDOTest::factory();
} catch (\PDOException $e) {
var_dump($e->errorInfo);
var_dump($e->getCode());
var_dump($e->getMessage());
}
?>
===DONE===
--EXPECTF--
array(3) {
[0]=>
string(5) "%s"
[1]=>
int(%d)
[2]=>
string(%d) "SQLSTATE[%s]%A"
}
int(%d)
string(%d) "SQLSTATE[%s]%A"
===DONE===
51 changes: 26 additions & 25 deletions ext/pdo_dblib/dblib_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
{
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
pdo_dblib_stmt *S = ecalloc(1, sizeof(*S));

S->H = H;
stmt->driver_data = S;
stmt->methods = &dblib_stmt_methods;
Expand All @@ -119,7 +119,7 @@ static long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM
if (FAIL == dbsqlexec(H->link)) {
return -1;
}

resret = dbresults(H->link);

if (resret == FAIL) {
Expand Down Expand Up @@ -165,23 +165,23 @@ static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
*q++ = '\'';
*q++ = '\0';
*quotedlen = l+1;

return 1;
}

static int pdo_dblib_transaction_cmd(const char *cmd, pdo_dbh_t *dbh TSRMLS_DC)
{
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
RETCODE ret;

if (FAIL == dbcmd(H->link, cmd)) {
return 0;
}

if (FAIL == dbsqlexec(H->link)) {
return 0;
}

return 1;
}

Expand All @@ -200,33 +200,33 @@ static int dblib_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
return pdo_dblib_transaction_cmd("ROLLBACK TRANSACTION", dbh TSRMLS_CC);
}

char *dblib_handle_last_id(pdo_dbh_t *dbh, const char *name, unsigned int *len TSRMLS_DC)
char *dblib_handle_last_id(pdo_dbh_t *dbh, const char *name, unsigned int *len TSRMLS_DC)
{
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;

RETCODE ret;
char *id = NULL;

/*
/*
* Would use scope_identity() but it's not implemented on Sybase
*/

if (FAIL == dbcmd(H->link, "SELECT @@IDENTITY")) {
return NULL;
}

if (FAIL == dbsqlexec(H->link)) {
return NULL;
}

ret = dbresults(H->link);
if (ret == FAIL || ret == NO_MORE_RESULTS) {
dbcancel(H->link);
return NULL;
}

ret = dbnextrow(H->link);

if (ret == FAIL || ret == NO_MORE_ROWS) {
dbcancel(H->link);
return NULL;
Expand All @@ -239,7 +239,7 @@ char *dblib_handle_last_id(pdo_dbh_t *dbh, const char *name, unsigned int *len T

id = emalloc(32);
*len = dbconvert(NULL, (dbcoltype(H->link, 1)) , (dbdata(H->link, 1)) , (dbdatlen(H->link, 1)), SQLCHAR, id, (DBINT)-1);

dbcancel(H->link);
return id;
}
Expand Down Expand Up @@ -267,7 +267,7 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
pdo_dblib_db_handle *H;
int i, nvars, nvers, ret = 0;
int *val;

const pdo_dblib_keyval tdsver[] = {
{"4.2",DBVERSION_42}
,{"4.6",DBVERSION_46}
Expand All @@ -283,9 +283,11 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
#endif
,{"10.0",DBVERSION_100}
,{"auto",0} /* Only works with FreeTDS. Other drivers will bork */

};


nvers = sizeof(tdsver)/sizeof(tdsver[0]);

struct pdo_data_src_parser vars[] = {
{ "charset", NULL, 0 }
,{ "appname", "PHP " PDO_DBLIB_FLAVOUR, 0 }
Expand All @@ -294,10 +296,9 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
,{ "secure", NULL, 0 } /* DBSETLSECURE */
,{ "version", NULL, 0 } /* DBSETLVERSION */
};

nvars = sizeof(vars)/sizeof(vars[0]);
nvers = sizeof(tdsver)/sizeof(tdsver[0]);


php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, nvars);

H = pecalloc(1, sizeof(*H), dbh->is_persistent);
Expand All @@ -310,21 +311,21 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_

DBERRHANDLE(H->login, (EHANDLEFUNC) error_handler);
DBMSGHANDLE(H->login, (MHANDLEFUNC) msg_handler);

if(vars[5].optval) {
for(i=0;i<nvers;i++) {
if(strcmp(vars[5].optval,tdsver[i].key) == 0) {
if(FAIL==dbsetlversion(H->login, tdsver[i].value)) {
pdo_raise_impl_error(dbh, NULL, "HY000", "PDO_DBLIB: Failed to set version specified in connection string." TSRMLS_CC);
pdo_raise_impl_error(dbh, NULL, "HY000", "PDO_DBLIB: Failed to set version specified in connection string." TSRMLS_CC);
goto cleanup;
}
break;
}
}

if (i==nvers) {
printf("Invalid version '%s'\n", vars[5].optval);
pdo_raise_impl_error(dbh, NULL, "HY000", "PDO_DBLIB: Invalid version specified in connection string." TSRMLS_CC);
pdo_raise_impl_error(dbh, NULL, "HY000", "PDO_DBLIB: Invalid version specified in connection string." TSRMLS_CC);
goto cleanup; /* unknown version specified */
}
}
Expand All @@ -340,7 +341,7 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
goto cleanup;
}
}

#if !PHP_DBLIB_IS_MSSQL
if (vars[0].optval) {
DBSETLCHARSET(H->login, vars[0].optval);
Expand Down Expand Up @@ -398,7 +399,7 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
dbh->driver_data = H;

if (!ret) {
zend_throw_exception_ex(php_pdo_get_exception(), DBLIB_G(err).dberr TSRMLS_CC,
pdo_throw_exception_ex(DBLIB_G(err).sqlstate, DBLIB_G(err).dberr TSRMLS_CC,
"SQLSTATE[%s] %s (severity %d)",
DBLIB_G(err).sqlstate,
DBLIB_G(err).dberrstr,
Expand Down
Loading