From:             sonya at look-for-it dot de
Operating system: Windows XP
PHP version:      5.2.4
PHP Bug Type:     SOAP related
Bug description:  Globals are not set if object passed by reference

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 bug report at http://bugs.php.net/?id=43022&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43022&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43022&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43022&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43022&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43022&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43022&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43022&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43022&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43022&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43022&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43022&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43022&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43022&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43022&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43022&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43022&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43022&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43022&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43022&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43022&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43022&r=mysqlcfg

Reply via email to