php.net |  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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xcl_rockman at qq dot com
New email:
PHP Version: OS:

 

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

can't return context

Test script:
---------------
$client = new GearmanClient();
$client->addServer();

# set a function to be called when the work is complete
$client->setCompleteCallback("reverse_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");

$client->runTasks();

# 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: H.foo:21, Hello World!
t1: H:foo:22, !dlroW olleH

Actual result:
--------------
empty

Patches

Pull Requests

History

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] kalle@php.net
-Status: Open +Status: Suspended
 [2017-01-10 08:23 UTC] kalle@php.net
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 Dec 21 12:01:31 2024 UTC