php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63291 Global variables not working
Submitted: 2012-10-16 17:03 UTC Modified: 2012-10-18 20:57 UTC
From: chibisuke at web dot de Assigned: krakjoe (profile)
Status: Closed Package: pthreads (PECL)
PHP Version: 5.4.7 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: chibisuke at web dot de
New email:
PHP Version: OS:

 

 [2012-10-16 17:03 UTC] chibisuke at web dot de
Description:
------------
Global variables are not shared between threads, as real threads would do.

Test script:
---------------
<?php
class Test extends Thread {
    public function run() {
        $GLOBALS['x'] = 'bar';
    }
}

$x = "foo";

echo $x;
$thread = new Test();
echo $x;

$thread->start();
$thread->join();
?>


Expected result:
----------------
foobar

Actual result:
--------------
foofoo

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-16 17:07 UTC] chibisuke at web dot de
oups... uploaded the buggus testscript example....

fixed one:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

class Test extends Thread {
    public function run() {
        $GLOBALS['x'] = 'bar';
    }
}

$x = "foo";

echo $x;
$thread = new Test();

$thread->start();
$thread->join();
echo $x;
?>

however the problem remains the same.
 [2012-10-18 20:57 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2012-10-18 20:57 UTC] krakjoe@php.net
threads are not supposed to have access to global variables.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC