|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64796 addtask cant pass the reference parameter of the context
Submitted: 2013-05-09 08:29 UTC Modified: 2017-01-10 08:23 UTC
From: xcl_rockman at qq dot com Assigned:
Status: Suspended Package: gearman (PECL)
PHP Version: 5.4.15 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-05-09 08:29 UTC] xcl_rockman at qq dot com
addtask cant pass the reference parameter of the context 

can't return context

Test script:
$client = new GearmanClient();

# set a function to be called when the work is complete

# Add some tasks for a placeholder of where to put the results
$results = array();
$client->addTask("reverse", "Hello World!", &$results, "t1");
$client->addTask("reverse", "!dlroW olleH", &$results, "t2");


# The results should now be filled in from the callbacks
foreach ($results as $id => $result)
   echo $id . ": " . $result['handle'] . ", " . $result['data'] . "\n";

function reverse_complete($task, $results)
   $results[$task->unique()] = array("handle"=>$task->jobHandle(), "data"=>$task->data());

Expected result:
t2:, Hello World!
t1: H:foo:22, !dlroW olleH

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-04 15:38 UTC] gearman at mailinator dot com
PHP 5.4 changed how references can be passed in a function. So this is not a 
Gearman issue.

Try the following
//remove reference '&' from $results
$client->addTask("reverse", "Hello World!", $results, "t1");

//add reference '&' for $results
function reverse_complete($task, $results)
 [2017-01-10 08:23 UTC]
-Status: Open +Status: Suspended
 [2017-01-10 08:23 UTC]
The gearman extension have not had much activity in the past few years, so I'm taking the safe bet that this is no longer under active development (as I don't consider the typo fixes on the github repo an active development), besides that it also targets unsupported PHP versions. Please unsuspend this report in case it begins to blossom with life once more
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 07:01:29 2024 UTC