Bug #77273 [Opn->Csd]: array_walk_recursive corrupts value types leading to PDO failure

From: Date: Thu, 03 Jan 2019 08:41:39 +0000
Subject: Bug #77273 [Opn->Csd]: array_walk_recursive corrupts value types leading to PDO failure
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218769@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77273&edit=1 ID: 77273 Updated by: nikic@php.net Reported by: andreas at sassermann dot de Summary: array_walk_recursive corrupts value types leading to PDO failure -Status: Open +Status: Closed Type: Bug Package: Arrays related Operating System: linux PHP Version: 7.2 Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=cb009b12a54c3dbb0e10b79c6ca77db8736d55b9 Log: Fixed bug #77273 Previous Comments: ------------------------------------------------------------------------ [2019-01-02 23:04:43] spotnyk at gmail dot com I can confirm this issue. It's not just walk_recursive, but any use of referenced array content. First experienced with: 7.1.8-2+ubuntu16.04.1+deb.sury.org+4 CANNOT reproduce with: 7.1.7-1+ubuntu16.04.1+deb.sury.org+1 ------------------------------------------------------------------------ [2018-12-21 21:23:01] cmb@php.net Thanks, Andreas! Changing the affected version to 7.2, since this is the oldest branch which would receive the bugfix. ------------------------------------------------------------------------ [2018-12-21 19:54:39] andreas at sassermann dot de I could verify the bug with 7.3.0. ------------------------------------------------------------------------ [2018-12-09 16:29:59] andreas at sassermann dot de Description: ------------ After processing an array containing pdo options with array_walk_recursive, the PDO constructor fails with exception: PDO::__construct(): SQLSTATE[HY000]: General error: attribute value must be an integer According to vardump, the option array is perfectly fine. The assumption, that some internal structure get corrupted is triggered by the fact that by doing an is_integer() on the array values, the array becomes usable again. The problem has been reproduced using PHP 7.1.1 (cli) ( NTS ) PHP 7.2.12 (cli) (built: Nov 6 2018 15:07:37) ( NTS ) It does not occur with PHP 7.0.30-0+deb9u1 (cli) (built: Jun 14 2018 13:50:25) ( NTS ) Test script: --------------- Find testscript at github: https://gist.github.com/a-sassermann/840bd057f579169dc44bc4eee85b158a It contains 3 tests: 1. check using PDO with unmodified option array 2. do an array_walk_recursive on option array before using with PDO 3. after array_walk_recursive do an is_integer() on array values Expected result: ---------------- All tests should succeed without error. Actual result: -------------- Test 2 fails with exception PDO::__construct(): SQLSTATE[HY000]: General error: attribute value must be an integer ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77273&edit=1

« previous php.bugs (#218769) next »