|
| 1 | +--TEST-- |
| 2 | +Memory leak when load_wsdl_ex() fails |
| 3 | +--EXTENSIONS-- |
| 4 | +soap |
| 5 | +--INI-- |
| 6 | +soap.wsdl_cache_enabled=0 |
| 7 | +--SKIPIF-- |
| 8 | +<?php |
| 9 | +if (!file_exists(__DIR__ . "/../../../sapi/cli/tests/php_cli_server.inc")) { |
| 10 | + echo "skip sapi/cli/tests/php_cli_server.inc required but not found"; |
| 11 | +} |
| 12 | +?> |
| 13 | +--FILE-- |
| 14 | +<?php |
| 15 | + |
| 16 | +include __DIR__ . "/../../../sapi/cli/tests/php_cli_server.inc"; |
| 17 | + |
| 18 | +$context = stream_context_create([ |
| 19 | + 'http' => ['header' => [ |
| 20 | + "Authorization: Bar", |
| 21 | + "aUTHORIZATION: Baz", |
| 22 | + ]], |
| 23 | +]); |
| 24 | + |
| 25 | +$wsdl = <<<END |
| 26 | +<?xml version="1.0" encoding="utf-8"?> |
| 27 | +<definitions |
| 28 | + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" |
| 29 | + xmlns="http://schemas.xmlsoap.org/wsdl/" |
| 30 | +> |
| 31 | + <import location="http://localhost:0/index.php"/> |
| 32 | +</definitions> |
| 33 | +END; |
| 34 | + |
| 35 | +$server_code = "echo <<<END\n$wsdl\nEND;"; |
| 36 | +php_cli_server_start($server_code); |
| 37 | +$wsdl_server_port = PHP_CLI_SERVER_PORT; |
| 38 | + |
| 39 | +try { |
| 40 | + $client = new SoapClient("http://localhost:$wsdl_server_port", [ |
| 41 | + 'soap_version' => SOAP_1_1, |
| 42 | + 'stream_context' => $context, |
| 43 | + ]); |
| 44 | +} catch (SoapFault $e) { |
| 45 | + echo get_class($e) . ': ' . $e->getMessage() . "\n"; |
| 46 | + echo "--- Raw Server Response Body ---\n"; |
| 47 | + var_dump(@file_get_contents("http://localhost:$wsdl_server_port", false, $context)); |
| 48 | +} |
| 49 | + |
| 50 | +?> |
| 51 | +--EXPECT-- |
| 52 | +SoapFault: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost:0/index.php' : failed to load external entity "http://localhost:0/index.php" |
| 53 | + |
| 54 | +--- Raw Server Response Body --- |
| 55 | +string(216) "<?xml version="1.0" encoding="utf-8"?> |
| 56 | +<definitions |
| 57 | + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" |
| 58 | + xmlns="http://schemas.xmlsoap.org/wsdl/" |
| 59 | +> |
| 60 | + <import location="http://localhost:0/index.php"/> |
| 61 | +</definitions>" |
0 commit comments