ID: 43022
User updated by: sonya at look-for-it dot de
Reported By: sonya at look-for-it dot de
Status: Open
Bug Type: SOAP related
Operating System: Windows XP
PHP Version: 5.2.4
New Comment:
I have just tested it on Apache/1.3.33 (Debian GNU/Linux) and
PHP/5.2.3. Same behaviour.
Previous Comments:
------------------------------------------------------------------------
[2007-10-18 14:24:06] sonya at look-for-it dot de
Description:
------------
I have problem with $GLOBALS while executing scripts via SOAP Service.
Objects passed by reference is not set in $GLOBALS and cannot be used in
other classes. The same code works perfectly if executed direct in
browser.
Reproduce code:
---------------
client.php
----------------------------------------------
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient("test.wsdl", array('trace'=> 1, 'exceptions'
=> 0));
print $client->testGlobals();
--------------------------------------------
server.php
----------------------------------------------
function testGlobals() {
global $TestClass1, $TestClass2;
require_once 'inc.php';
return $TestClass2->testvar2;
}
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("test.wsdl");
$server->addFunction("testGlobals");
$server->handle();
--------------------------------------------
inc.php
--------------------------------------------
require_once('TestClass1.class.php');
require_once('TestClass2.class.php');
$TestClass2 = new TestClass2();
-------------------------------------------
TestClass1.class.php
-------------------------------------------
class TestClass1 {
public $testvar1;
function TestClass1() {
$this->testvar1 = 100;
}
}
$TestClass1 = & new TestClass1();
---------------------------------------------
TestClass2.class.php
---------------------------------------------
class TestClass2 {
public $testvar2;
function TestClass2() {
global $TestClass1;
$this->testvar2 = $TestClass1->testvar1;
}
}
Expected result:
----------------
I expect the value 100 to be returned by service.
Actual result:
--------------
Nothing is returned. The reason is that in TestClass2 there is no
$GLOBALS['TestClass1'] unless I pass $TestClass1 by value:
(last line of TestClass1.class.php):
$TestClass1 = new TestClass1();
What is wrong here?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43022&edit=1