|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43412 Globals are not set if object passed by reference
Submitted: 2007-11-26 13:03 UTC Modified: 2007-11-26 14:53 UTC
From: sonya at look-for-it dot de Assigned:
Status: Not a bug Package: SOAP related
PHP Version: 5.2.5 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
31 - 16 = ?
Subscribe to this entry?

 [2007-11-26 13:03 UTC] sonya at look-for-it dot de
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

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

require_once 'inc.php';
print '<pre>';
print_r ($GLOBALS['TestClass1']);
print '</pre>';

and while executing via SOAP
function testGlobals() {
    global $TestClass1, $TestClass2;
    require_once 'inc.php';
    return serialize($GLOBALS['TestClass1']);

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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-26 14:53 UTC] sonya at look-for-it dot de
$GLOBALS are not set because requre_once is called within a function. Sorry, you can close this "bug" :)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 23:01:28 2024 UTC