php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71986 Nested foreach assign-by-reference creates broken variables
Submitted: 2016-04-08 09:06 UTC Modified: -
From: joshdifabio at gmail dot com Assigned:
Status: Closed Package: SOAP related
PHP Version: 7.0.5 OS: All
Private report: No CVE-ID: None
 [2016-04-08 09:06 UTC] joshdifabio at gmail dot com
Description:
------------
Nested foreach loops using assign-by-reference produce variables which, when passed to SoapClient, cause errors. We discovered this bug when passing data returned by the official AWS DynamoDB client to SoapClient, but reproduce it below with a few lines of PHP.

https://github.com/aws/aws-sdk-php/blob/3.17.5/src/DynamoDb/Marshaler.php#L285

Test script:
---------------
<?php

$client = new SoapClient(null, ['uri' => '', 'location' => '']);

$data = [[null]];

foreach ($data as &$value) {
    foreach ($value as &$_value) {
        $_value = 'foo';
    }
}

$client->__soapCall('call', $data);

Expected result:
----------------
PHP Fatal error:  Uncaught SoapFault exception: [HTTP] Unable to parse URL

(Because SoapClient attempts to retrieve the WSDL from the invalid URL provided in the test code. This error is seen in PHP5.)

Actual result:
--------------
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: Cannot find encoding

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-08 09:58 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c45f7b97a3252767b31d38fd7e761b9291ed2152
Log: Fixed bug #71986 (Nested foreach assign-by-reference creates broken variables)
 [2016-04-08 09:58 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2016-04-08 09:58 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c45f7b97a3252767b31d38fd7e761b9291ed2152
Log: Fixed bug #71986 (Nested foreach assign-by-reference creates broken variables)
 [2016-07-20 11:32 UTC] davey@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c45f7b97a3252767b31d38fd7e761b9291ed2152
Log: Fixed bug #71986 (Nested foreach assign-by-reference creates broken variables)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 11:01:28 2024 UTC