com php-src: Fixed PDORow behaviour and message.: ext/pdo/pdo _stmt.c ext/pdo/tests/pdo_036.phpt ext/pdo/te sts/pdorow.phpt

From: Date: Sun, 01 Mar 2015 02:37:57 +0000
Subject: com php-src: Fixed PDORow behaviour and message.: ext/pdo/pdo _stmt.c ext/pdo/tests/pdo_036.phpt ext/pdo/te sts/pdorow.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-86005@lists.php.net to get a copy of this message
Commit: b00cd68d7419bea8d8155ae585b85cf4f5fe8897 Author: Danack <Danack@basereality.com> Sun, 1 Mar 2015 02:37:57 +0000 Parents: 54e2020ee3e6142a86db03f1a9d47bc763334dbb Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b00cd68d7419bea8d8155ae585b85cf4f5fe8897 Log: Fixed PDORow behaviour and message. Changed paths: M ext/pdo/pdo_stmt.c M ext/pdo/tests/pdo_036.phpt M ext/pdo/tests/pdorow.phpt Diff: diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index c6ebc37..9474287 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -113,9 +113,10 @@ ZEND_END_ARG_INFO() RETURN_FALSE; \ } \ -static PHP_FUNCTION(dbstmt_constructor) /* {{{ */ +static PHP_FUNCTION(dbrow_constructor) /* {{{ */ { - php_error_docref(NULL, E_ERROR, "You should not create a PDOStatement manually"); +// php_error_docref(NULL, E_ERROR, "You should not create a PDOStatement manually"); + zend_throw_exception_ex(php_pdo_get_exception(), 0, "You may not create a PDORow manually"); } /* }}} */ @@ -2640,7 +2641,7 @@ static union _zend_function *row_get_ctor(zend_object *object) ctor.type = ZEND_INTERNAL_FUNCTION; ctor..function_name = zend_string_init("__construct", sizeof("__construct") - 1, 0); ctor.scope = pdo_row_ce; - ctor.handler = ZEND_FN(dbstmt_constructor); + ctor.handler = ZEND_FN(dbrow_constructor); ctor.fn_flags = ZEND_ACC_PUBLIC; return (union _zend_function*)&ctor; diff --git a/ext/pdo/tests/pdo_036.phpt b/ext/pdo/tests/pdo_036.phpt index 55c8876..16a1597 100644 --- a/ext/pdo/tests/pdo_036.phpt +++ b/ext/pdo/tests/pdo_036.phpt @@ -7,17 +7,29 @@ Testing PDORow and PDOStatement instances with Reflection $instance = new reflectionclass('pdostatement'); $x = $instance->newInstance(); -var_dump($x); -$instance = new reflectionclass('pdorow'); -$x = $instance->newInstance(); -var_dump($x); +if ($x instanceof pdostatement) { + echo "Ok".PHP_EOL; +} +else { + echo "Failed to create instance of pdostatment"; +} -?> ---EXPECTF-- -object(PDOStatement)#%d (1) { - [%u|b%"queryString"]=> - NULL +try { + $instance = new reflectionclass('pdorow'); + $x = $instance->newInstance(); + echo "Failed to throw exception: ".var_export($x, true); +} +catch(PDOException $pe) { + if ($pe->getMessage() != "You may not create a PDORow manually") { + echo "PDOException has wrong message."; + } + else { + echo "Ok".PHP_EOL; + } } -Fatal error: PDORow::__construct(): You should not create a PDOStatement manually in %spdo_036.php on line %d +?> +--EXPECTF-- +Ok +Ok diff --git a/ext/pdo/tests/pdorow.phpt b/ext/pdo/tests/pdorow.phpt index bcfd8ff..3b46604 100644 --- a/ext/pdo/tests/pdorow.phpt +++ b/ext/pdo/tests/pdorow.phpt @@ -5,8 +5,22 @@ Trying instantiate a PDORow object manually --FILE-- <?php -new PDORow; +try { + $instance = new PDORow; + echo "Failed to throw exception.".var_export($instance, true); +} +catch(PDOException $pe) { + if ($pe->getMessage() != "You may not create a PDORow manually") { + echo "PDOException has wrong message."; + } + else { + echo "Ok".PHP_EOL; + } +} +catch(\Exception $e) { + echo "Failed to "; +} ?> --EXPECTF-- -Fatal error: PDORow::__construct(): You should not create a PDOStatement manually in %s on line %d +Ok

« previous php.cvs (#86005) next »