1--TEST-- 2Bug #72489 (PHP Crashes When Modifying Array Containing MySQLi Result Data) 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7?> 8--FILE-- 9<?php 10 11require_once("connect.inc"); 12if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 13 printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 14} 15 16if (!$link->query("DROP TABLE IF EXISTS bug72489")) { 17 printf("[002] [%d] %s\n", $link->errno, $link->error); 18} 19 20if (!$link->query("CREATE TABLE bug72489 (id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, code VARCHAR(30) NOT NULL)")) { 21 printf("[003] [%d] %s\n", $link->errno, $link->error); 22} 23 24$seedSQL = "INSERT INTO bug72489 (`code`) VALUES ('code1'), ('code2'), ('code3');"; 25if (!$link->query($seedSQL)) { 26 printf("[004] [%d] %s\n", $link->errno, $link->error); 27} 28 29$subRow = array(); 30 31if (!$stmt = $link->prepare("SELECT id, code FROM bug72489")) { 32 printf("[005] [%d] %s\n", $link->errno, $link->error); 33} 34 35$stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY); 36if (!$stmt->bind_result($subRow['id'], $subRow['code']) || !$stmt->execute()) { 37 printf("[006] [%d] %s\n", $link->errno, $link->error); 38} 39 40while ($stmt->fetch()) { 41 $testArray = array('id' => 1); 42 $subRow['code'] = $testArray; 43} 44 45echo "Finished 1\n"; 46 47$newArray = array(); 48 49echo "Finished 2\n"; 50 51?> 52--CLEAN-- 53<?php 54require_once("connect.inc"); 55if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 56 printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 57 58if (!mysqli_query($link, "DROP TABLE IF EXISTS bug72489")) 59 printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 60 61mysqli_close($link); 62?> 63--EXPECT-- 64Finished 1 65Finished 2 66