Bug #81040 [Opn->Fbk]: Native pass-by-ref in mysqli_stmt::bind_param leaks reference

From: Date: Fri, 21 May 2021 12:52:37 +0000
Subject: Bug #81040 [Opn->Fbk]: Native pass-by-ref in mysqli_stmt::bind_param leaks reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233951@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81040&edit=1 ID: 81040 Updated by: cmb@php.net Reported by: dharman@php.net Summary: Native pass-by-ref in mysqli_stmt::bind_param leaks reference -Status: Open +Status: Feedback Type: Bug Package: Unknown/Other Function Operating System: Windows 10 PHP Version: 8.0.6 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This doesn't appear to be particularly related to PHP 8.0. Anyway, what is the behavior with libmysql-client. It seems to me that would yield the expected behavior. Previous Comments: ------------------------------------------------------------------------ [2021-05-13 16:30:51] dharman@php.net Description: ------------ Native pass-by-reference makes elements of an array referenced. Tested with mysqli_stmt::bind_param. This results in inadvertent changes to follow up code, e.g. results from array_diff() I don't know if it's intended behaviour or if not then which component this is related to. Additionally, should the reference leak through array_diff()? Test online: https://phpize.online/?phpses=6fd2785a4408856aa1fc2aba245d05bc&sqlses=null&php_version=php8&sql_version=mysql57 Test script: --------------- <?php mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = new mysqli('localhost', 'user', 'password', 'test'); function a(&$a, &$b, &$c) { $a = 3; } $foo = [1, 2, 3]; $bar = [3, 4, 5]; $stmt = $mysqli->prepare("SELECT ?,?,?"); // What's the difference between this $stmt->bind_param('sss', $foo[0], $foo[1], $foo[2]); // and this a($foo[0], $foo[1], $foo[2]); $diff = array_diff($foo, $bar); $foo[1] = 'hi'; var_dump($diff); Expected result: ---------------- array(1) { [1] => int(2) } Actual result: -------------- array(1) { [1] => string(2) "hi" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81040&edit=1

« previous php.bugs (#233951) next »