Skip to content

Commit 0c6a68f

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Follow up #77849 PDOStatement objects in undefined state after clone
2 parents 0d5be6c + a2b8a62 commit 0c6a68f

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,22 +2263,6 @@ static int dbstmt_compare(zval *object1, zval *object2)
22632263
return -1;
22642264
}
22652265

2266-
static zend_object *dbstmt_clone_obj(zval *zobject)
2267-
{
2268-
pdo_stmt_t *stmt;
2269-
pdo_stmt_t *old_stmt;
2270-
2271-
stmt = zend_object_alloc(sizeof(pdo_stmt_t), Z_OBJCE_P(zobject));
2272-
zend_object_std_init(&stmt->std, Z_OBJCE_P(zobject));
2273-
object_properties_init(&stmt->std, Z_OBJCE_P(zobject));
2274-
2275-
old_stmt = Z_PDO_STMT_P(zobject);
2276-
2277-
zend_objects_clone_members(&stmt->std, &old_stmt->std);
2278-
2279-
return &stmt->std;
2280-
}
2281-
22822266
zend_object_handlers pdo_dbstmt_object_handlers;
22832267
static int pdo_row_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data);
22842268

@@ -2301,7 +2285,7 @@ void pdo_stmt_init(void)
23012285
pdo_dbstmt_object_handlers.unset_property = dbstmt_prop_delete;
23022286
pdo_dbstmt_object_handlers.get_method = dbstmt_method_get;
23032287
pdo_dbstmt_object_handlers.compare_objects = dbstmt_compare;
2304-
pdo_dbstmt_object_handlers.clone_obj = dbstmt_clone_obj;
2288+
pdo_dbstmt_object_handlers.clone_obj = NULL;
23052289

23062290
INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions);
23072291
pdo_row_ce = zend_register_internal_class(&ce);

ext/pdo/tests/bug_77849_2.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
PDO Common: Bug #77849 (inconsistent state of cloned statament object)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo')) die('skip');
6+
?>
7+
--FILE--
8+
<?php
9+
$stmt = new PDOStatement();
10+
11+
clone $stmt;
12+
?>
13+
--EXPECTF--
14+
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDOStatement in %s:4
15+
Stack trace:
16+
#0 {main}
17+
thrown in %s on line 4
18+

0 commit comments

Comments
 (0)