diff options
Diffstat (limited to 'ext/pdo')
| -rwxr-xr-x | ext/pdo/pdo.c | 4 | ||||
| -rwxr-xr-x | ext/pdo/pdo_dbh.c | 38 | ||||
| -rw-r--r-- | ext/pdo/pdo_sql_parser.c | 8 | ||||
| -rw-r--r-- | ext/pdo/pdo_sql_parser.c.orig | 22 | ||||
| -rw-r--r-- | ext/pdo/pdo_sql_parser.re | 6 | ||||
| -rw-r--r-- | ext/pdo/pdo_sqlstate.c | 4 | ||||
| -rwxr-xr-x | ext/pdo/pdo_stmt.c | 31 | ||||
| -rwxr-xr-x | ext/pdo/php_pdo.h | 4 | ||||
| -rwxr-xr-x | ext/pdo/php_pdo_driver.h | 6 | ||||
| -rwxr-xr-x | ext/pdo/php_pdo_int.h | 4 | ||||
| -rw-r--r-- | ext/pdo/tests/bug_43130.phpt | 8 | ||||
| -rw-r--r-- | ext/pdo/tests/bug_43663.phpt | 22 | ||||
| -rw-r--r-- | ext/pdo/tests/bug_44159.phpt | 37 |
13 files changed, 148 insertions, 46 deletions
diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c index c19620115..2a55bf9a8 100755 --- a/ext/pdo/pdo.c +++ b/ext/pdo/pdo.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo.c,v 1.57.2.17.2.9 2007/07/23 11:53:58 jani Exp $ */ +/* $Id: pdo.c,v 1.57.2.17.2.10 2007/12/31 07:20:09 sebastian Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index e3d49f3c9..5d567741e 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_dbh.c,v 1.82.2.31.2.17 2007/09/12 18:26:49 iliaa Exp $ */ +/* $Id: pdo_dbh.c,v 1.82.2.31.2.22 2008/03/03 21:14:33 iliaa Exp $ */ /* The PDO Database Handle Class */ @@ -669,8 +669,17 @@ static PHP_METHOD(PDO, rollBack) static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_DC) /* {{{ */ { + +#define PDO_LONG_PARAM_CHECK \ + if (Z_TYPE_P(value) != IS_LONG && Z_TYPE_P(value) != IS_STRING && Z_TYPE_P(value) != IS_BOOL) { \ + pdo_raise_impl_error(dbh, NULL, "HY000", "attribute value must be an integer" TSRMLS_CC); \ + PDO_HANDLE_DBH_ERR(); \ + return FAILURE; \ + } \ + switch (attr) { case PDO_ATTR_ERRMODE: + PDO_LONG_PARAM_CHECK; convert_to_long(value); switch (Z_LVAL_P(value)) { case PDO_ERRMODE_SILENT: @@ -686,6 +695,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D return FAILURE; case PDO_ATTR_CASE: + PDO_LONG_PARAM_CHECK; convert_to_long(value); switch (Z_LVAL_P(value)) { case PDO_CASE_NATURAL: @@ -701,6 +711,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D return FAILURE; case PDO_ATTR_ORACLE_NULLS: + PDO_LONG_PARAM_CHECK; convert_to_long(value); dbh->oracle_nulls = Z_LVAL_P(value); return SUCCESS; @@ -714,6 +725,8 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D return FAILURE; } } + } else { + PDO_LONG_PARAM_CHECK; } convert_to_long(value); if (Z_LVAL_P(value) == PDO_FETCH_USE_DEFAULT) { @@ -724,6 +737,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D return SUCCESS; case PDO_ATTR_STRINGIFY_FETCHES: + PDO_LONG_PARAM_CHECK; convert_to_long(value); dbh->stringify = Z_LVAL_P(value) ? 1 : 0; return SUCCESS; @@ -815,9 +829,9 @@ static PHP_METHOD(PDO, setAttribute) { pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); long attr; - zval *value = NULL; + zval *value; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz!", &attr, &value)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz", &attr, &value)) { RETURN_FALSE; } @@ -978,7 +992,7 @@ static PHP_METHOD(PDO, errorInfo) pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC); if (ZEND_NUM_ARGS()) { - RETURN_FALSE; + WRONG_PARAM_COUNT; } PDO_CONSTRUCT_CHECK; @@ -1119,6 +1133,10 @@ static PHP_METHOD(PDO, getAvailableDrivers) { HashPosition pos; pdo_driver_t **pdriver; + + if (ZEND_NUM_ARGS()) { + WRONG_PARAM_COUNT; + } array_init(return_value); @@ -1273,12 +1291,18 @@ static union _zend_function *dbh_method_get( if (zend_hash_find(dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_DBH], lc_method_name, method_len+1, (void**)&fbc) == FAILURE) { - fbc = NULL; + if (std_object_handlers.get_method) { + fbc = std_object_handlers.get_method(object_pp, lc_method_name, method_len TSRMLS_CC); + } + if (!fbc) { + fbc = NULL; + } + goto out; } /* got it */ } - + out: efree(lc_method_name); return fbc; diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index 4aaa8973a..1913f0dc7 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -1,9 +1,9 @@ -/* Generated by re2c 0.11.0 on Mon Oct 29 18:36:37 2007 */ +/* Generated by re2c 0.11.0 on Mon Nov 26 16:10:28 2007 */ /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_sql_parser.c,v 1.35.2.6.2.13 2007/10/29 22:37:25 iliaa Exp $ */ +/* $Id: pdo_sql_parser.c,v 1.35.2.6.2.15 2007/12/31 07:20:09 sebastian Exp $ */ #include "php.h" #include "php_pdo_driver.h" @@ -73,7 +73,6 @@ yy4: yy5: yych = *++YYCURSOR; switch(yych) { - case '-': case '0': case '1': case '2': @@ -183,7 +182,6 @@ yy16: if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { - case '-': case '0': case '1': case '2': diff --git a/ext/pdo/pdo_sql_parser.c.orig b/ext/pdo/pdo_sql_parser.c.orig index 9b537680c..d507f7d9c 100644 --- a/ext/pdo/pdo_sql_parser.c.orig +++ b/ext/pdo/pdo_sql_parser.c.orig @@ -1,10 +1,10 @@ -/* Generated by re2c 0.11.0 on Mon Oct 29 18:36:37 2007 */ +/* Generated by re2c 0.11.0 on Mon Nov 26 16:10:28 2007 */ #line 1 "ext/pdo/pdo_sql_parser.re" /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_sql_parser.c,v 1.35.2.6.2.13 2007/10/29 22:37:25 iliaa Exp $ */ +/* $Id: pdo_sql_parser.c,v 1.35.2.6.2.15 2007/12/31 07:20:09 sebastian Exp $ */ #include "php.h" #include "php_pdo_driver.h" @@ -78,7 +78,6 @@ yy4: yy5: yych = *++YYCURSOR; switch(yych) { - case '-': case '0': case '1': case '2': @@ -156,7 +155,7 @@ yy6: yy7: #line 62 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_BIND_POS); } -#line 160 "ext/pdo/pdo_sql_parser.c" +#line 159 "ext/pdo/pdo_sql_parser.c" yy8: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -172,12 +171,12 @@ yy8: yy10: #line 64 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 176 "ext/pdo/pdo_sql_parser.c" +#line 175 "ext/pdo/pdo_sql_parser.c" yy11: ++YYCURSOR; #line 65 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_EOI); } -#line 181 "ext/pdo/pdo_sql_parser.c" +#line 180 "ext/pdo/pdo_sql_parser.c" yy13: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -190,13 +189,12 @@ yy13: yy15: #line 60 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 194 "ext/pdo/pdo_sql_parser.c" +#line 193 "ext/pdo/pdo_sql_parser.c" yy16: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { - case '-': case '0': case '1': case '2': @@ -265,7 +263,7 @@ yy16: yy18: #line 61 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_BIND); } -#line 269 "ext/pdo/pdo_sql_parser.c" +#line 267 "ext/pdo/pdo_sql_parser.c" yy19: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -279,7 +277,7 @@ yy21: ++YYCURSOR; #line 59 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 283 "ext/pdo/pdo_sql_parser.c" +#line 281 "ext/pdo/pdo_sql_parser.c" yy23: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -293,7 +291,7 @@ yy25: ++YYCURSOR; #line 58 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 297 "ext/pdo/pdo_sql_parser.c" +#line 295 "ext/pdo/pdo_sql_parser.c" } #line 66 "ext/pdo/pdo_sql_parser.re" diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index 5f957bc24..3b89d14d0 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_sql_parser.re,v 1.28.2.4.2.10 2007/10/29 22:37:25 iliaa Exp $ */ +/* $Id: pdo_sql_parser.re,v 1.28.2.4.2.12 2007/12/31 07:17:40 sebastian Exp $ */ #include "php.h" #include "php_pdo_driver.h" @@ -46,7 +46,7 @@ static int scan(Scanner *s) s->tok = cursor; /*!re2c - BINDCHR = [:][a-zA-Z0-9_-]+; + BINDCHR = [:][a-zA-Z0-9_]+; QUESTION = [?]; SPECIALS = [:?"']; MULTICHAR = [:?]; diff --git a/ext/pdo/pdo_sqlstate.c b/ext/pdo/pdo_sqlstate.c index c92ea4b4e..181415459 100644 --- a/ext/pdo/pdo_sqlstate.c +++ b/ext/pdo/pdo_sqlstate.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_sqlstate.c,v 1.7.2.1.2.1 2007/01/01 09:36:04 sebastian Exp $ */ +/* $Id: pdo_sqlstate.c,v 1.7.2.1.2.2 2007/12/31 07:20:09 sebastian Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 3e85321b7..2e1621672 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_stmt.c,v 1.118.2.38.2.26 2007/10/31 12:58:24 iliaa Exp $ */ +/* $Id: pdo_stmt.c,v 1.118.2.38.2.34 2008/02/26 00:14:04 iliaa Exp $ */ /* The PDO Statement Handle Class */ @@ -894,6 +894,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, int flags = how & PDO_FETCH_FLAGS, idx, old_arg_count = 0; zend_class_entry *ce = NULL, *old_ce = NULL; zval grp_val, *grp, **pgrp, *retval, *old_ctor_args = NULL; + int colno; if (how == PDO_FETCH_USE_DEFAULT) { how = stmt->default_fetch_type; @@ -909,6 +910,12 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, return 1; } + if (flags & PDO_FETCH_GROUP && stmt->fetch.column == -1) { + colno = 1; + } else { + colno = stmt->fetch.column; + } + if (return_value) { int i = 0; @@ -945,13 +952,21 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, break; case PDO_FETCH_COLUMN: - if (stmt->fetch.column >= 0 && stmt->fetch.column < stmt->column_count) { - fetch_value(stmt, return_value, stmt->fetch.column, NULL TSRMLS_CC); + if (colno >= 0 && colno < stmt->column_count) { + if (flags == PDO_FETCH_GROUP && stmt->fetch.column == -1) { + fetch_value(stmt, return_value, 1, NULL TSRMLS_CC); + } else if (flags == PDO_FETCH_GROUP && colno) { + fetch_value(stmt, return_value, 0, NULL TSRMLS_CC); + } else { + fetch_value(stmt, return_value, colno, NULL TSRMLS_CC); + } if (!return_all) { return 1; } else { break; } + } else { + pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "Invalid column index" TSRMLS_CC); } return 0; @@ -1049,7 +1064,11 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, if (return_all && how != PDO_FETCH_KEY_PAIR) { INIT_PZVAL(&grp_val); - fetch_value(stmt, &grp_val, i, NULL TSRMLS_CC); + if (flags == PDO_FETCH_GROUP && how == PDO_FETCH_COLUMN && stmt->fetch.column > 0) { + fetch_value(stmt, &grp_val, colno, NULL TSRMLS_CC); + } else { + fetch_value(stmt, &grp_val, i, NULL TSRMLS_CC); + } convert_to_string(&grp_val); if (how == PDO_FETCH_COLUMN) { i = stmt->column_count; /* no more data to fetch */ @@ -1527,7 +1546,7 @@ static PHP_METHOD(PDOStatement, fetchAll) switch(ZEND_NUM_ARGS()) { case 0: case 1: - stmt->fetch.column = how & PDO_FETCH_GROUP ? 1 : 0; + stmt->fetch.column = how & PDO_FETCH_GROUP ? -1 : 0; break; case 2: convert_to_long(arg2); diff --git a/ext/pdo/php_pdo.h b/ext/pdo/php_pdo.h index 52ecbd3d0..4812a6d48 100755 --- a/ext/pdo/php_pdo.h +++ b/ext/pdo/php_pdo.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pdo.h,v 1.7.2.5.2.3 2007/01/01 09:36:04 sebastian Exp $ */ +/* $Id: php_pdo.h,v 1.7.2.5.2.4 2007/12/31 07:20:09 sebastian Exp $ */ #ifndef PHP_PDO_H #define PHP_PDO_H diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h index 4bb2efc9d..eec8f2137 100755 --- a/ext/pdo/php_pdo_driver.h +++ b/ext/pdo/php_pdo_driver.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pdo_driver.h,v 1.66.2.11.2.6 2007/07/23 11:53:58 jani Exp $ */ +/* $Id: php_pdo_driver.h,v 1.66.2.11.2.8 2007/12/31 07:20:09 sebastian Exp $ */ #ifndef PHP_PDO_DRIVER_H #define PHP_PDO_DRIVER_H @@ -67,7 +67,7 @@ enum pdo_param_type { PDO_PARAM_STMT, /* hierarchical result set */ /* get_col ptr should point to a zend_bool */ - PDO_PARAM_BOOL, + PDO_PARAM_BOOL }; /* magic flag to denote a parameter as being input/output */ diff --git a/ext/pdo/php_pdo_int.h b/ext/pdo/php_pdo_int.h index 3f8f76888..dd2218b3d 100755 --- a/ext/pdo/php_pdo_int.h +++ b/ext/pdo/php_pdo_int.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pdo_int.h,v 1.17.2.6.2.2 2007/01/01 09:36:04 sebastian Exp $ */ +/* $Id: php_pdo_int.h,v 1.17.2.6.2.3 2007/12/31 07:20:09 sebastian Exp $ */ /* Stuff private to the PDO extension and not for consumption by PDO drivers * */ diff --git a/ext/pdo/tests/bug_43130.phpt b/ext/pdo/tests/bug_43130.phpt index 5082895cb..dd956299e 100644 --- a/ext/pdo/tests/bug_43130.phpt +++ b/ext/pdo/tests/bug_43130.phpt @@ -6,6 +6,7 @@ if (!extension_loaded('pdo')) die('skip'); $dir = getenv('REDIR_TEST_DIR'); if (false == $dir) die('skip no driver'); if (!strncasecmp(getenv('PDOTEST_DSN'), 'sqlite', strlen('sqlite'))) die('skip not relevant for sqlite driver'); +if (!strncasecmp(getenv('PDOTEST_DSN'), 'pgsql', strlen('pgsql'))) die('skip not relevant for pgsql driver'); require_once $dir . 'pdo_test.inc'; PDOTest::skip(); ?> @@ -27,5 +28,8 @@ $id = '1'; $stmt->execute(); var_dump($stmt->fetch(PDO::FETCH_COLUMN)); ?> ---EXPECT-- -string(5) "test1" +--EXPECTF-- +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in %s on line %d + +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number in %s on line %d +bool(false) diff --git a/ext/pdo/tests/bug_43663.phpt b/ext/pdo/tests/bug_43663.phpt new file mode 100644 index 000000000..2e903d788 --- /dev/null +++ b/ext/pdo/tests/bug_43663.phpt @@ -0,0 +1,22 @@ +--TEST-- +PDO Common: Bug #43663 (__call on classes derived from PDO) +--SKIPIF-- +<?php # vim:ft=php +if (!extension_loaded('pdo_sqlite')) die('skip no pdo_sqlite'); +?> +--FILE-- +<?php +class test extends PDO{ + function __call($name, array $args) { + echo "Called $name in ".__CLASS__."\n"; + } + function foo() { + echo "Called foo in ".__CLASS__."\n"; + } +} +$a = new test('sqlite::memory:'); +$a->foo(); +$a->bar(); +--EXPECT-- +Called foo in test +Called bar in test diff --git a/ext/pdo/tests/bug_44159.phpt b/ext/pdo/tests/bug_44159.phpt new file mode 100644 index 000000000..db4da4013 --- /dev/null +++ b/ext/pdo/tests/bug_44159.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #44159 (Crash: $pdo->setAttribute(PDO::STATEMENT_ATTR_CLASS, NULL)) +--SKIPIF-- +<?php +if (!extension_loaded('pdo_sqlite')) die('skip no pdo_sqlite'); +?> +--FILE-- +<?php + +$pdo = new PDO("sqlite:/tmp/foo.db"); + +$attrs = array(PDO::ATTR_STATEMENT_CLASS, PDO::ATTR_STRINGIFY_FETCHES, PDO::NULL_TO_STRING); + +foreach ($attrs as $attr) { + var_dump($pdo->setAttribute($attr, NULL)); + var_dump($pdo->setAttribute($attr, 1)); + var_dump($pdo->setAttribute($attr, 'nonsense')); +} + +?> +--EXPECTF-- +Warning: PDO::setAttribute(): SQLSTATE[HY000]: General error: PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); the classname must be a string specifying an existing class in %s on line %d +bool(false) + +Warning: PDO::setAttribute(): SQLSTATE[HY000]: General error: PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); the classname must be a string specifying an existing class in %s on line %d +bool(false) + +Warning: PDO::setAttribute(): SQLSTATE[HY000]: General error: PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); the classname must be a string specifying an existing class in %s on line %d +bool(false) + +Warning: PDO::setAttribute(): SQLSTATE[HY000]: General error: attribute value must be an integer in %s on line %d +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) |
