From: Nikita Popov Date: Wed, 25 Nov 2020 15:29:00 +0000 (+0100) Subject: Merge branch 'PHP-7.4' into PHP-8.0 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=518eb0ca2b8ea7fecb7a8db793de06cce568d8ce;p=php Merge branch 'PHP-7.4' into PHP-8.0 * PHP-7.4: Fixed error reporting in mysqli_stmt::__construct --- 518eb0ca2b8ea7fecb7a8db793de06cce568d8ce diff --cc ext/mysqli/mysqli.c index 55557da488,c4dbcb251a..928ef8ea76 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@@ -986,9 -1045,8 +986,8 @@@ PHP_METHOD(mysqli_stmt, __construct size_t statement_len; if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!", &mysql_link, mysqli_link_class_entry, &statement, &statement_len) == FAILURE) { - return; + RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID); stmt = (MY_STMT *) ecalloc(1, sizeof(MY_STMT)); @@@ -1007,12 -1062,26 +1003,20 @@@ mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); mysqli_resource->ptr = (void *)stmt; - mysqli_resource->status = (ZEND_NUM_ARGS() == 1) ? MYSQLI_STATUS_INITIALIZED : MYSQLI_STATUS_VALID; + mysqli_resource->status = MYSQLI_STATUS_INITIALIZED; MYSQLI_REGISTER_RESOURCE_EX(mysqli_resource, getThis()); + + if (statement) { + if(mysql_stmt_prepare(stmt->stmt, statement, statement_len)) { + MYSQLI_REPORT_STMT_ERROR(stmt->stmt); + RETURN_FALSE; + } + mysqli_resource->status = MYSQLI_STATUS_VALID; + } } -/* }}} */ -/* {{{ mixed mysqli_result_construct() -constructor for result object. -Parameters: - object [, mode] -> mysqli_store/use_result -*/ -PHP_FUNCTION(mysqli_result_construct) +PHP_METHOD(mysqli_result, __construct) { MY_MYSQL *mysql; MYSQL_RES *result = NULL;