From be11869f55a387b75e28b86d1801cebbd7952457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Sun, 2 May 2021 19:06:44 +0200 Subject: [PATCH 1/2] Fix the default value of $mode in PDOStatement::fetch*() --- ext/pdo/pdo_stmt.stub.php | 4 ++-- ext/pdo/pdo_stmt_arginfo.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/pdo/pdo_stmt.stub.php b/ext/pdo/pdo_stmt.stub.php index 26f4ace9f720f..8a7bfa5049a80 100644 --- a/ext/pdo/pdo_stmt.stub.php +++ b/ext/pdo/pdo_stmt.stub.php @@ -32,10 +32,10 @@ public function errorInfo() {} public function execute(?array $params = null) {} /** @return mixed */ - public function fetch(int $mode = PDO::FETCH_BOTH, int $cursorOrientation = PDO::FETCH_ORI_NEXT, int $cursorOffset = 0) {} + public function fetch(int $mode = 0, int $cursorOrientation = PDO::FETCH_ORI_NEXT, int $cursorOffset = 0) {} /** @return array */ - public function fetchAll(int $mode = PDO::FETCH_BOTH, mixed ...$args) {} + public function fetchAll(int $mode = 0, mixed ...$args) {} /** @return mixed */ public function fetchColumn(int $column = 0) {} diff --git a/ext/pdo/pdo_stmt_arginfo.h b/ext/pdo/pdo_stmt_arginfo.h index a8cc88c07f90e..5499f487369ea 100644 --- a/ext/pdo/pdo_stmt_arginfo.h +++ b/ext/pdo/pdo_stmt_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 764dfcd532d90de147f5e4b17e8a56e1545e289c */ + * Stub hash: f43b03f0139522fbd97c57cf7294d8566cb95ecb */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindColumn, 0, 0, 2) ZEND_ARG_TYPE_MASK(0, column, MAY_BE_STRING|MAY_BE_LONG, NULL) @@ -39,13 +39,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_execute, 0, 0, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetch, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "PDO::FETCH_BOTH") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cursorOrientation, IS_LONG, 0, "PDO::FETCH_ORI_NEXT") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cursorOffset, IS_LONG, 0, "0") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchAll, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "PDO::FETCH_BOTH") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0") ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0) ZEND_END_ARG_INFO() From 8513635951dfd673e539342d0b8a8711b8496285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 3 May 2021 11:49:26 +0200 Subject: [PATCH 2/2] Expose PDO_FETCH_USE_DEFAULT as PDO::FETCH_DEFAULT --- ext/pdo/pdo_dbh.c | 1 + ext/pdo/pdo_stmt.stub.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 98aa8d1a72389..cea49d10088e5 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -1342,6 +1342,7 @@ void pdo_dbh_init(void) REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_POST", (zend_long)PDO_PARAM_EVT_FETCH_POST); REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_NORMALIZE", (zend_long)PDO_PARAM_EVT_NORMALIZE); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_DEFAULT", (zend_long)PDO_FETCH_USE_DEFAULT); REGISTER_PDO_CLASS_CONST_LONG("FETCH_LAZY", (zend_long)PDO_FETCH_LAZY); REGISTER_PDO_CLASS_CONST_LONG("FETCH_ASSOC", (zend_long)PDO_FETCH_ASSOC); REGISTER_PDO_CLASS_CONST_LONG("FETCH_NUM", (zend_long)PDO_FETCH_NUM); diff --git a/ext/pdo/pdo_stmt.stub.php b/ext/pdo/pdo_stmt.stub.php index 8a7bfa5049a80..e2c25b6a7a028 100644 --- a/ext/pdo/pdo_stmt.stub.php +++ b/ext/pdo/pdo_stmt.stub.php @@ -32,10 +32,10 @@ public function errorInfo() {} public function execute(?array $params = null) {} /** @return mixed */ - public function fetch(int $mode = 0, int $cursorOrientation = PDO::FETCH_ORI_NEXT, int $cursorOffset = 0) {} + public function fetch(int $mode = PDO::FETCH_DEFAULT, int $cursorOrientation = PDO::FETCH_ORI_NEXT, int $cursorOffset = 0) {} /** @return array */ - public function fetchAll(int $mode = 0, mixed ...$args) {} + public function fetchAll(int $mode = PDO::FETCH_DEFAULT, mixed ...$args) {} /** @return mixed */ public function fetchColumn(int $column = 0) {}