#43412 [NEW]: Globals are not set if object passed by reference
| From: | sonya at look-for-it dot de | Date: | Mon, 26 Nov 2007 13:03:06 +0000 |
| Subject: | #43412 [NEW]: Globals are not set if object passed by reference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-120085@lists.php.net to get a copy of this message | ||
From: sonya at look-for-it dot de
Operating system: Windows XP
PHP version: 5.2.5
PHP Bug Type: SOAP related
Bug description: Globals are not set if object passed by reference
Description:
------------
I was not able to continue my bug report #43022 because it's set to bogus.
But it's still about different behaviour of $GLOBALS within SOAP. I try to
make it more clear in this bug report.
Reproduce code:
---------------
Please create a file inc.php
----------------------------
inc.php
----------------------------
class TestClass1 {
public $testvar1;
function TestClass1() {
$this->testvar1 = 100;
}
}
$TestClass1 = & new TestClass1();
// GLOBALS['TestClass1"] is NOT set while executing via SOAP
// GLOBALS['TestClass1"] is set while executing via browser
class TestClass2 {
public $testvar2;
function TestClass2() {
global $TestClass1;
$this->testvar2 = $TestClass1->testvar1;
}
}
$TestClass2 = new TestClass2();
----------------------------------------------
then compare $GLOBALS['TestClass1'] while executing in Browser
--------------------------------------
test.php
--------------------------------------
require_once 'inc.php';
print '<pre>';
print_r ($GLOBALS['TestClass1']);
print '</pre>';
--------------------------------------
and while executing via SOAP
--------------------------------------
server.php
--------------------------------------
function testGlobals() {
global $TestClass1, $TestClass2;
require_once 'inc.php';
return serialize($GLOBALS['TestClass1']);
}
--------------------------------------
client.php
--------------------------------------
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient("test.wsdl", array('trace'=> 1,
exceptions'=>
0));
print '<pre>';
print_r (unserialize($client->testGlobals()));
print '</pre>';
----------------------------------------------
Expected result:
----------------
Expected the same result returned by soap service and displayed in
browser. $GLOBALS assignment has to be the same.
Actual result:
--------------
You will find that TestClass1 is assigned to $GLOBALS when executing via
Browser and not assigned when executing the _same_ code via SOAP. Unless
you pass the object by value in inc.php.
My question is - why there is different behaviour with the same code?
Thank you.
--
Edit bug report at http://bugs.php.net/?id=43412&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43412&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43412&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43412&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43412&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43412&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=43412&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43412&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43412&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43412&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43412&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43412&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=43412&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=43412&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43412&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43412&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43412&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43412&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43412&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43412&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43412&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43412&r=mysqlcfg